I’m trying to figure out what the best practice is for simple CRUD API built using lambda functions. In the Netlify Dev generator it recommends 1 function that handles all aspects of CRUD by checking the http method (GET,POST,PUT,DELETE) and mapping that to the appropriate place.
I’m trying to understand if it might be better for separate each into it’s own function instead. The main reason is I’d like to also use middy middleware and more specifically the validator package. There’s no way for me to validate all 4 actions with a single validator middleware with the way it’s currently written.
The only real benefit I can think of for grouping it into one file is it’s better organized in the sense that it lives in one place instead of having todo-create, todo-read, todo-update, and todo-delete folders. It would be nice if netlify supported nested folder structure so I could have something like todos/create todos/update, etc.
I guess I could also whip up my own validator middleware that allows you to define schema based on the http method.