Getting an error while trying to debug my Api/lamb...
# help
p
Getting an error while trying to debug my Api/lambda using
sst start
. This happens after the debugger attaches. Anybody know what’s up?
Copy code
.build/services/lambda.main is undefined or not exported
Route section of API:
Copy code
routes: {
    "GET /private": "services/lambda.main",
    "GET /public": {
      function: "services/lambda.main",
      authorizationType: sst.ApiAuthorizationType.NONE,
    },
},
Build folder shows lambda.js
t
Can I see the contents of your lambda file source
p
Copy code
import { APIGatewayProxyHandlerV2 } from "aws-lambda";
import { getDB } from "./libs/db";

export const handler: APIGatewayProxyHandlerV2 = async () => {
  const db = await getDB()
  try {
    const result = await db.user.findMany();
    return {
      statusCode: 200,
      body: JSON.stringify(result),
    };
  } catch (ex) {
    return {
      statusCode: 200,
      body: ex.toString(),
    };
  }
};
Basically pulled from the prisma example minus the DB import
Realizing that it needs a main function….
😄
That’s what I get for blindly copy pasting 😄
t
Haha there you go
p
Sometimes all it takes is someone asking a question 🙂
Thanks