some api calls functioning as intended

This commit is contained in:
Mikayla Dobson
2022-09-26 16:24:35 -05:00
parent 27348527a5
commit a4c03b19d4
6 changed files with 9 additions and 7 deletions

View File

@@ -1,11 +1,13 @@
const passportLoader = require('./passport');
const expressLoader = require('./express');
const routes = require('../routes/API');
const swagger = require('./swagger');
module.exports = async (app) => {
const express = await expressLoader(app);
const passport = await passportLoader(express);
await routes(app, passport);
await swagger(app);
console.log('loaders called');
}

View File

@@ -4,7 +4,7 @@ const LocalStrategy = require('passport-local').Strategy;
const AuthService = require('../services/AuthService');
const AuthInstance = new AuthService();
module.exports = (app) => {
module.exports = async (app) => {
app.use(passport.initialize());
app.use(passport.session());

View File

@@ -4,8 +4,8 @@ const fs = require('fs');
const path = require('path');
// Loading via yml.safeLoad to avoid errors with special characters during processing
const swaggerDocument = yaml.safeLoad(fs.readFileSync(path.resolve(__dirname, '../swagger.yml'), 'utf8'));
const swaggerDocument = yaml.load(fs.readFileSync(path.resolve(__dirname, '../swagger.yml'), 'utf8'));
const app = require('../server');
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(swaggerDocument));
module.exports = async (app) => {
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(swaggerDocument));
}

View File

@@ -5,7 +5,7 @@ const PORT = process.env.PORT || 8088;
async function start() {
const app = express();
loaders(app);
await loaders(app);
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);

View File

@@ -19,7 +19,7 @@ module.exports = class CartService {
async addItem(userid, item) {
const cart = await CartInstance.findOneByUserId(userid);
const item = await CartProductInstance.create(item);
const newItem = await CartProductInstance.create(item);
}
async removeItem(userid, item) {

0
swagger.yml Normal file
View File