Files
e-commerce/routes/auth.js
2022-09-27 17:23:39 -05:00

35 lines
938 B
JavaScript

const AuthService = require('../services/AuthService');
const AuthServiceInstance = new AuthService();
const router = require('express').Router();
module.exports = (app, passport) => {
app.use('/api/auth', router);
router.post('/register', async (req, res, next) => {
try {
const data = req.body;
const response = await AuthServiceInstance.register(data);
res.status(200).send(response);
} catch(e) {
next(e);
}
})
router.post('/login', passport.authenticate('local'), async (req, res, next) => {
try {
const data = req.body;
const response = await AuthServiceInstance.login(data);
res.status(200).send(response);
} catch(e) {
next(e);
}
})
router.get('/google', async (req, res, next) => {
try {
} catch(e) {
next(e);
}
})
}