I’ve created a new service folder with: sls create --template google-nodejs —path customers.
This created a folder called customers/ with 3 files in it: index.js, package.json, & serverless.yml.
Now I’m editing customers/serverless.yml and i’m just curious as to proper formatting for multiple functions (CRUD-like).
I found a couple different formats out in the wild, and have read the docs, but I’m having trouble. Can someone tell me what’s wrong with the following, I keep getting Deployment failed: RESOURCE ERROR - Name in request must be equal to the name of the function. Here are the relevant lines from customers/serverless.yml:
functions:
create:
handler: create
events:
- http:
path: customers
method: post
list:
handler: list
events:
- http:
path: customers
method: get
Error: The "handler" property for the function "hello" is invalid.
Handlers should be plain strings referencing only the exported function name without characters such as "." or "/" (so e.g. "http" instead of "index.http").
Do you want to nest your functions code in a subdirectory?
Google solves this by utilizing the "main" config in the projects package.json file. Please check the docs for more info.
Regardless, I have since tried about every permutation of that snippet imaginable. And the only way I can get it to run is with the default that is created from the google-nodejs template and a function named http. I would LOVE for you guys to create an example working repo for google that has multiple services/folders as one might use to break out CRUD functionality by “model”.
It’s really unclear error message. But the issue is that function and handler names should not be the same. So, in your example valid config could look like this:
functions:
createFunction:
handler: create
events:
- http:
path: customers
method: post
listFunction:
handler: list
events:
- http:
path: customers
method: get