Gabriel
04/26/2022, 12:08 PMnew Api(this, "Api", {
defaultRoutesFolder: { folder: "src/", defaultHandler: "main" },
routes: {
//override custom functions
"GET /notes/{id}/count": {
function: 'src/notes/{id}/count.get.handler',
authorizationType: sst.ApiAuthorizationType.NONE,
},
}
}
which then generates the paths from the folder which contains:
src/notes/default.get.js
src/notes/create.post.js
src/notes/{id}/default.get.js
src/notes/{id}/note.put.js
src/notes/{id}/note.delete.js
Which then would be the same as
routes : {
"GET /notes" : "src/notes/default.get.main",
"POST /notes/create" : "src/notes/create.post.main",
"GET /notes/{id}" : "src/notes/{id}/default.get.main",
"PUT /notes/{id}/note" : "src/notes/{id}/note.put.main",
"DELETE /notes/{id}/note" : "src/notes/{id}/note.delete.main"
}
or something similar maybe?thdxr
04/26/2022, 12:20 PMthdxr
04/26/2022, 12:20 PMGabriel
04/26/2022, 12:38 PMthdxr
04/26/2022, 12:40 PMGabriel
04/26/2022, 12:52 PMroutes: {
"POST /invite": "src/invite.post.handler"
}
it will throw an error on yarn sst deploy
saying :
Error: Cannot find a handler file for "invite.post.handler"
at NodeHandler (/node_modules/@serverless-stack/core/dist/runtime/handler/node.js:98:15)
at instructions (/node_modules/@serverless-stack/core/dist/runtime/handler/handler.js:36:12)
at Object.bundle (/node_modules/@serverless-stack/core/dist/runtime/handler/handler.js:16:17)
at new Function (/node_modules/@serverless-stack/resources/src/Function.ts:362:39)
at Function.fromDefinition (/node_modules/@serverless-stack/resources/src/Function.ts:531:14)
at Api.createFunctionIntegration (/node_modules/@serverless-stack/resources/src/Api.ts:579:23)
at Api.addRoute (/node_modules/@serverless-stack/resources/src/Api.ts:466:26)
at /node_modules/@serverless-stack/resources/src/Api.ts:303:12
at Array.forEach (<anonymous>)
at Api.addRoutes (/node_modules/@serverless-stack/resources/src/Api.ts:302:25)
thdxr
04/26/2022, 12:52 PMthdxr
04/26/2022, 12:53 PMGabriel
04/26/2022, 12:53 PMthdxr
04/26/2022, 12:53 PM