implemented a simple backend for mobile banking

This commit is contained in:
2025-06-02 13:24:10 +05:30
commit c350c591f6
26 changed files with 4060 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
const { validateUser } = require('../services/auth.service');
const { generateToken } = require('../util/jwt');
const { logger } = require('../util/logger');
async function login(req, res) {
const { customerNo, password } = req.body;
if (!customerNo || !password) {
return res
.status(400)
.json({ error: 'customerNo and password are required' });
}
try {
const user = await validateUser(customerNo, password);
if (!user) return res.status(401).json({ error: 'invalid credentials' });
const token = generateToken(user.customer_no);
res.json({ token });
} catch (err) {
logger.error(err, 'login failed');
res.status(500).json({ error: 'something went wrong' });
}
}
module.exports = { login };