Sam Hulick
05/18/2022, 6:57 PMsst.Api
? so I don’t have to do:
'GET /folders': 'lambda/rest/functions/get-folders.main',
'GET /global-search': 'lambda/rest/functions/global-search.main',
'GET /tags': 'lambda/rest/functions/get-tags.main',
'GET /trash': 'lambda/rest/functions/get-deleted-items.main',
way back in the early days of SST, I wrote a messy helper function to handle this for me. but now I need to get rid of that as it’s.. well, a mess, and there’s probably a better way now 🙂Ross Coundon
05/18/2022, 6:58 PMSam Hulick
05/18/2022, 7:00 PMRoss Coundon
05/18/2022, 7:01 PMOmi Chowdhury
05/18/2022, 7:05 PMRoss Coundon
05/18/2022, 7:05 PMOmi Chowdhury
05/18/2022, 7:06 PMRoss Coundon
05/18/2022, 7:07 PMSam Hulick
05/18/2022, 7:08 PM'([\w-]+)\.main'
-> ``${restFuncBasePath}/$1.main``Kevin Grimm
05/19/2022, 2:15 AMdefaultFunctionProps
object of the Api construct like this
const myApi = new sst.Api(this, "myApi", {
defaultFunctionProps: {
srcPath: "lambda/rest/functions/",
},
routes: {
"GET /folders": "get-folders.main",
"GET /global-search": "global-search.main",
"GET /tags": "get-tags.main",
"GET /trash": "get-deleted-items.main",
},
});
Frank
basePath
field to the Function is we messed up the naming for srcPath
. srcPath
really meant “path to your package.json”, but ppl mis-use it as “base path”.Frank
srcPath
to ie. packageJsonPath
and then add basePath
.Frank
Frank
Kevin Grimm
05/19/2022, 3:07 AMpackage.json
is referenced under FunctionProps
. I saw examples of relative paths scattered in the Function docs and sort of ran with it 😅Kevin Grimm
05/19/2022, 3:08 AMbasePath
If the srcPath is set, then the path to the handler is relative to it. So if the srcPath is set to src. Then lambda.main as the handler would mean that the file is in src/lambda.js (or the other extensions).
Frank