Skip to content

Commit

Permalink
fix: make handler functions async
Browse files Browse the repository at this point in the history
  • Loading branch information
blewisio committed Apr 14, 2020
1 parent f83418e commit db0a3bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 5 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
};
```

0 comments on commit db0a3bd

Please sign in to comment.