From db0a3bd796a8a9fae39bbc3d6c056a4ce6240b51 Mon Sep 17 00:00:00 2001 From: Brent Lewis Date: Mon, 13 Apr 2020 22:07:15 -0500 Subject: [PATCH] fix: make handler functions async --- index.js | 5 +++-- package.json | 2 +- readme.md | 9 +++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 59fe294..d4ced62 100755 --- a/index.js +++ b/index.js @@ -88,9 +88,10 @@ const logHandlers = ({ methods, route }) => { methods.forEach((method) => { const name = getName({ method, route, params }); - console.log(`module.exports.${name} = () => { + console.log(`module.exports.${name} = async () => { return { - statusCode: ${method === 'POST' ? 201 : 200} + statusCode: ${method === 'POST' ? 201 : 200},${method === 'GET' ? ` + body: JSON.stringify({}),` : ''} }; };`); console.log(); diff --git a/package.json b/package.json index 9f78ce3..06a640d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "generate-serverless-endpoints", - "version": "1.0.2", + "version": "1.0.3", "description": "Stub serverless API endpoints via command-line questionnaire", "bin": { "generate-serverless-endpoints": "index.js", diff --git a/readme.md b/readme.md index 472ac3b..d645a40 100644 --- a/readme.md +++ b/readme.md @@ -51,15 +51,16 @@ functions: Copy and paste these into your handler.js file: -module.exports.getUsersNotifications = () => { +module.exports.getUsersNotifications = async () => { return { - statusCode: 200 + statusCode: 200, + body: JSON.stringify({}), }; }; -module.exports.postUsersNotifications = () => { +module.exports.postUsersNotifications = async () => { return { - statusCode: 201 + statusCode: 201, }; }; ``` \ No newline at end of file