すべてはここにおいてきた。
で、へろーわーるどしようと叩いてみたけどエラーで失敗するなぜ???
root@00231e897e28:/app/backend-prj# sls invoke local -f hello Running "serverless" from node_modules { "errorMessage": "Cannot read properties of undefined (reading 'name')", "errorType": "TypeError", "stackTrace": [ "TypeError: Cannot read properties of undefined (reading 'name')", " at hello (/app/backend-prj/src/functions/hello/handler.ts:9:34)", " at runRequest (/app/backend-prj/node_modules/@middy/core/index.js:86:32)", " at processTicksAndRejections (node:internal/process/task_queues:96:5)" ] } root@00231e897e28:/app/backend-prj# sls invoke local -f hello --data '{"name":"aipa"}' Running "serverless" from node_modules { "errorMessage": "Cannot read properties of undefined (reading 'name')", "errorType": "TypeError", "stackTrace": [ "TypeError: Cannot read properties of undefined (reading 'name')", " at hello (/app/backend-prj/src/functions/hello/handler.ts:9:34)", " at runRequest (/app/backend-prj/node_modules/@middy/core/index.js:86:32)", " at processTicksAndRejections (node:internal/process/task_queues:96:5)" ] } root@00231e897e28:/app/backend-prj# sls invoke local -f hello --path src/functions/hello/mock.json Running "serverless" from node_modules { "statusCode": 200, "body": "{\"message\":\"Hello Frederic, welcome to the exciting Serverless world!\",\"event\":{\"headers\":{\"Content-Type\":\"application/json\"},\"body\":{\"name\":\"Frederic\"},\"rawBody\":\"{\\\"name\\\": \\\"Frederic\\\"}\"}}" }
色々叩いたけど、requestの構造が間違ってて、mock.json使ったら行けましたとさ(便利)