19 lines
412 B
JavaScript
19 lines
412 B
JavaScript
let express = require('express');
|
|
let router = express.Router();
|
|
|
|
let Account = require('../models/accountModel');
|
|
|
|
// Add a user
|
|
router.post('/', async (req, res) => {
|
|
const userData = { ...req.body };
|
|
|
|
try {
|
|
const user = await Account.addUser(userData);
|
|
res.status(201).json(user);
|
|
} catch (error) {
|
|
res.status(500).json({ message: 'Failed to add new user', error });
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|