Skip to content

Instantly share code, notes, and snippets.

@mcnkbr
Created March 30, 2021 21:59
Show Gist options
  • Save mcnkbr/83eef234ea21bfa815b65f8aef4d4308 to your computer and use it in GitHub Desktop.
Save mcnkbr/83eef234ea21bfa815b65f8aef4d4308 to your computer and use it in GitHub Desktop.
services/user.js
const data = require('./data.js');
module.exports = {
getUsers: function(context) {
try {
const users = data.getUsers();
context.res.status(200).json(users);
} catch (error) {
context.res.status(500).send(error);
}
},
addUser: function(context) {
try {
const response = data.addUser(context.req.body.user);
context.res.status(200).json(response);
} catch (error) {
context.res.status(500).send(error);
}
},
deleteUser: function(context) {
try {
const response = data.deleteUser(context.req.params.id);
context.res.status(200).json(response);
} catch (error) {
context.res.status(500).send(error);
}
},
editUser: function(context) {
try {
const response = data.editUser(context.req.body.user);
context.res.status(200).json(response);
} catch (error) {
context.res.status(500).send(error);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment