var express = require('express'); var router = express.Router(); let JSONError = require('../helpers').JSONError; let Users = require('../database').Repositories.Users; /* GET users listing. */ router.get('/', function(req, res, next) { res.send('respond with a resource'); }); /* GET users listing. */ router.post('/login', function(req, res, next) { const params = {...req.body}; const { username, password } = params; Users.login({username, password}). then((user) => res.send(user)). catch((e) => { console.log(e); res.status(400); res.send(JSONError("Bad Credentials")); }); }); module.exports = router;