Skip to content

Commit

Permalink
add npm start script
Browse files Browse the repository at this point in the history
  • Loading branch information
El-khamisi committed Aug 28, 2022
1 parent 0976339 commit c6cf604
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 39 deletions.
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const port = PORT|| 8080;
//Create Application
const app = express();

const {superAdmin} = require('./src/config/seeder');
superAdmin();

const endpoints = require('./src/index.routes');
endpoints(app);
Expand Down
28 changes: 0 additions & 28 deletions [email protected]

This file was deleted.

18 changes: 12 additions & 6 deletions src/index.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const role = require('./services/role/role.routes');
const profile = require('./services/user/profile.routes');
const plans = require('./services/plans/plans.routes');

const { superAdmin } = require('./config/seeder');

const { initPlans } = require('./services/plans/plans.model');

module.exports = async (app) => {
Expand All @@ -32,6 +34,7 @@ module.exports = async (app) => {
.connect(DBURI)
.then((conn) => {
console.log('connected to local database successfully');
superAdmin();
return conn.connection.getClient();
})
.catch(() => {
Expand All @@ -42,6 +45,7 @@ module.exports = async (app) => {
.connect(DBURI_remote)
.then((conn) => {
console.log('connected to database successfully');
superAdmin();
return conn.connection.getClient();
})
.catch(() => {
Expand All @@ -51,12 +55,14 @@ module.exports = async (app) => {
initPlans();

// Middlewares
app.use(
cors({
origin: ['http://localhost:3000', 'https://textgenuss.net'],
credentials: true,
})
);
app.use((req, res, next) => {
const origin = req.headers.origin;
res.set('Access-Control-Allow-Origin', origin);
res.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.set('Access-Control-Allow-Headers', 'Content-Type, Authorization');
res.set('Access-Control-Allow-Credentials', true);
return next();
});

app.use(
session({
Expand Down
2 changes: 0 additions & 2 deletions src/services/login/login.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ exports.logUser = async (req, res) => {
return failedRes(res, 400, null, 'Email or Password is invalid');
} else {
const token = logged.generateToken(req, res);



req.session.user = logged;

Expand Down
2 changes: 1 addition & 1 deletion src/services/quiz/quiz.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ exports.submitQuiz = async (req, res) => {
});
response.total = parseFloat(((5 / doc.length) * response.total).toFixed(1));
const usr = await User.findById(user_id).exec();
if(!usr) return failedRes(res, 400, new Error(`Can NOT found User`));
if (!usr) return failedRes(res, 400, new Error(`Can NOT found User`));

let flag = false;
for (let i = 0; i < usr.quizzes.length; i++) {
Expand Down

0 comments on commit c6cf604

Please sign in to comment.