node-go/packages/play-node-go/server/controllers/auth.js

28 lines
451 B
JavaScript
Raw Normal View History

2020-01-14 20:06:25 +00:00
const knex = require('../data/db')
const signToken = require('../services/signToken');
2020-01-10 01:44:58 +00:00
const signUp = async (req, res, next) => {
const user = req.body;
try {
2020-01-14 20:06:25 +00:00
knex('user')
.insert(user)
.then(newUser => {
signToken(res, newUser[0]);
res.send('ok').status(200);
}
)
}
catch (err) {
res.status(500).json(err)
}
2020-01-10 01:44:58 +00:00
}
const login = (req, res, next) => {
}
module.exports = {
signUp,
login
}