Skip to content

Instantly share code, notes, and snippets.

@kasramp

kasramp/index.js Secret

Created May 28, 2020 13:21
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 kasramp/49a9e7e59996a693ba616c9586c0fa19 to your computer and use it in GitHub Desktop.
Save kasramp/49a9e7e59996a693ba616c9586c0fa19 to your computer and use it in GitHub Desktop.
delete("/v1/users/:id", async (context) => {
if (context.params && context.params.id && !isNaN(parseInt(context.params.id))) {
let isDeleted = await storage.deleteUser(context.params.id);
if (isDeleted) {
context.response.status = 204;
} else {
context.response.status = 404;
context.response.body = { error: `User ${context.params.id} not found` };
}
} else {
context.response.status = 400;
context.response.body = { error: "Id must be number" };
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment