I have two resources, games and players, both have crud functions. Are these supposed to be in the same serverless service? I would like to separate them, but how do I then
In your example you would want to keep them in the same serverless framework. I would create two files player.js
and game.js
in src/controllers
to seperate out the logic.
You can setup serverless with the following YAML file
functions:
player_info:
handler: src/controllers/player.info
events:
- http:
path: player # path in the url
method: get
player_create:
handler: src/controllers/player.create
events:
- http:
path: player # path in the url
method: post
player_delete:
handler: src/controllers/player.delete
events:
- http:
path: player # path in the url
method: delete
game_info:
handler: src/controllers/game.info
events:
- http:
path: player # path in the url
method: get
game_create:
handler: src/controllers/game.create
events:
- http:
path: player # path in the url
method: post
game_delete:
handler: src/controllers/game.delete
events:
- http:
path: player # path in the url
method: delete