diff --git a/index.js b/index.js index 812959b..6bfdfd5 100644 --- a/index.js +++ b/index.js @@ -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); diff --git a/root@164.92.136.164 b/root@164.92.136.164 deleted file mode 100644 index d18cbe3..0000000 --- a/root@164.92.136.164 +++ /dev/null @@ -1,28 +0,0 @@ -PORT=8080 -DBURI_remote=mongodb+srv://admin:admin@cluster0.uzfzv.mongodb.net/textgenuss_test?retryWrites=true&w=majority -DBURI=mongodb://localhost:27017/textgenuss_test -TOKENWORD=CATSLOVEFISH - -#cloudinary -cloudinary_name=dxicsmcph -cloudinary_api_key=589679456873894 -cloudinary_api_secret=roUSRtRa0X3aYdqG-rnjP8J4BAg - -#paymob -PAYMOB_APIKEY=ZXlKaGJHY2lPaUpJVXpVeE1pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SmpiR0Z6Y3lJNklrMWxjbU5vWVc1MElpd2ljSEp2Wm1sc1pWOXdheUk2TVRjeU16RTJMQ0p1WVcxbElqb2lhVzVwZEdsaGJDSjkuVGlMaHRMdXFsUThxaktSVGxxOS1tUjdrVGVubE83dUJMbnJ6Wlh2SWtzX08yWFZGQlZubm5YTG9Ia1FpbjZsYWZXUjhzZnRGV2xJVE9NMnk2aERqeXc= -PAYMOB_integration_id=2022816 -PAYMOB_HMAC=F6B35BFCB030E464605B36816DB50FBF - -exchange_api=C1llzKxg52ShBGa6RLTKvNnz2D39eUyN - -#emailAPI -sendinblue_user=5amisiyala@gmail.com -sendinblue_key=Wb2gPIvGVzw7pME9 -to_email=5amisiyala@gmail.com -smtp_host=smtp-relay.sendinblue.com -smtp_port=587 -server_domain=https://textgenuss.herokuapp.com - - -#environment -NODE_ENV=dev \ No newline at end of file diff --git a/src/index.routes.js b/src/index.routes.js index 455bd4f..e25bb4d 100644 --- a/src/index.routes.js +++ b/src/index.routes.js @@ -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) => { @@ -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(() => { @@ -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(() => { @@ -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({ diff --git a/src/services/login/login.controller.js b/src/services/login/login.controller.js index 30fc5ef..aba7768 100644 --- a/src/services/login/login.controller.js +++ b/src/services/login/login.controller.js @@ -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; diff --git a/src/services/quiz/quiz.controllers.js b/src/services/quiz/quiz.controllers.js index 1ed0ba0..b4fba4b 100644 --- a/src/services/quiz/quiz.controllers.js +++ b/src/services/quiz/quiz.controllers.js @@ -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++) {