Created
March 30, 2021 21:59
-
-
Save mcnkbr/83eef234ea21bfa815b65f8aef4d4308 to your computer and use it in GitHub Desktop.
services/user.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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