updates to passport config, changes to routers

This commit is contained in:
Mikayla Dobson
2022-09-26 16:18:01 -05:00
parent f4a7ced887
commit 27348527a5
3 changed files with 54 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
const { LoginService } = require('../services/Auth');
const AuthService = require('../services/AuthService');
const AuthInstance = new AuthService();
module.exports = (app) => {
app.use(passport.initialize());
@@ -26,7 +28,7 @@ module.exports = (app) => {
},
async (email, password, done) => {
try {
const response = await LoginService(email, password);
const response = await AuthInstance.login({ email: email, password: password });
return done(null, response);
} catch(e) {
return done(e);

View File

@@ -0,0 +1,29 @@
const router = require('express').Router();
module.exports = (app, passport) => {
app.use('/api/auth', router);
router.post('/register', async (req, res, next) => {
try {
} catch(e) {
next(e);
}
})
router.post('/login', passport.authenticate('local'), async (req, res, next) => {
try {
} catch(e) {
next(e);
}
})
router.get('/google', async (req, res, next) => {
try {
} catch(e) {
next(e);
}
})
}

View File

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