Skip to content

Instantly share code, notes, and snippets.

@richardgrantserverless
Created May 25, 2022 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardgrantserverless/0f143dce0cf05d4d1fae9d659723acc1 to your computer and use it in GitHub Desktop.
Save richardgrantserverless/0f143dce0cf05d4d1fae9d659723acc1 to your computer and use it in GitHub Desktop.
exports.handler = (event, context, cb) => {
const projects = new Projects(event);
switch (event.method) {
case 'POST':
Promise.resolve()
.then(() => projects.postCheckInput())
.then(() => projects.checkMaxUse())
.then(() => projects.post())
.then((data) => cb(null, data))
.catch((error) => errorHandle(error, cb));
break;
case 'GET':
Promise.resolve()
.then(() => projects.get())
.then((data) => cb(null, data))
.catch((error) => errorHandle(error, cb));
break;
case 'DELETE':
Promise.resolve()
.then(() => projects.checkOwnSite())
.then(() => projects.delete())
.then((data) => cb(null, data))
.catch((error) => errorHandle(error, cb));
break;
case 'PUT':
Promise.resolve()
.then(() => projects.checkOwnSite())
.then(() => projects.updateProjectName())
.then((data) => cb(null, data))
.catch((error) => errorHandle(error, cb));
break;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment