restored basic functionality of user auth workflow

This commit is contained in:
Mikayla Dobson
2022-09-26 17:44:43 -05:00
parent a4c03b19d4
commit 45be163dcd
5 changed files with 47 additions and 16 deletions

View File

@@ -1,10 +1,10 @@
const authRouter = require('./auth');
const userRouter = require('./user');
const productRouter = require('./product');
const orderRouter = require('./order');
const orderRouter = require('./orders');
const cartRouter = require('./cart');
module.exports = async (app, passport) => {
module.exports = (app, passport) => {
authRouter(app, passport);
userRouter(app);
productRouter(app);

View File

@@ -1,11 +1,23 @@
const AuthService = require('../services/AuthService');
const AuthServiceInstance = new AuthService();
const router = require('express').Router();
module.exports = (app, passport) => {
app.use('/api/auth', router);
router.get('/', async (req, res, next) => {
try {
res.send('auth get response');
} catch(e) {
next(e);
}
})
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);
}
@@ -13,7 +25,9 @@ module.exports = (app, passport) => {
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);
}

View File

@@ -1,11 +1,11 @@
const router = require('express').Router();
module.exports = (app) => {
app.use('/api/order', router);
app.use('/api/orders', router);
router.get('/', async (req, res, next) => {
try {
} catch(e) {
next(e);
}