You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So for typescript aws lambdas Middy really seems to be the go to for set up. Relatively simple to set up, good documentation, and good reviews. https://middy.js.org/docs/
A small snippet of the code for it would be export const handler = middy() .use(jsonBodyParser()) // parses the request body when it's a JSON and converts it to an object .use(validator({ eventSchema: transpileSchema(schema) })) // validates the input .use(httpErrorHandler()) // handles common http errors and returns proper responses .handler(lambdaHandler)
Each use is called by middy and executes that function so be it our authentication piece or something else. Then it gets to the end for the handler. One thing I've noticed in our code is that we do Auth in some random parts of the functions sometimes so updating our existing work to use a middleware approach might take time and I would suggest a slower role out. Overall I think this is a good option.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So for typescript aws lambdas Middy really seems to be the go to for set up. Relatively simple to set up, good documentation, and good reviews. https://middy.js.org/docs/
A small snippet of the code for it would be
export const handler = middy() .use(jsonBodyParser()) // parses the request body when it's a JSON and converts it to an object .use(validator({ eventSchema: transpileSchema(schema) })) // validates the input .use(httpErrorHandler()) // handles common http errors and returns proper responses .handler(lambdaHandler)
Each use is called by middy and executes that function so be it our authentication piece or something else. Then it gets to the end for the handler. One thing I've noticed in our code is that we do Auth in some random parts of the functions sometimes so updating our existing work to use a middleware approach might take time and I would suggest a slower role out. Overall I think this is a good option.
On AWS they also promote using Middy so I dont think its a bad route. https://aws.amazon.com/blogs/compute/simplifying-serverless-best-practices-with-aws-lambda-powertools-for-typescript/
Beta Was this translation helpful? Give feedback.
All reactions