Hi, for my current project I am using expressJS fo...
# help
k
Hi, for my current project I am using expressJS for my Lambda functions to be able to use the tsoa library to easily generate OpenAPI documentation. The idea is that for each domain or microservice, a route in the sst.Api construct is routed to a function that uses expressJS that further routes to a specific REST method. Also implemented with versioning. Something like:
Copy code
routes: {
"ANY /{version}/users/*" ... => expressJS Lambda function that routes to specific API method
"ANY /{version}/payments/*" ... => expressJS Lambda function that routes to specific API method
}
At the moment I can do:
Copy code
routes: {
"ANY /v1/users/{proxy+}", ... => expressJS Lambda function for GET/PUT/DELETE
"ANY /v1/users", ... => expressJS Lambda function for POST
"ANY /v1/payments/{proxy+}", ... => expressJS Lambda function for GET/PUT/DELETE
"ANY /v1/payments", ... => expressJS Lambda function for POST
"ANY /v2/payments/{proxy+}", ... => expressJS Lambda function for GET/PUT/DELETE
"ANY /v2/payments", ... => expressJS Lambda function for POST
}
Is this a valid approach to route to a Lambda function per service and to use versioning?
ö
Are you doing this for generating OpenAPI Documentation?
k
Yes
f
I haven’t tried a setup like this, but the routes look good to me. Do they work as expected?
k
Yes works good, only downside is that I have to define an extra route linked to the same lambda for the POST as the last slash is not ignored.
f
Oh I see.
ö
As far as I know you can export the OpenAPI documentation from API Gateway Console after you deployed it