2020-05-01 15:32:46 +00:00
|
|
|
let express = require('express');
|
|
|
|
let router = express.Router();
|
|
|
|
|
|
|
|
let Account = require('../models/accountModel');
|
|
|
|
|
|
|
|
// Add a user
|
|
|
|
router.post('/', async (req, res) => {
|
2020-05-01 16:24:59 +00:00
|
|
|
const userData = { ...req.body };
|
2020-05-01 15:32:46 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const user = await Account.addUser(userData);
|
|
|
|
res.status(201).json(user);
|
2020-05-01 16:24:59 +00:00
|
|
|
} catch (error) {
|
|
|
|
res.status(500).json({ message: 'Failed to add new user', error });
|
2020-05-01 15:32:46 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|