From 225da89c69449b2cf37502e03f04d7cc79652e07 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Aug 2019 19:57:51 +0530 Subject: [PATCH 1/2] Fixes #9 contest admin part --- backend/Models/contestadmin/checkAdmin.js | 37 ++ .../Models/contestadmin/createNewContest.js | 81 ++++ .../Models/contestadmin/createNewQuestion.js | 33 ++ backend/Models/contestadmin/deleteAdmin.js | 25 + backend/Models/contestadmin/deleteContest.js | 24 + backend/Models/contestadmin/deleteQuestion.js | 25 + backend/Models/contestadmin/editAdmin.js | 26 + backend/Models/contestadmin/editContest.js | 32 ++ backend/Models/contestadmin/editQuestion.js | 34 ++ backend/Models/contestadmin/getAllContests.js | 28 ++ .../Models/contestadmin/getAllQuestions.js | 17 + .../Models/contestadmin/getSingleContest.js | 21 + .../Models/contestadmin/getSingleQuestion.js | 18 + backend/Models/contestadmin/makeAdmin.js | 26 + backend/Routes/Controllers/auth/index.js | 1 + .../Controllers/contests/admin/index.js | 457 ++++++++++++++++++ backend/Routes/Controllers/contests/index.js | 7 + backend/Routes/Controllers/index.js | 3 + .../contestadmin/createNewContestSchema.js | 42 ++ .../contestadmin/createNewQuestionSchema.js | 48 ++ .../Schema/contestadmin/deleteAdminSchema.js | 24 + .../contestadmin/deleteContestSchema.js | 21 + .../contestadmin/deleteQuestionSchema.js | 11 + .../Schema/contestadmin/editAdminSchema.js | 27 ++ .../Schema/contestadmin/editContestSchema.js | 45 ++ .../Schema/contestadmin/editQuestionSchema.js | 51 ++ .../contestadmin/getAllQuestionsSchema.js | 20 + .../contestadmin/getSingleContestSchema.js | 21 + .../contestadmin/getSingleQuestionSchema.js | 25 + 29 files changed, 1230 insertions(+) create mode 100644 backend/Models/contestadmin/checkAdmin.js create mode 100644 backend/Models/contestadmin/createNewContest.js create mode 100644 backend/Models/contestadmin/createNewQuestion.js create mode 100644 backend/Models/contestadmin/deleteAdmin.js create mode 100644 backend/Models/contestadmin/deleteContest.js create mode 100644 backend/Models/contestadmin/deleteQuestion.js create mode 100644 backend/Models/contestadmin/editAdmin.js create mode 100644 backend/Models/contestadmin/editContest.js create mode 100644 backend/Models/contestadmin/editQuestion.js create mode 100644 backend/Models/contestadmin/getAllContests.js create mode 100644 backend/Models/contestadmin/getAllQuestions.js create mode 100644 backend/Models/contestadmin/getSingleContest.js create mode 100644 backend/Models/contestadmin/getSingleQuestion.js create mode 100644 backend/Models/contestadmin/makeAdmin.js create mode 100644 backend/Routes/Controllers/contests/admin/index.js create mode 100644 backend/Routes/Controllers/contests/index.js create mode 100644 backend/Schema/contestadmin/createNewContestSchema.js create mode 100644 backend/Schema/contestadmin/createNewQuestionSchema.js create mode 100644 backend/Schema/contestadmin/deleteAdminSchema.js create mode 100644 backend/Schema/contestadmin/deleteContestSchema.js create mode 100644 backend/Schema/contestadmin/deleteQuestionSchema.js create mode 100644 backend/Schema/contestadmin/editAdminSchema.js create mode 100644 backend/Schema/contestadmin/editContestSchema.js create mode 100644 backend/Schema/contestadmin/editQuestionSchema.js create mode 100644 backend/Schema/contestadmin/getAllQuestionsSchema.js create mode 100644 backend/Schema/contestadmin/getSingleContestSchema.js create mode 100644 backend/Schema/contestadmin/getSingleQuestionSchema.js diff --git a/backend/Models/contestadmin/checkAdmin.js b/backend/Models/contestadmin/checkAdmin.js new file mode 100644 index 0000000..5167069 --- /dev/null +++ b/backend/Models/contestadmin/checkAdmin.js @@ -0,0 +1,37 @@ +const {pool} = require('../db'); + +/** + * + * @param {String} username + * @return {Promise} + */ +/*function checkadmin(username) { + return new Promise((resolve, reject) => { + pool.query( + `SELECT isadmin FROM users WHERE username=?`, + [username], + (error, results) => { + if (results[0].isadmin==0) { + return reject('Not an admin'); + } + return response(results); + } + ); + }); +} +*/ + +function checkadmin(username){ + pool.query( + `SELECT isadmin FROM users WHERE username=?`, + [username], + (error, results) => { + if(error) + return false; + if (results[0].isadmin==0) { + return false; + } + return true; + }) + } +module.exports = checkadmin; \ No newline at end of file diff --git a/backend/Models/contestadmin/createNewContest.js b/backend/Models/contestadmin/createNewContest.js new file mode 100644 index 0000000..0c749da --- /dev/null +++ b/backend/Models/contestadmin/createNewContest.js @@ -0,0 +1,81 @@ +const {pool} = require('../db') + +function createNewContest({ + username, + title, + about, + rules, + prize, + start_time:startTime, + end_time:endTime, + group_id:groupId, + confidential +}){ + return new Promise((resolve,reject)=>{ + pool.getConnection(function(err,connection){ + if(err) + return reject(error); + connection.beginTransaction(function(err){ + if(err) + return reject(err); + connection.query( + 'SELECT is_admin FROM users WHERE username=?', + [username], + (error,results)=>{ + if(error){ + return connection.rollback(function(){ + return reject(error); + connection.release(); + }) + } + if(results[0].is_admin==0){ + return reject("You are not allowed to create a contest"); + } + connection.query( + 'INSERT INTO contests (username,title,about,rules,prize,start_time,end_time,group_id,confidential) VALUES (?,?,?,?,?,?,?,?,?)', + [username,title,about,rules,prize,startTime,endTime,groupId,confidential], + (error,results)=>{ + if(error){ + return connection.rollback(function(){ + return reject(error); + connection.release(); + }); + } + var id=results.id; + connection.query( + 'INSERT INTO admin_of_contest (admin_name,contest_id,is_admin) VALUES (?,?,?)', + [username,id,1], + (error,result)=>{ + if(error){ + return connection.rollback(function(){ + return reject(error); + connection.release(); + }); + } + connection.commit(function(err){ + if(err){ + return connection.rollback(function(){ + return reject(error); + connection.release(); + }); + } + + connection.release(); + if(err){ + return connection.rollback(function(){ + return reject(error); + connection.release(); + } + } + return resolve("Succesfully added a new contest"); + }) + + }) + }) + }) + }) + }) +} + + +module.exports=createNewContest; \ No newline at end of file diff --git a/backend/Models/contestadmin/createNewQuestion.js b/backend/Models/contestadmin/createNewQuestion.js new file mode 100644 index 0000000..2846394 --- /dev/null +++ b/backend/Models/contestadmin/createNewQuestion.js @@ -0,0 +1,33 @@ +const {pool} = require('../db'); + +function createNewQuestion({ + username, + question_name:questionName, + contest_id:contestId, + type, + problemstatement, + solution, + max_score:maxScore, + negative, + partial, + difficulty, + answer +}){ + return new Promise((resolve,reject)=>{ + pool.query( + 'INSERT INTO questions (username,question_name,contest_id,type,problem_statement,solution,maxscore,negative,partial,difficulty,answer) VALUES (?,?,?,?,?,?,?,?,?,?,?) WHERE (SELECT is_admin from admin_of_contest WHERE admin_name = ? AND contest_id = ?)', + [username,questionName,contestId,type,problemstatement,solution,maxScore,negative,partial,difficulty,answer,username,contestId], + (error,results)=>{ + if(error){ + return reject(error); + } + if(results.affectedRows==0){ + return reject('You are not an admin'); + } + return resolve("Successfully deleted"); + + }) + }) +} + +module.exports=createNewQuestion; \ No newline at end of file diff --git a/backend/Models/contestadmin/deleteAdmin.js b/backend/Models/contestadmin/deleteAdmin.js new file mode 100644 index 0000000..4440383 --- /dev/null +++ b/backend/Models/contestadmin/deleteAdmin.js @@ -0,0 +1,25 @@ +const {pool} = require('../db'); + +function deleteAdmin({ + username, + contest_id:contestId, + adminname +}){ + return new Promise((resolve,reject)=>{ + pool.query( + 'UPDATE admin_of_contest SET admin_of_contest.delete=1 WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND admin_name = ? AND contest_id = ? ', + [username,contestId,adminname,contestId], + (error,results)=>{ + if(error){ + return reject(error); + } + if(results.affectedRows==0){ + return reject('You can not delete an admin'); + } + return resolve("Successfully deleted"); + + }) + }) +} + +module.exports=deleteAdmin; \ No newline at end of file diff --git a/backend/Models/contestadmin/deleteContest.js b/backend/Models/contestadmin/deleteContest.js new file mode 100644 index 0000000..034472e --- /dev/null +++ b/backend/Models/contestadmin/deleteContest.js @@ -0,0 +1,24 @@ +const {pool} = require('../db'); + +function deleteContest({ + username, + contest_id:contestId +}){ + return new Promise((resolve,reject)=>{ + pool.query( + 'UPDATE contests,admin_of_contest,questions SET contests.delete=1 AND admin_of_contest.delete=1 AND questions.delete=1 WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) ', + [username,contestId], + (error,results)=>{ + if(error){ + return reject(error); + } + if(results.affectedRows==0){ + return reject('You are not an admin'); + } + return resolve("Successfully deleted"); + + }) + }) +} + +module.exports=deleteContest; \ No newline at end of file diff --git a/backend/Models/contestadmin/deleteQuestion.js b/backend/Models/contestadmin/deleteQuestion.js new file mode 100644 index 0000000..6a8f31c --- /dev/null +++ b/backend/Models/contestadmin/deleteQuestion.js @@ -0,0 +1,25 @@ +const {pool} = require('../db'); + +function deleteQuestion({ + username, + contest_id: contestId, + question_id: questionId +}){ + return new Promise((resolve,reject)=>{ + podol.query( + 'UPDATE questions SET questions.delete=1 WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND id = ? ', + [username,contestId,questionId], + (error,results)=>{ + if(error){ + return reject(error); + } + if(results.affectedRows==0){ + return reject('You are not an admin'); + } + return resolve("Successfully deleted"); + + }) + }) +} + +module.exports=deleteQuestion; \ No newline at end of file diff --git a/backend/Models/contestadmin/editAdmin.js b/backend/Models/contestadmin/editAdmin.js new file mode 100644 index 0000000..8fa70d4 --- /dev/null +++ b/backend/Models/contestadmin/editAdmin.js @@ -0,0 +1,26 @@ +const {pool} = require('../db'); + +function editAdmin({ + username, + contest_id:contestId, + adminname, + newvalue +}){ + return new Promise((resolve,reject)=>{ + pool.query( + 'UPDATE admin_of_contest SET admin_of_contest.is_admin=? WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND admin_name = ? AND contest_id = ? ', + [newvalue,username,contestId,adminname,contestId], + (error,results)=>{ + if(error){ + return reject(error); + } + if(results.affectedRows==0){ + return reject('You cannot edit an admin'); + } + return resolve("Successfully deleted"); + + }) + }) +} + +module.exports=editAdmin; \ No newline at end of file diff --git a/backend/Models/contestadmin/editContest.js b/backend/Models/contestadmin/editContest.js new file mode 100644 index 0000000..77782ad --- /dev/null +++ b/backend/Models/contestadmin/editContest.js @@ -0,0 +1,32 @@ +const {pool} = require('../db') + +function editContest({ + username, + contest_id:contestId, + title, + about, + rules, + prize, + start_time, + end_time, + group_id:groupId, + confidential +}){ + return new Promise((resolve,reject)=>{ + pool.query( + 'UPDATE contests SET title=?,about=?,rules=?,prize=?,start_time=?,end_time=?,group_id=?,confidential=? WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND id = ?', + [title,about,rules,prize,start_time,end_time,groupId,confidential,username,contestId,contestId], + (error,results)=>{ + if(error){ + return reject(error); + } + if(results.affectedRows==0){ + return reject('You are not an admin'); + } + return resolve("Successfully edited"); + + }) + }) +} + +module.exports=editContest; \ No newline at end of file diff --git a/backend/Models/contestadmin/editQuestion.js b/backend/Models/contestadmin/editQuestion.js new file mode 100644 index 0000000..7588f9e --- /dev/null +++ b/backend/Models/contestadmin/editQuestion.js @@ -0,0 +1,34 @@ +const {pool} = require('../db'); + +function editQuestion({ + username, + contest_id:contestId, + question_id:questionId, + question_name:questionName, + type, + problemstatement, + solution, + maxscore, + negative, + partial, + difficulty, + answer +}){ + return new Promise((resolve,reject)=>{ + pool.query( + 'UPDATE questions SET type = ?,question_name=?,problem_statement = ?,solution = ?,max_score = ?,negative = ?,partial = ?,difficulty = ?,answer=? WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name = ? AND contest_id = ?) AND id = ?', + [type,questionName,problemstatement,solution,maxscore,negative,partial,difficulty,answer,username,contestId,questionId], + (error,results)=>{ + if(error){ + return reject(error); + } + if(results.affectedRows==0){ + return reject('You are not an admin'); + } + return resolve("Successfully deleted"); + + }) + }) +} + +module.exports=editQuestion; \ No newline at end of file diff --git a/backend/Models/contestadmin/getAllContests.js b/backend/Models/contestadmin/getAllContests.js new file mode 100644 index 0000000..5887a88 --- /dev/null +++ b/backend/Models/contestadmin/getAllContests.js @@ -0,0 +1,28 @@ +const {pool} = require('../db'); + +function getAllContests(username) { + return new Promise((resolve, reject) => { + pool.query( + `SELECT contest_id FROM admin_of_contest WHERE admin_name=?`, + [username], + (error, results) => { + if (error) { + return reject(error); + } + if (!results.length) { + return reject("No contests"); + } + let contestIdArr = results.map(result => result.contest_id); + pool.query(`SELECT * FROM contests WHERE id IN (?)`, [contestIdArr], + (error,resultss)=>{ + if(error){ + return reject(error); + } + return resolve(resultss); + }) + } + ) + }); +} + +module.exports=getAllContests; \ No newline at end of file diff --git a/backend/Models/contestadmin/getAllQuestions.js b/backend/Models/contestadmin/getAllQuestions.js new file mode 100644 index 0000000..5b539ce --- /dev/null +++ b/backend/Models/contestadmin/getAllQuestions.js @@ -0,0 +1,17 @@ +const {pool} = require('../db'); +function getaAllQuestions({contest_id:contestId}) { + return new Promise((resolve, reject) => { + pool.query( + `SELECT * FROM questions WHERE contest_id=?`, + [contestId], + (error, results) => { + if (error) { + return reject(error); + } + return resolve(results); + } + ); + }); +} + +module.exports=getAllQuestions; \ No newline at end of file diff --git a/backend/Models/contestadmin/getSingleContest.js b/backend/Models/contestadmin/getSingleContest.js new file mode 100644 index 0000000..9c731d6 --- /dev/null +++ b/backend/Models/contestadmin/getSingleContest.js @@ -0,0 +1,21 @@ +const {pool} = require('../db'); + +function getSingleContest({ + username, + contest_id:contestId; +}) { + return new Promise((resolve, reject) => { + pool.query( + `SELECT * FROM contests WHERE id=?`, + [contestId], + (error, results) => { + if (error) { + return reject(error); + } + return resolve(results); + } + ); + }); +} + +module.exports=getSingleContest; \ No newline at end of file diff --git a/backend/Models/contestadmin/getSingleQuestion.js b/backend/Models/contestadmin/getSingleQuestion.js new file mode 100644 index 0000000..8585182 --- /dev/null +++ b/backend/Models/contestadmin/getSingleQuestion.js @@ -0,0 +1,18 @@ +const {pool} = require('../db'); + +function getSingleQuestion({question_id:questionId}) { + return new Promise((resolve, reject) => { + pool.query( + `SELECT * FROM questions WHERE id=?`, + [questionId], + (error, results) => { + if (error) { + return reject(error); + } + return resolve(results); + } + ); + }); +} + +module.exports=getSingleQuestion; \ No newline at end of file diff --git a/backend/Models/contestadmin/makeAdmin.js b/backend/Models/contestadmin/makeAdmin.js new file mode 100644 index 0000000..63ca94a --- /dev/null +++ b/backend/Models/contestadmin/makeAdmin.js @@ -0,0 +1,26 @@ +const {pool} = require('../db'); + +function makeAdmin({ + username, + contest_id:contestId, + adminname, + newvalue +}){ + return new Promise((resolve,reject)=>{ + pool.query( + 'INSERT INTO admin_of_contest (admin_name,contest_id,is_admin) VALUES (?,?,?) WHERE (SELECT is_admin from admin_of_contest WHERE admin_name = ? AND contest_id = ?)', + [adminname,contestId,newvalue,username,contestId], + (error,results)=>{ + if(error){ + return reject(error); + } + if(results.affectedRows==0){ + return reject('You are not an admin'); + } + return resolve("Successfully deleted"); + + }) + }) +} + +module.exports=makeAdmin; \ No newline at end of file diff --git a/backend/Routes/Controllers/auth/index.js b/backend/Routes/Controllers/auth/index.js index 2e34719..b2f0d9f 100644 --- a/backend/Routes/Controllers/auth/index.js +++ b/backend/Routes/Controllers/auth/index.js @@ -187,6 +187,7 @@ router.post( .then((results) => { return res.status(200).json({ success: true, + error: null, results, }); diff --git a/backend/Routes/Controllers/contests/admin/index.js b/backend/Routes/Controllers/contests/admin/index.js new file mode 100644 index 0000000..62aa23f --- /dev/null +++ b/backend/Routes/Controllers/contests/admin/index.js @@ -0,0 +1,457 @@ +const contestadmin = require('../../../../Models/contestadmin'); +const middleware = require('../../auth/middleware'); +const ajv = require('../../../../Schema'); +const express = require('express'); +const router = express.Router(); + +const { + deleteQuestionSchema, + deleteContestSchema, + deleteAdminSchema, + editQuestionSchema, + editAdminSchema, + editContestSchema, + getAllQuestionsSchema, + getSingleQuestionSchema, + getSingleContestSchema, + createNewQuestionSchema, + createNewContestSchema +} = require('../../../../Schema/contestadmin'); + +router.post('/delete_question', middleware.verifyUser.verifyAccessToken, (req,res)=>{ + let validate = ajv.compile(deleteQuestionSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + constestadmin + .deleteQuestion(req.body) + .then((results)=>{ + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + if (error === 'You are not an admin') { + return res.status(401).json({ + success: false, + error, + results: null, + }); + } + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); + + +}) + +router.post('/edit_question',middleware.verifyUser.verifyAccessToken,(req,res)=>{ + let validate = ajv.compile(editQuestionSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + constestadmin + .editQuestion(req.body) + .then((results)=>{ + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + if (error === 'You are not an admin') { + return res.status(401).json({ + success: false, + error, + results: null, + }); + } + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); +}) + +router.get('/questions/:question_id',(req,res)=>{ + req.body.question_id=req.params.question_id; + let validate = ajv.compile(getSingleQuestionSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + contestadmin + .getSingleQuestion(req.body) + .then((results) => { + return res.status(200).json({ + success: true, + error: null, + results + }); + }) + .catch((error) => { + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); + +}) + +router.post('/create_question',middleware.verifyUser.verifyAccessToken,(req,res)=>{ + let validate = ajv.compile(createNewQuestionSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + contestadmin + .createNewQuestion(req.body) + .then((results)=>{ + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); +}) + +router.get('/:contestId/questions',middleware.verifyUser.verifyAccessToken,(req,res)=>{ + req.body.contest_id=req.params.contestId; + let validate = ajv.compile(getAllQuestionsSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + contestadmin + .getAllQuestions(req.body) + .then((results) => { + return res.status(200).json({ + success: true, + error: null, + results + }); + }) + .catch((error) => { + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); +}) +router.post('/make_admin',middleware.verifyUser.verifyAccessToken,(req,res)=>{ + let validate = ajv.compile(editAdminSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + contestadmin + .makeAdmin(req.body) + .then((results)=>{ + + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + if (error === 'You are not an admin') { + return res.status(401).json({ + success: false, + error, + results: null, + }); + } + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); +}) + +router.post('/edit_admin',middleware.verifyUser.verifyAccessToken,(req,res)=>{ + let validate = ajv.compile(editAdminSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + constestadmin + .editAdmin(req.body) + .then((results)=>{ + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + if (error === 'You cannot edit an admin') { + return res.status(401).json({ + success: false, + error, + results: null, + }); + } + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); + +}); + +router.post('/admin/delete',middleware.verifyUser.verifyAccessToken,(req,res)=>{ + let validate = ajv.compile(deleteAdminSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + constestadmin + .deleteAdmin(req.body) + .then((results)=>{ + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + if (error === 'You cannot delete an admin') { + return res.status(401).json({ + success: false, + error, + results: null, + }); + } + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); + +}); + + +router.get('/:contestId',middleware.verifyUser.verifyAccessToken,(req,res)=>{ + req.body.contest_id=req.params.contestId; + let validate = ajv.compile(getSingleContestSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + constestadmin + .getSingleContest(req.body) + .then((results)=>{ + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); + +}); + +router.post('/create',middleware.verifyUser.verifyAccessToken,(req,res)=>{ + let validate = ajv.compile(createNewContestSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + contestadmin + .createNewContest(req.body) + .then((results)=>{ + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + if (error === 'You are not allowed to create a contest') { + return res.status(401).json({ + success: false, + error, + results: null, + }); + } + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); + +}); + +router.post('/update', middleware.verifyUser.verifyAccessToken, (req, res) => { + let validate = ajv.compile(editContestSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + constestadmin + .editContest(req.body) + .then((results)=>{ + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + if (error === 'You are not an admin') { + return res.status(401).json({ + success: false, + error, + results: null, + }); + } + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); +}); + +router.post('/delete', middleware.verifyUser.verifyAccessToken, (req, res) => { + let validate = ajv.compile(deleteContestSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null, + }); + } + constestadmin + .deleteContest(req.body) + .then((results)=>{ + return res.status(200).json({ + success:true, + error:null, + results + }); + }) + .catch((error)=>{ + if (error === 'You are not an admin') { + return res.status(401).json({ + success: false, + error, + results: null, + }); + } + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); +}); + +router.get('/my_contests',middleware.verifyUser.verifyAccessToken,(req,res)=>{ + contestadmin + .getAllContests(req.body.username) + .then((results) => { + return res.status(200).json({ + success: true, + error: null, + results + }); + }) + .catch((error) => { + if (error === 'No contests') { + return res.status(401).json({ + success: false, + error, + results: null, + }); + } + return res.status(400).json({ + success: false, + error, + results: null, + }); + }); +}); + +module.exports=router; \ No newline at end of file diff --git a/backend/Routes/Controllers/contests/index.js b/backend/Routes/Controllers/contests/index.js new file mode 100644 index 0000000..c88f413 --- /dev/null +++ b/backend/Routes/Controllers/contests/index.js @@ -0,0 +1,7 @@ +const adminRouter = require('./admin'); +const express = require('express'); +const router = express.Router(); + +router.use('/admin', adminRouter); + +module.exports = router; diff --git a/backend/Routes/Controllers/index.js b/backend/Routes/Controllers/index.js index 6ed7a70..5b98f4d 100644 --- a/backend/Routes/Controllers/index.js +++ b/backend/Routes/Controllers/index.js @@ -1,7 +1,10 @@ const authRouter = require('./auth'); +const contestRouter = requrie('./contests'); const express = require('express'); const router = express.Router(); router.use('/auth', authRouter); +router.use('/contests',contestRouter); + module.exports = router; diff --git a/backend/Schema/contestadmin/createNewContestSchema.js b/backend/Schema/contestadmin/createNewContestSchema.js new file mode 100644 index 0000000..bba4e1c --- /dev/null +++ b/backend/Schema/contestadmin/createNewContestSchema.js @@ -0,0 +1,42 @@ +const createNewContestSchema = { + required:['username','title','about','rules','prize','start_time','end_time','group_id','confidential',] + properties: { + username: {type: 'string'}, + title:{type:'string'} + about: {type: 'string'}, + rules: {type:'string'}, + prize: {type: 'string'}, + start_time:{type: 'string'}, + end_time:{type: 'string'}, + group_id:{type: 'string'}, + confidential:{type: 'boolean'}, + }, + errorMessage: { + required: { + username: 'Username required', + title: 'Title required', + about: 'About required', + rules: 'Rules required', + prize: 'Prize required', + start_time: 'Start time required', + end_time: 'End time required', + group_id: 'Group Id required', + confidential: 'Confidetial Status required', + }, + properties: { + username: 'Invalid username', + title: 'Invalid Title', + about: 'Invalid About', + rules: 'Invalid Rules', + prize: 'Invalid Prize', + start_time: 'Invalid Start time', + end_time: 'Invalid End time', + group_id: 'Invalid Group Id', + confidential: 'Invalid Confidetial Status', + }, + _: 'Invalid data', + }, + +}; + +module.exports = createNewContestSchema; diff --git a/backend/Schema/contestadmin/createNewQuestionSchema.js b/backend/Schema/contestadmin/createNewQuestionSchema.js new file mode 100644 index 0000000..e880828 --- /dev/null +++ b/backend/Schema/contestadmin/createNewQuestionSchema.js @@ -0,0 +1,48 @@ +const createNewQuestionSchema = { + required: ['username','contest_id','type','question_name','problemstatement','solution','max_score','negative','partial','difficulty','answer'] + properties: { + username:{type:'string'}, + contest_id:{type:'number'}, + type:{type:'integer'}, + question_name:{type:'string'}, + problemstatement:{type:'string'}, + solution:{type:'string'}, + max_score:{type:'number'}, + negative:{type:'number'}, + partial:{type:'number'}, + difficulty:{type:'string'}, + answer:{type:'string'} + }, + errorMessage: { + required: { + username: 'Username required', + contest_id: 'Contest id required', + question_name:'Question name required', + type;'Type required', + problemstatement:'Problem statement required', + solution:'Answer required', + max_score:'Maxscore required', + negative:'Negstive scheming required' + partial:'Partial scheming required', + difficulty:'Difficulty level required' + answer:'Answer required' + }, + properties: { + username: 'Invalid username', + contest_id: 'Invalid contest id', + question_name: 'Invalid question name', + type: 'Invalid question type', + problemstatement: 'Invalid problem statement', + solution: 'Invalid solution', + max_score: 'Invalid maximum score', + negative: 'Invalid negative marking', + partial: 'Invalid partial marking', + difficulty: 'Invalid difficulty level', + answer: 'Invalid answer', + }, + _: 'Invalid data', + }, + +}; + +module.exports = createNewQuestionSchema; diff --git a/backend/Schema/contestadmin/deleteAdminSchema.js b/backend/Schema/contestadmin/deleteAdminSchema.js new file mode 100644 index 0000000..27c8ae3 --- /dev/null +++ b/backend/Schema/contestadmin/deleteAdminSchema.js @@ -0,0 +1,24 @@ +const deleteAdminSchema = { + required:['username','contest_id','adminname'] + properties: { + username: {type: 'string'}, + contest_id:{type:'number'}, + adminname:{type:'string'} + }, + errorMessage: { + required: { + username: 'Username required', + contest_id: 'Contest id required', + adminname: 'Name of admin to be deleted is required' + }, + properties: { + username: 'Invalid username', + contest_id: 'Invalid contest id', + adminname: 'Invalid name of admin' + }, + _: 'Invalid data', + } + +}; + +module.exports = deleteAdminSchema; diff --git a/backend/Schema/contestadmin/deleteContestSchema.js b/backend/Schema/contestadmin/deleteContestSchema.js new file mode 100644 index 0000000..78718d6 --- /dev/null +++ b/backend/Schema/contestadmin/deleteContestSchema.js @@ -0,0 +1,21 @@ +const deleteContestSchema = { + required:['username','contest_id'] + properties: { + username: {type: 'string'}, + contest_id:{type:'number'} + }, + errorMessage: { + required: { + username: 'Username required', + contest_id: 'Contest Id required', + }, + properties: { + username: 'Invalid username', + contest_id: 'Invalid contest id', + }, + _: 'Invalid data', + } + +}; + +module.exports = deleteContestSchema; diff --git a/backend/Schema/contestadmin/deleteQuestionSchema.js b/backend/Schema/contestadmin/deleteQuestionSchema.js new file mode 100644 index 0000000..5ed83bb --- /dev/null +++ b/backend/Schema/contestadmin/deleteQuestionSchema.js @@ -0,0 +1,11 @@ +const deleteQuestionSchema = { + required:['username','contest_id','question_id'] + properties: { + username: {type: 'string'}, + contest_id:{type:'string'}, + question_id:{type:'string'} + }, + +}; + +module.exports = deleteQuestionSchema; diff --git a/backend/Schema/contestadmin/editAdminSchema.js b/backend/Schema/contestadmin/editAdminSchema.js new file mode 100644 index 0000000..c8dd322 --- /dev/null +++ b/backend/Schema/contestadmin/editAdminSchema.js @@ -0,0 +1,27 @@ +const editAdminSchema = { + required:['username','contest_id','adminname','newvalue'] + properties: { + username: {type: 'string'}, + contest_id:{type:'number'}, + adminname:{type:'string'}, + newvalue:{type:'integer'} + }, + errorMessage: { + required: { + username:'Username required', + contest_id: 'Contest id required', + adminname: 'Admin name required', + newvalue: 'New value required' + }, + properties: { + username: 'Invalid username', + contest_id: 'Invalid contest id', + adminname: 'Invalid admin name', + newvalue: 'Invalid new value' + }, + _: 'Invalid data', + } + +}; + +module.exports = editAdminSchema; diff --git a/backend/Schema/contestadmin/editContestSchema.js b/backend/Schema/contestadmin/editContestSchema.js new file mode 100644 index 0000000..7ef2f5d --- /dev/null +++ b/backend/Schema/contestadmin/editContestSchema.js @@ -0,0 +1,45 @@ +const editContestSchema = { + required:['username','contest_id','title','about','rules','prize','start_time','end_time','group_id','confidential'] + properties: { + username: {type: 'string'}, + contest_id:{type:'string'} + title:{type:'string'} + about: {type: 'string'}, + rules: {type:'number'}, + prize: {type: 'string'}, + start_time:{type: 'string'}, + end_time:{type: 'string'}, + group_id:{type: 'number'}, + confidential:{type: 'boolean'} + }, + errorMessage: { + required: { + username: 'Username required', + contest_id: 'Contest id required', + title:"Title required", + about: 'About required', + rules: 'Rules required', + prize: 'Prize required', + start_time: 'Start time required', + end_time: 'End time required', + group_id: 'Group Id required', + confidential: 'Confidetial Status required', + }, + properties: { + username: 'Invalid username', + contest_id:'Invalid contest id' + title: 'Invalid Title', + about: 'Invalid About', + rules: 'Invalid Rules', + prize: 'Invalid Prize', + start_time: 'Invalid Start time', + end_time: 'Invalid End time', + group_id: 'Invalid Group Id', + confidential: 'Invalid Confidetial Status', + }, + _: 'Invalid data', + } + +}; + +module.exports = editContestSchema; diff --git a/backend/Schema/contestadmin/editQuestionSchema.js b/backend/Schema/contestadmin/editQuestionSchema.js new file mode 100644 index 0000000..38905e0 --- /dev/null +++ b/backend/Schema/contestadmin/editQuestionSchema.js @@ -0,0 +1,51 @@ + const editQuestionSchema = { + required: ['username','contest_id','question_id','type','question_name','problemstatement','solution','max_score','negative','partial','difficulty','answer'] + properties: { + username:{type:'string'}, + contest_id:{type:'number'}, + question_id:{type:'number'}, + question_name:{type:'string'}, + type:{type:'integer'}, + problemstatement:{type:'string'}, + solution:{type:'string'}, + max_score:{type:'number'}, + negative:{type:'number'}, + partial:{type:'number'}, + difficulty:{type:'string'}, + answer:{type:'string'} + }, + errorMessage: { + required: { + username: 'Username required', + contest_id: 'Contest id required', + question_id:'Question id required', + question_name:'Question name required', + type;'Type required', + problemstatement:'Problem statement required', + solution:'Answer required', + max_score:'Maxscore required', + negative:'Negative scheming required' + partial:'Partial scheming required', + difficulty:'Difficulty level required' + answer:'Answer required' + }, + properties: { + username: 'Invalid username', + contest_id: 'Invalid contest id', + question_id:'Invalid question id' + question_name: 'Invalid question name', + type: 'Invalid question type', + problemstatement: 'Invalid problem statement', + solution: 'Invalid solution', + max_score: 'Invalid maximum score', + negative: 'Invalid negative marking', + partial: 'Invalid partial marking', + difficulty: 'Invalid difficulty level', + answer: 'Invalid answer', + }, + _: 'Invalid data', + }, + +}; + +module.exports = editQuestionSchema; diff --git a/backend/Schema/contestadmin/getAllQuestionsSchema.js b/backend/Schema/contestadmin/getAllQuestionsSchema.js new file mode 100644 index 0000000..63b333e --- /dev/null +++ b/backend/Schema/contestadmin/getAllQuestionsSchema.js @@ -0,0 +1,20 @@ +const getAllQuestionsSchema = { + required:['username','contest_id'] + properties: { + username: {type:'string'}, + contest_id:{type:'number'}, + }, + errorMessage: { + required: { + username: 'Username required', + contest_id: 'Contest id required' + }, + properties: { + username: 'Invalid username', + contest_id: 'Invalid contest id' + }, + _: 'Invalid data', + } +}; + +module.exports = getAllQuestionsSchema; diff --git a/backend/Schema/contestadmin/getSingleContestSchema.js b/backend/Schema/contestadmin/getSingleContestSchema.js new file mode 100644 index 0000000..1c77835 --- /dev/null +++ b/backend/Schema/contestadmin/getSingleContestSchema.js @@ -0,0 +1,21 @@ +const getSingleContestSchema = { + required:['username','contest_id'] + properties: { + username: {type: 'string'}, + contest_id:{type:'number'} + }, + errorMessage: { + required: { + username: 'Username required', + contest_id:'Contest id required' + }, + properties: { + username: 'Invalid username', + contest_id: 'Invalid contest id', + }, + _: 'Invalid data', + } + +}; + +module.exports = getSingleContestSchema; diff --git a/backend/Schema/contestadmin/getSingleQuestionSchema.js b/backend/Schema/contestadmin/getSingleQuestionSchema.js new file mode 100644 index 0000000..8abda1d --- /dev/null +++ b/backend/Schema/contestadmin/getSingleQuestionSchema.js @@ -0,0 +1,25 @@ +const getSingleQuestionSchema = { + required:['username','contest_id','question_id'] + properties: { + username: {type:'string'}, + contest_id:{type:'number'}, + question_id:{type:'number'} + }, + errorMessage: { + required: { + username: 'Username required', + contest_id: 'Contest id required', + question_id: 'Question id required', + + }, + properties: { + username: 'Invalid username', + contest_id: 'Invalid contest id', + question_id: 'Invalid question id', + }, + _: 'Invalid data', + } + +}; + +module.exports = getSingleQuestionSchema; From 145731f1072fa4295b3307a918d0a922b593e614 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Aug 2019 00:08:59 +0530 Subject: [PATCH 2/2] fixed styling errors --- backend/Models/contestadmin/checkAdmin.js | 26 +- .../Models/contestadmin/createNewContest.js | 162 +-- .../Models/contestadmin/createNewQuestion.js | 72 +- backend/Models/contestadmin/deleteAdmin.js | 40 +- backend/Models/contestadmin/deleteContest.js | 39 +- backend/Models/contestadmin/deleteQuestion.js | 42 +- backend/Models/contestadmin/editAdmin.js | 41 +- backend/Models/contestadmin/editContest.js | 48 +- backend/Models/contestadmin/editQuestion.js | 73 +- backend/Models/contestadmin/getAllContests.js | 43 +- .../Models/contestadmin/getAllQuestions.js | 20 +- .../Models/contestadmin/getSingleContest.js | 23 +- .../Models/contestadmin/getSingleQuestion.js | 20 +- backend/Models/contestadmin/makeAdmin.js | 41 +- .../Controllers/contests/admin/index.js | 531 +++++----- backend/Schema/auth/forgotPassword.js | 12 +- backend/Schema/auth/index.js | 4 +- backend/Schema/auth/login.js | 12 +- backend/Schema/auth/resetPassword.js | 16 +- backend/Schema/auth/signup.js | 24 +- backend/Schema/auth/updatePassword.js | 12 +- backend/Schema/auth/updateUser.js | 22 +- backend/Schema/auth/verifyEmail.js | 12 +- backend/Schema/auth/verifyNewEmail.js | 16 +- .../contestadmin/createNewContestSchema.js | 41 +- .../contestadmin/createNewQuestionSchema.js | 61 +- .../Schema/contestadmin/deleteAdminSchema.js | 11 +- .../contestadmin/deleteContestSchema.js | 13 +- .../contestadmin/deleteQuestionSchema.js | 11 +- .../Schema/contestadmin/editAdminSchema.js | 15 +- .../Schema/contestadmin/editContestSchema.js | 44 +- .../Schema/contestadmin/editQuestionSchema.js | 70 +- .../contestadmin/getAllQuestionsSchema.js | 8 +- .../contestadmin/getSingleContestSchema.js | 17 +- .../contestadmin/getSingleQuestionSchema.js | 16 +- backend/Schema/index.js | 2 +- backend/package-lock.json | 977 +++++++++++++++++- backend/package.json | 11 +- 38 files changed, 1848 insertions(+), 800 deletions(-) diff --git a/backend/Models/contestadmin/checkAdmin.js b/backend/Models/contestadmin/checkAdmin.js index 5167069..2ab0e41 100644 --- a/backend/Models/contestadmin/checkAdmin.js +++ b/backend/Models/contestadmin/checkAdmin.js @@ -1,4 +1,4 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); /** * @@ -21,17 +21,17 @@ const {pool} = require('../db'); } */ -function checkadmin(username){ +function checkadmin(username) { pool.query( `SELECT isadmin FROM users WHERE username=?`, - [username], - (error, results) => { - if(error) - return false; - if (results[0].isadmin==0) { - return false; - } - return true; - }) - } -module.exports = checkadmin; \ No newline at end of file + [username], + (error, results) => { + if (error) return false; + if (results[0].isadmin == 0) { + return false; + } + return true; + } + ); +} +module.exports = checkadmin; diff --git a/backend/Models/contestadmin/createNewContest.js b/backend/Models/contestadmin/createNewContest.js index 0c749da..3c0cdcc 100644 --- a/backend/Models/contestadmin/createNewContest.js +++ b/backend/Models/contestadmin/createNewContest.js @@ -1,81 +1,91 @@ -const {pool} = require('../db') +const { pool } = require('../db'); function createNewContest({ - username, - title, - about, - rules, - prize, - start_time:startTime, - end_time:endTime, - group_id:groupId, - confidential -}){ - return new Promise((resolve,reject)=>{ - pool.getConnection(function(err,connection){ - if(err) - return reject(error); - connection.beginTransaction(function(err){ - if(err) - return reject(err); - connection.query( - 'SELECT is_admin FROM users WHERE username=?', - [username], - (error,results)=>{ - if(error){ - return connection.rollback(function(){ - return reject(error); - connection.release(); - }) - } - if(results[0].is_admin==0){ - return reject("You are not allowed to create a contest"); - } - connection.query( - 'INSERT INTO contests (username,title,about,rules,prize,start_time,end_time,group_id,confidential) VALUES (?,?,?,?,?,?,?,?,?)', - [username,title,about,rules,prize,startTime,endTime,groupId,confidential], - (error,results)=>{ - if(error){ - return connection.rollback(function(){ - return reject(error); - connection.release(); - }); - } - var id=results.id; - connection.query( - 'INSERT INTO admin_of_contest (admin_name,contest_id,is_admin) VALUES (?,?,?)', - [username,id,1], - (error,result)=>{ - if(error){ - return connection.rollback(function(){ - return reject(error); - connection.release(); - }); - } - connection.commit(function(err){ - if(err){ - return connection.rollback(function(){ - return reject(error); - connection.release(); - }); - } + username, + title, + about, + rules, + prize, + start_time: startTime, + end_time: endTime, + group_id: groupId, + confidential +}) { + return new Promise((resolve, reject) => { + pool.getConnection(function(err, connection) { + if (err) return reject(err); + connection.beginTransaction(function(err) { + if (err) return reject(err); + connection.query( + 'SELECT is_admin FROM users WHERE username=?', + [username], + (error, results) => { + if (error) { + return connection.rollback(function() { + connection.release(); + return reject(error); + }); + } + if (results[0].is_admin == 0) { + return reject('You are not allowed to create a contest'); + } + connection.query( + 'INSERT INTO contests (username,title,about,rules,prize,start_time,end_time,group_id,confidential) VALUES (?,?,?,?,?,?,?,?,?)', + [ + username, + title, + about, + rules, + prize, + startTime, + endTime, + groupId, + confidential + ], + (error, results) => { + if (error) { + return connection.rollback(function() { + connection.release(); + return reject(error); + }); + } + var id = results.id; + connection.query( + 'INSERT INTO admin_of_contest (admin_name,contest_id,is_admin) VALUES (?,?,?)', + [username, id, 1], + error => { + if (error) { + return connection.rollback(function() { + connection.release(); + return reject(error); + }); + } + connection.commit(function(err) { + if (err) { + return connection.rollback(function() { + connection.release(); + return reject(error); + }); + } - connection.release(); - if(err){ - return connection.rollback(function(){ - return reject(error); - connection.release(); - } - } - return resolve("Succesfully added a new contest"); - }) - - }) - }) - }) - }) - }) + connection.release(); + if (err) { + return connection.rollback(function() { + connection.release(); + return reject(error); + }); + } + return resolve('Succesfully added a new contest'); + }); + } + ); + } + ); + } + ); + }); + }); + }); } - -module.exports=createNewContest; \ No newline at end of file +module.exports = createNewContest; diff --git a/backend/Models/contestadmin/createNewQuestion.js b/backend/Models/contestadmin/createNewQuestion.js index 2846394..6fa1469 100644 --- a/backend/Models/contestadmin/createNewQuestion.js +++ b/backend/Models/contestadmin/createNewQuestion.js @@ -1,33 +1,47 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); function createNewQuestion({ - username, - question_name:questionName, - contest_id:contestId, - type, - problemstatement, - solution, - max_score:maxScore, - negative, - partial, - difficulty, - answer -}){ - return new Promise((resolve,reject)=>{ - pool.query( - 'INSERT INTO questions (username,question_name,contest_id,type,problem_statement,solution,maxscore,negative,partial,difficulty,answer) VALUES (?,?,?,?,?,?,?,?,?,?,?) WHERE (SELECT is_admin from admin_of_contest WHERE admin_name = ? AND contest_id = ?)', - [username,questionName,contestId,type,problemstatement,solution,maxScore,negative,partial,difficulty,answer,username,contestId], - (error,results)=>{ - if(error){ - return reject(error); - } - if(results.affectedRows==0){ - return reject('You are not an admin'); - } - return resolve("Successfully deleted"); - - }) - }) + username, + question_name: questionName, + contest_id: contestId, + type, + problemstatement, + solution, + max_score: maxScore, + negative, + partial, + difficulty, + answer +}) { + return new Promise((resolve, reject) => { + pool.query( + 'INSERT INTO questions (username,question_name,contest_id,type,problem_statement,solution,maxscore,negative,partial,difficulty,answer) VALUES (?,?,?,?,?,?,?,?,?,?,?) WHERE (SELECT is_admin from admin_of_contest WHERE admin_name = ? AND contest_id = ?)', + [ + username, + questionName, + contestId, + type, + problemstatement, + solution, + maxScore, + negative, + partial, + difficulty, + answer, + username, + contestId + ], + (error, results) => { + if (error) { + return reject(error); + } + if (results.affectedRows == 0) { + return reject('You are not an admin'); + } + return resolve('Successfully deleted'); + } + ); + }); } -module.exports=createNewQuestion; \ No newline at end of file +module.exports = createNewQuestion; diff --git a/backend/Models/contestadmin/deleteAdmin.js b/backend/Models/contestadmin/deleteAdmin.js index 38c0c8e..e8f8db3 100644 --- a/backend/Models/contestadmin/deleteAdmin.js +++ b/backend/Models/contestadmin/deleteAdmin.js @@ -1,25 +1,21 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); -function deleteAdmin({ - username, - contest_id:contestId, - adminname -}){ - return new Promise((resolve,reject)=>{ - pool.query( - 'UPDATE admin_of_contest SET admin_of_contest.delete_status=1 WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND admin_name = ? AND contest_id = ? ', - [username,contestId,adminname,contestId], - (error,results)=>{ - if(error){ - return reject(error); - } - if(results.affectedRows==0){ - return reject('You can not delete an admin'); - } - return resolve("Successfully deleted"); - - }) - }) +function deleteAdmin({ username, contest_id: contestId, adminname }) { + return new Promise((resolve, reject) => { + pool.query( + 'UPDATE admin_of_contest SET admin_of_contest.delete_status=1 WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND admin_name = ? AND contest_id = ? ', + [username, contestId, adminname, contestId], + (error, results) => { + if (error) { + return reject(error); + } + if (results.affectedRows == 0) { + return reject('You can not delete an admin'); + } + return resolve('Successfully deleted'); + } + ); + }); } -module.exports=deleteAdmin; \ No newline at end of file +module.exports = deleteAdmin; diff --git a/backend/Models/contestadmin/deleteContest.js b/backend/Models/contestadmin/deleteContest.js index 81c46fd..529821d 100644 --- a/backend/Models/contestadmin/deleteContest.js +++ b/backend/Models/contestadmin/deleteContest.js @@ -1,24 +1,21 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); -function deleteContest({ - username, - contest_id:contestId -}){ - return new Promise((resolve,reject)=>{ - pool.query( - 'UPDATE contests,admin_of_contest,questions SET contests.delete_status=1 AND admin_of_contest.delete_status=1 AND questions.delete_status=1 WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) ', - [username,contestId], - (error,results)=>{ - if(error){ - return reject(error); - } - if(results.affectedRows==0){ - return reject('You are not an admin'); - } - return resolve("Successfully deleted"); - - }) - }) +function deleteContest({ username, contest_id: contestId }) { + return new Promise((resolve, reject) => { + pool.query( + 'UPDATE contests,admin_of_contest,questions SET contests.delete_status=1 AND admin_of_contest.delete_status=1 AND questions.delete_status=1 WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) ', + [username, contestId], + (error, results) => { + if (error) { + return reject(error); + } + if (results.affectedRows == 0) { + return reject('You are not an admin'); + } + return resolve('Successfully deleted'); + } + ); + }); } -module.exports=deleteContest; \ No newline at end of file +module.exports = deleteContest; diff --git a/backend/Models/contestadmin/deleteQuestion.js b/backend/Models/contestadmin/deleteQuestion.js index a52ec95..da4ce3a 100644 --- a/backend/Models/contestadmin/deleteQuestion.js +++ b/backend/Models/contestadmin/deleteQuestion.js @@ -1,25 +1,25 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); function deleteQuestion({ - username, - contest_id: contestId, - question_id: questionId -}){ - return new Promise((resolve,reject)=>{ - podol.query( - 'UPDATE questions SET questions.delete_status=1 WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND id = ? ', - [username,contestId,questionId], - (error,results)=>{ - if(error){ - return reject(error); - } - if(results.affectedRows==0){ - return reject('You are not an admin'); - } - return resolve("Successfully deleted"); - - }) - }) + username, + contest_id: contestId, + question_id: questionId +}) { + return new Promise((resolve, reject) => { + pool.query( + 'UPDATE questions SET questions.delete_status=1 WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND id = ? ', + [username, contestId, questionId], + (error, results) => { + if (error) { + return reject(error); + } + if (results.affectedRows == 0) { + return reject('You are not an admin'); + } + return resolve('Successfully deleted'); + } + ); + }); } -module.exports=deleteQuestion; \ No newline at end of file +module.exports = deleteQuestion; diff --git a/backend/Models/contestadmin/editAdmin.js b/backend/Models/contestadmin/editAdmin.js index 8fa70d4..4bdd003 100644 --- a/backend/Models/contestadmin/editAdmin.js +++ b/backend/Models/contestadmin/editAdmin.js @@ -1,26 +1,21 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); -function editAdmin({ - username, - contest_id:contestId, - adminname, - newvalue -}){ - return new Promise((resolve,reject)=>{ - pool.query( - 'UPDATE admin_of_contest SET admin_of_contest.is_admin=? WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND admin_name = ? AND contest_id = ? ', - [newvalue,username,contestId,adminname,contestId], - (error,results)=>{ - if(error){ - return reject(error); - } - if(results.affectedRows==0){ - return reject('You cannot edit an admin'); - } - return resolve("Successfully deleted"); - - }) - }) +function editAdmin({ username, contest_id: contestId, adminname, newvalue }) { + return new Promise((resolve, reject) => { + pool.query( + 'UPDATE admin_of_contest SET admin_of_contest.is_admin=? WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND admin_name = ? AND contest_id = ? ', + [newvalue, username, contestId, adminname, contestId], + (error, results) => { + if (error) { + return reject(error); + } + if (results.affectedRows == 0) { + return reject('You cannot edit an admin'); + } + return resolve('Successfully deleted'); + } + ); + }); } -module.exports=editAdmin; \ No newline at end of file +module.exports = editAdmin; diff --git a/backend/Models/contestadmin/editContest.js b/backend/Models/contestadmin/editContest.js index 77782ad..5fe9be9 100644 --- a/backend/Models/contestadmin/editContest.js +++ b/backend/Models/contestadmin/editContest.js @@ -1,32 +1,44 @@ -const {pool} = require('../db') +const { pool } = require('../db'); function editContest({ username, - contest_id:contestId, + contest_id: contestId, title, about, rules, prize, start_time, end_time, - group_id:groupId, + group_id: groupId, confidential -}){ - return new Promise((resolve,reject)=>{ +}) { + return new Promise((resolve, reject) => { pool.query( 'UPDATE contests SET title=?,about=?,rules=?,prize=?,start_time=?,end_time=?,group_id=?,confidential=? WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) AND id = ?', - [title,about,rules,prize,start_time,end_time,groupId,confidential,username,contestId,contestId], - (error,results)=>{ - if(error){ - return reject(error); - } - if(results.affectedRows==0){ - return reject('You are not an admin'); - } - return resolve("Successfully edited"); - - }) - }) + [ + title, + about, + rules, + prize, + start_time, + end_time, + groupId, + confidential, + username, + contestId, + contestId + ], + (error, results) => { + if (error) { + return reject(error); + } + if (results.affectedRows == 0) { + return reject('You are not an admin'); + } + return resolve('Successfully edited'); + } + ); + }); } -module.exports=editContest; \ No newline at end of file +module.exports = editContest; diff --git a/backend/Models/contestadmin/editQuestion.js b/backend/Models/contestadmin/editQuestion.js index 7588f9e..f38dca7 100644 --- a/backend/Models/contestadmin/editQuestion.js +++ b/backend/Models/contestadmin/editQuestion.js @@ -1,34 +1,47 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); function editQuestion({ - username, - contest_id:contestId, - question_id:questionId, - question_name:questionName, - type, - problemstatement, - solution, - maxscore, - negative, - partial, - difficulty, - answer -}){ - return new Promise((resolve,reject)=>{ - pool.query( - 'UPDATE questions SET type = ?,question_name=?,problem_statement = ?,solution = ?,max_score = ?,negative = ?,partial = ?,difficulty = ?,answer=? WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name = ? AND contest_id = ?) AND id = ?', - [type,questionName,problemstatement,solution,maxscore,negative,partial,difficulty,answer,username,contestId,questionId], - (error,results)=>{ - if(error){ - return reject(error); - } - if(results.affectedRows==0){ - return reject('You are not an admin'); - } - return resolve("Successfully deleted"); - - }) - }) + username, + contest_id: contestId, + question_id: questionId, + question_name: questionName, + type, + problemstatement, + solution, + maxscore, + negative, + partial, + difficulty, + answer +}) { + return new Promise((resolve, reject) => { + pool.query( + 'UPDATE questions SET type = ?,question_name=?,problem_statement = ?,solution = ?,max_score = ?,negative = ?,partial = ?,difficulty = ?,answer=? WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name = ? AND contest_id = ?) AND id = ?', + [ + type, + questionName, + problemstatement, + solution, + maxscore, + negative, + partial, + difficulty, + answer, + username, + contestId, + questionId + ], + (error, results) => { + if (error) { + return reject(error); + } + if (results.affectedRows == 0) { + return reject('You are not an admin'); + } + return resolve('Successfully deleted'); + } + ); + }); } -module.exports=editQuestion; \ No newline at end of file +module.exports = editQuestion; diff --git a/backend/Models/contestadmin/getAllContests.js b/backend/Models/contestadmin/getAllContests.js index 5887a88..910743a 100644 --- a/backend/Models/contestadmin/getAllContests.js +++ b/backend/Models/contestadmin/getAllContests.js @@ -1,28 +1,31 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); function getAllContests(username) { return new Promise((resolve, reject) => { pool.query( - `SELECT contest_id FROM admin_of_contest WHERE admin_name=?`, - [username], - (error, results) => { - if (error) { - return reject(error); - } - if (!results.length) { - return reject("No contests"); - } - let contestIdArr = results.map(result => result.contest_id); - pool.query(`SELECT * FROM contests WHERE id IN (?)`, [contestIdArr], - (error,resultss)=>{ - if(error){ - return reject(error); - } - return resolve(resultss); - }) + `SELECT contest_id FROM admin_of_contest WHERE admin_name=?`, + [username], + (error, results) => { + if (error) { + return reject(error); } - ) + if (!results.length) { + return reject('No contests'); + } + let contestIdArr = results.map(result => result.contest_id); + pool.query( + `SELECT * FROM contests WHERE id IN (?)`, + [contestIdArr], + (error, resultss) => { + if (error) { + return reject(error); + } + return resolve(resultss); + } + ); + } + ); }); } -module.exports=getAllContests; \ No newline at end of file +module.exports = getAllContests; diff --git a/backend/Models/contestadmin/getAllQuestions.js b/backend/Models/contestadmin/getAllQuestions.js index 5b539ce..80d7cb0 100644 --- a/backend/Models/contestadmin/getAllQuestions.js +++ b/backend/Models/contestadmin/getAllQuestions.js @@ -1,17 +1,17 @@ -const {pool} = require('../db'); -function getaAllQuestions({contest_id:contestId}) { +const { pool } = require('../db'); +function getAllQuestions({ contest_id: contestId }) { return new Promise((resolve, reject) => { pool.query( - `SELECT * FROM questions WHERE contest_id=?`, - [contestId], - (error, results) => { - if (error) { - return reject(error); - } - return resolve(results); + `SELECT * FROM questions WHERE contest_id=?`, + [contestId], + (error, results) => { + if (error) { + return reject(error); } + return resolve(results); + } ); }); } -module.exports=getAllQuestions; \ No newline at end of file +module.exports = getAllQuestions; diff --git a/backend/Models/contestadmin/getSingleContest.js b/backend/Models/contestadmin/getSingleContest.js index 9c731d6..b3b4eaa 100644 --- a/backend/Models/contestadmin/getSingleContest.js +++ b/backend/Models/contestadmin/getSingleContest.js @@ -1,21 +1,18 @@ -const {pool} = require('../db'); +const { pool } = require("../db"); -function getSingleContest({ - username, - contest_id:contestId; -}) { +function getSingleContest({ username, contest_id: contestId }) { return new Promise((resolve, reject) => { pool.query( - `SELECT * FROM contests WHERE id=?`, - [contestId], - (error, results) => { - if (error) { - return reject(error); - } - return resolve(results); + `SELECT * FROM contests WHERE id=? WHERE (SELECT is_admin FROM admin_of_contest WHERE admin_name =? AND contest_id = ?) is not null`, + [contestId], + (error, results) => { + if (error) { + return reject(error); } + return resolve(results); + } ); }); } -module.exports=getSingleContest; \ No newline at end of file +module.exports = getSingleContest; diff --git a/backend/Models/contestadmin/getSingleQuestion.js b/backend/Models/contestadmin/getSingleQuestion.js index 8585182..61bf164 100644 --- a/backend/Models/contestadmin/getSingleQuestion.js +++ b/backend/Models/contestadmin/getSingleQuestion.js @@ -1,18 +1,18 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); -function getSingleQuestion({question_id:questionId}) { +function getSingleQuestion({ question_id: questionId }) { return new Promise((resolve, reject) => { pool.query( - `SELECT * FROM questions WHERE id=?`, - [questionId], - (error, results) => { - if (error) { - return reject(error); - } - return resolve(results); + `SELECT * FROM questions WHERE id=?`, + [questionId], + (error, results) => { + if (error) { + return reject(error); } + return resolve(results); + } ); }); } -module.exports=getSingleQuestion; \ No newline at end of file +module.exports = getSingleQuestion; diff --git a/backend/Models/contestadmin/makeAdmin.js b/backend/Models/contestadmin/makeAdmin.js index 63ca94a..f2abb97 100644 --- a/backend/Models/contestadmin/makeAdmin.js +++ b/backend/Models/contestadmin/makeAdmin.js @@ -1,26 +1,21 @@ -const {pool} = require('../db'); +const { pool } = require('../db'); -function makeAdmin({ - username, - contest_id:contestId, - adminname, - newvalue -}){ - return new Promise((resolve,reject)=>{ - pool.query( - 'INSERT INTO admin_of_contest (admin_name,contest_id,is_admin) VALUES (?,?,?) WHERE (SELECT is_admin from admin_of_contest WHERE admin_name = ? AND contest_id = ?)', - [adminname,contestId,newvalue,username,contestId], - (error,results)=>{ - if(error){ - return reject(error); - } - if(results.affectedRows==0){ - return reject('You are not an admin'); - } - return resolve("Successfully deleted"); - - }) - }) +function makeAdmin({ username, contest_id: contestId, adminname, newvalue }) { + return new Promise((resolve, reject) => { + pool.query( + 'INSERT INTO admin_of_contest (admin_name,contest_id,is_admin) VALUES (?,?,?) WHERE (SELECT is_admin from admin_of_contest WHERE admin_name = ? AND contest_id = ?)', + [adminname, contestId, newvalue, username, contestId], + (error, results) => { + if (error) { + return reject(error); + } + if (results.affectedRows == 0) { + return reject('You are not an admin'); + } + return resolve('Successfully deleted'); + } + ); + }); } -module.exports=makeAdmin; \ No newline at end of file +module.exports = makeAdmin; diff --git a/backend/Routes/Controllers/contests/admin/index.js b/backend/Routes/Controllers/contests/admin/index.js index 62aa23f..9c449f0 100644 --- a/backend/Routes/Controllers/contests/admin/index.js +++ b/backend/Routes/Controllers/contests/admin/index.js @@ -18,440 +18,467 @@ const { createNewContestSchema } = require('../../../../Schema/contestadmin'); -router.post('/delete_question', middleware.verifyUser.verifyAccessToken, (req,res)=>{ - let validate = ajv.compile(deleteQuestionSchema); +router.post( + '/delete_question', + middleware.verifyUser.verifyAccessToken, + (req, res) => { + let validate = ajv.compile(deleteQuestionSchema); let valid = validate(req.body); - if (!valid) { - return res.status(400).json({ - success: false, - error: validate.errors, - results: null, - }); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null + }); } - constestadmin - .deleteQuestion(req.body) - .then((results)=>{ + contestadmin + .deleteQuestion(req.body) + .then(results => { return res.status(200).json({ - success:true, - error:null, + success: true, + error: null, results }); }) - .catch((error)=>{ + .catch(error => { if (error === 'You are not an admin') { return res.status(401).json({ success: false, error, - results: null, + results: null }); } - return res.status(400).json({ + return res.status(400).json({ success: false, error, - results: null, + results: null }); }); + } +); - -}) - -router.post('/edit_question',middleware.verifyUser.verifyAccessToken,(req,res)=>{ - let validate = ajv.compile(editQuestionSchema); +router.post( + '/edit_question', + middleware.verifyUser.verifyAccessToken, + (req, res) => { + let validate = ajv.compile(editQuestionSchema); let valid = validate(req.body); - if (!valid) { - return res.status(400).json({ - success: false, - error: validate.errors, - results: null, - }); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null + }); } - constestadmin - .editQuestion(req.body) - .then((results)=>{ + contestadmin + .editQuestion(req.body) + .then(results => { return res.status(200).json({ - success:true, - error:null, + success: true, + error: null, results }); }) - .catch((error)=>{ + .catch(error => { if (error === 'You are not an admin') { return res.status(401).json({ success: false, error, - results: null, + results: null }); } - return res.status(400).json({ + return res.status(400).json({ success: false, error, - results: null, + results: null }); }); -}) + } +); -router.get('/questions/:question_id',(req,res)=>{ - req.body.question_id=req.params.question_id; - let validate = ajv.compile(getSingleQuestionSchema); - let valid = validate(req.body); - if (!valid) { - return res.status(400).json({ +router.get('/questions/:question_id', (req, res) => { + req.body.question_id = req.params.question_id; + let validate = ajv.compile(getSingleQuestionSchema); + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ success: false, error: validate.errors, - results: null, - }); - } - contestadmin - .getSingleQuestion(req.body) - .then((results) => { - return res.status(200).json({ - success: true, - error: null, - results - }); - }) - .catch((error) => { - return res.status(400).json({ - success: false, - error, - results: null, - }); + results: null + }); + } + contestadmin + .getSingleQuestion(req.body) + .then(results => { + return res.status(200).json({ + success: true, + error: null, + results }); + }) + .catch(error => { + return res.status(400).json({ + success: false, + error, + results: null + }); + }); +}); -}) - -router.post('/create_question',middleware.verifyUser.verifyAccessToken,(req,res)=>{ - let validate = ajv.compile(createNewQuestionSchema); +router.post( + '/create_question', + middleware.verifyUser.verifyAccessToken, + (req, res) => { + let validate = ajv.compile(createNewQuestionSchema); let valid = validate(req.body); - if (!valid) { - return res.status(400).json({ - success: false, - error: validate.errors, - results: null, - }); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null + }); } contestadmin .createNewQuestion(req.body) - .then((results)=>{ + .then(results => { return res.status(200).json({ - success:true, - error:null, + success: true, + error: null, results }); }) - .catch((error)=>{ - return res.status(400).json({ + .catch(error => { + return res.status(400).json({ success: false, error, - results: null, + results: null }); }); -}) + } +); -router.get('/:contestId/questions',middleware.verifyUser.verifyAccessToken,(req,res)=>{ - req.body.contest_id=req.params.contestId; - let validate = ajv.compile(getAllQuestionsSchema); - let valid = validate(req.body); - if (!valid) { +router.get( + '/:contestId/questions', + middleware.verifyUser.verifyAccessToken, + (req, res) => { + req.body.contest_id = req.params.contestId; + let validate = ajv.compile(getAllQuestionsSchema); + let valid = validate(req.body); + if (!valid) { return res.status(400).json({ - success: false, - error: validate.errors, - results: null, - }); + success: false, + error: validate.errors, + results: null + }); } contestadmin .getAllQuestions(req.body) - .then((results) => { + .then(results => { return res.status(200).json({ success: true, error: null, results }); }) - .catch((error) => { + .catch(error => { return res.status(400).json({ success: false, error, - results: null, + results: null }); }); -}) -router.post('/make_admin',middleware.verifyUser.verifyAccessToken,(req,res)=>{ - let validate = ajv.compile(editAdminSchema); + } +); +router.post( + '/make_admin', + middleware.verifyUser.verifyAccessToken, + (req, res) => { + let validate = ajv.compile(editAdminSchema); let valid = validate(req.body); - if (!valid) { - return res.status(400).json({ - success: false, - error: validate.errors, - results: null, - }); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null + }); } contestadmin .makeAdmin(req.body) - .then((results)=>{ - + .then(results => { return res.status(200).json({ - success:true, - error:null, + success: true, + error: null, results }); }) - .catch((error)=>{ + .catch(error => { if (error === 'You are not an admin') { return res.status(401).json({ success: false, error, - results: null, + results: null }); } - return res.status(400).json({ + return res.status(400).json({ success: false, error, - results: null, + results: null }); }); -}) + } +); -router.post('/edit_admin',middleware.verifyUser.verifyAccessToken,(req,res)=>{ - let validate = ajv.compile(editAdminSchema); +router.post( + '/edit_admin', + middleware.verifyUser.verifyAccessToken, + (req, res) => { + let validate = ajv.compile(editAdminSchema); let valid = validate(req.body); - if (!valid) { - return res.status(400).json({ - success: false, - error: validate.errors, - results: null, - }); + if (!valid) { + return res.status(400).json({ + success: false, + error: validate.errors, + results: null + }); } - constestadmin - .editAdmin(req.body) - .then((results)=>{ + contestadmin + .editAdmin(req.body) + .then(results => { return res.status(200).json({ - success:true, - error:null, + success: true, + error: null, results }); }) - .catch((error)=>{ + .catch(error => { if (error === 'You cannot edit an admin') { return res.status(401).json({ success: false, error, - results: null, + results: null }); } - return res.status(400).json({ + return res.status(400).json({ success: false, error, - results: null, + results: null }); }); + } +); -}); - -router.post('/admin/delete',middleware.verifyUser.verifyAccessToken,(req,res)=>{ - let validate = ajv.compile(deleteAdminSchema); +router.post( + '/admin/delete', + middleware.verifyUser.verifyAccessToken, + (req, res) => { + let validate = ajv.compile(deleteAdminSchema); let valid = validate(req.body); if (!valid) { - return res.status(400).json({ - success: false, - error: validate.errors, - results: null, - }); + return res.status(400).json({ + success: false, + error: validate.errors, + results: null + }); } - constestadmin - .deleteAdmin(req.body) - .then((results)=>{ + contestadmin + .deleteAdmin(req.body) + .then(results => { return res.status(200).json({ - success:true, - error:null, + success: true, + error: null, results }); }) - .catch((error)=>{ + .catch(error => { if (error === 'You cannot delete an admin') { return res.status(401).json({ success: false, error, - results: null, + results: null }); } - return res.status(400).json({ + return res.status(400).json({ success: false, error, - results: null, + results: null }); }); + } +); -}); - - -router.get('/:contestId',middleware.verifyUser.verifyAccessToken,(req,res)=>{ - req.body.contest_id=req.params.contestId; - let validate = ajv.compile(getSingleContestSchema); +router.get( + '/:contestId', + middleware.verifyUser.verifyAccessToken, + (req, res) => { + req.body.contest_id = req.params.contestId; + let validate = ajv.compile(getSingleContestSchema); let valid = validate(req.body); if (!valid) { - return res.status(400).json({ - success: false, - error: validate.errors, - results: null, - }); + return res.status(400).json({ + success: false, + error: validate.errors, + results: null + }); } - constestadmin - .getSingleContest(req.body) - .then((results)=>{ + contestadmin + .getSingleContest(req.body) + .then(results => { return res.status(200).json({ - success:true, - error:null, + success: true, + error: null, results }); }) - .catch((error)=>{ - return res.status(400).json({ + .catch(error => { + return res.status(400).json({ success: false, error, - results: null, + results: null }); }); + } +); -}); - -router.post('/create',middleware.verifyUser.verifyAccessToken,(req,res)=>{ +router.post('/create', middleware.verifyUser.verifyAccessToken, (req, res) => { let validate = ajv.compile(createNewContestSchema); - let valid = validate(req.body); - if (!valid) { - return res.status(400).json({ + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ success: false, error: validate.errors, - results: null, - }); - } - contestadmin - .createNewContest(req.body) - .then((results)=>{ - return res.status(200).json({ - success:true, - error:null, - results - }); - }) - .catch((error)=>{ - if (error === 'You are not allowed to create a contest') { - return res.status(401).json({ - success: false, - error, - results: null, - }); - } - return res.status(400).json({ + results: null + }); + } + contestadmin + .createNewContest(req.body) + .then(results => { + return res.status(200).json({ + success: true, + error: null, + results + }); + }) + .catch(error => { + if (error === 'You are not allowed to create a contest') { + return res.status(401).json({ success: false, error, - results: null, + results: null }); + } + return res.status(400).json({ + success: false, + error, + results: null }); - + }); }); router.post('/update', middleware.verifyUser.verifyAccessToken, (req, res) => { let validate = ajv.compile(editContestSchema); - let valid = validate(req.body); - if (!valid) { - return res.status(400).json({ + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ success: false, error: validate.errors, - results: null, - }); - } - if (!valid) { - return res.status(400).json({ + results: null + }); + } + if (!valid) { + return res.status(400).json({ success: false, error: validate.errors, - results: null, - }); - } - constestadmin + results: null + }); + } + contestadmin .editContest(req.body) - .then((results)=>{ - return res.status(200).json({ - success:true, - error:null, - results - }); - }) - .catch((error)=>{ - if (error === 'You are not an admin') { - return res.status(401).json({ - success: false, - error, - results: null, - }); - } - return res.status(400).json({ + .then(results => { + return res.status(200).json({ + success: true, + error: null, + results + }); + }) + .catch(error => { + if (error === 'You are not an admin') { + return res.status(401).json({ success: false, error, - results: null, + results: null }); + } + return res.status(400).json({ + success: false, + error, + results: null }); + }); }); router.post('/delete', middleware.verifyUser.verifyAccessToken, (req, res) => { let validate = ajv.compile(deleteContestSchema); - let valid = validate(req.body); - if (!valid) { - return res.status(400).json({ + let valid = validate(req.body); + if (!valid) { + return res.status(400).json({ success: false, error: validate.errors, - results: null, - }); - } - constestadmin + results: null + }); + } + contestadmin .deleteContest(req.body) - .then((results)=>{ - return res.status(200).json({ - success:true, - error:null, - results - }); - }) - .catch((error)=>{ - if (error === 'You are not an admin') { - return res.status(401).json({ - success: false, - error, - results: null, - }); - } - return res.status(400).json({ + .then(results => { + return res.status(200).json({ + success: true, + error: null, + results + }); + }) + .catch(error => { + if (error === 'You are not an admin') { + return res.status(401).json({ success: false, error, - results: null, + results: null }); + } + return res.status(400).json({ + success: false, + error, + results: null }); + }); }); -router.get('/my_contests',middleware.verifyUser.verifyAccessToken,(req,res)=>{ +router.get( + '/my_contests', + middleware.verifyUser.verifyAccessToken, + (req, res) => { contestadmin .getAllContests(req.body.username) - .then((results) => { + .then(results => { return res.status(200).json({ success: true, error: null, results }); }) - .catch((error) => { + .catch(error => { if (error === 'No contests') { return res.status(401).json({ success: false, error, - results: null, + results: null }); } return res.status(400).json({ success: false, error, - results: null, + results: null }); }); -}); + } +); -module.exports=router; \ No newline at end of file +module.exports = router; diff --git a/backend/Schema/auth/forgotPassword.js b/backend/Schema/auth/forgotPassword.js index e16fd09..804ea40 100644 --- a/backend/Schema/auth/forgotPassword.js +++ b/backend/Schema/auth/forgotPassword.js @@ -4,18 +4,18 @@ const schema = { email: { type: 'string', pattern: - '^[a-z]+\\.[0-9]{2}[a-z]{2}[0-9]{4}@([a-z].\\.)?iitism\\.ac\\.in$', - }, + '^[a-z]+\\.[0-9]{2}[a-z]{2}[0-9]{4}@([a-z].\\.)?iitism\\.ac\\.in$' + } }, errorMessage: { required: { - email: 'Email required', + email: 'Email required' }, properties: { - email: 'Invalid email', + email: 'Invalid email' }, - _: 'Invalid data', - }, + _: 'Invalid data' + } }; module.exports = schema; diff --git a/backend/Schema/auth/index.js b/backend/Schema/auth/index.js index 66c17d6..34f3fb3 100644 --- a/backend/Schema/auth/index.js +++ b/backend/Schema/auth/index.js @@ -8,7 +8,7 @@ const resetPasswordSchema = require('./resetPassword'); const verifyEmailSchema = require('./verifyEmail'); const verifyNewEmailSchema = require('./verifyNewEmail'); -ajv.addFormat('password', (data) => { +ajv.addFormat('password', data => { return data.length >= 8; }); @@ -20,5 +20,5 @@ module.exports = { updatePasswordSchema, resetPasswordSchema, verifyEmailSchema, - verifyNewEmailSchema, + verifyNewEmailSchema }; diff --git a/backend/Schema/auth/login.js b/backend/Schema/auth/login.js index 6946fe9..d86fc54 100644 --- a/backend/Schema/auth/login.js +++ b/backend/Schema/auth/login.js @@ -1,20 +1,20 @@ const schema = { required: ['username', 'password'], properties: { - username: {type: 'string', minLength: 4}, - password: {type: 'string', format: 'password'}, + username: { type: 'string', minLength: 4 }, + password: { type: 'string', format: 'password' } }, errorMessage: { required: { username: 'Username required', - password: 'Password required', + password: 'Password required' }, properties: { username: 'Invalid username', - password: 'Invalid password', + password: 'Invalid password' }, - _: 'Invalid data', - }, + _: 'Invalid data' + } }; module.exports = schema; diff --git a/backend/Schema/auth/resetPassword.js b/backend/Schema/auth/resetPassword.js index 425f2a5..1b9760a 100644 --- a/backend/Schema/auth/resetPassword.js +++ b/backend/Schema/auth/resetPassword.js @@ -1,26 +1,26 @@ const schema = { required: ['password', 'password_confirm', 'username', 'otp'], properties: { - password: {type: 'string', format: 'password'}, - password_confirm: {type: 'string', format: 'password'}, - username: {type: 'string', minLength: 4}, - otp: {type: 'number', minLength: 6, maxLength: 6}, + password: { type: 'string', format: 'password' }, + password_confirm: { type: 'string', format: 'password' }, + username: { type: 'string', minLength: 4 }, + otp: { type: 'number', minLength: 6, maxLength: 6 } }, errorMessage: { required: { password: 'Password required', password_confirm: 'Confirm password required', username: 'Username required', - otp: 'OTP required', + otp: 'OTP required' }, properties: { password: 'Invalid data', password_confirm: 'Invalid confirm password', username: 'Invalid username', - otp: 'Invalid OTP', + otp: 'Invalid OTP' }, - _: 'Invalid data', - }, + _: 'Invalid data' + } }; module.exports = schema; diff --git a/backend/Schema/auth/signup.js b/backend/Schema/auth/signup.js index 64747cc..4268e7b 100644 --- a/backend/Schema/auth/signup.js +++ b/backend/Schema/auth/signup.js @@ -1,23 +1,23 @@ const schema = { required: ['username', 'email', 'name', 'password', 'department'], properties: { - username: {type: 'string', minLength: 4}, + username: { type: 'string', minLength: 4 }, email: { type: 'string', pattern: - '^[a-z]+\\.[0-9]{2}[a-z]{2}[0-9]{4}@([a-z].\\.)?iitism\\.ac\\.in$', + '^[a-z]+\\.[0-9]{2}[a-z]{2}[0-9]{4}@([a-z].\\.)?iitism\\.ac\\.in$' }, - name: {type: 'string'}, - password: {type: 'string', format: 'password'}, - branch: {type: 'number'}, - department: {type: 'number'}, + name: { type: 'string' }, + password: { type: 'string', format: 'password' }, + branch: { type: 'number' }, + department: { type: 'number' }, admission_no: { type: 'string', minLength: 8, maxLength: 8, - pattern: '^[0-9]{2}[a-z]{2}[0-9]{4}$', + pattern: '^[0-9]{2}[a-z]{2}[0-9]{4}$' }, - semester: {type: 'number', minLength: 1, maxLength: 8}, + semester: { type: 'number', minLength: 1, maxLength: 8 } }, errorMessage: { required: { @@ -25,7 +25,7 @@ const schema = { email: 'Email required', name: 'Name required', password: 'Password required', - department: 'Department required', + department: 'Department required' }, properties: { username: 'Invalid username', @@ -35,10 +35,10 @@ const schema = { branch: 'Invalid branch', department: 'Invalid department', admission_no: 'Invalid Admission number', - semester: 'Invalid semester', + semester: 'Invalid semester' }, - _: 'Invalid data', - }, + _: 'Invalid data' + } }; module.exports = schema; diff --git a/backend/Schema/auth/updatePassword.js b/backend/Schema/auth/updatePassword.js index 6748788..90a0183 100644 --- a/backend/Schema/auth/updatePassword.js +++ b/backend/Schema/auth/updatePassword.js @@ -1,20 +1,20 @@ let schema = { required: ['password', 'new_password'], properties: { - password: {type: 'string', format: 'password'}, - new_password: {type: 'string', format: 'password'}, + password: { type: 'string', format: 'password' }, + new_password: { type: 'string', format: 'password' } }, errorMessage: { required: { password: 'Current Password required', - new_password: 'New password required', + new_password: 'New password required' }, properties: { password: 'Invalid password', - new_password: 'Invalid new Password', + new_password: 'Invalid new Password' }, - _: 'Invalid data', - }, + _: 'Invalid data' + } }; module.exports = schema; diff --git a/backend/Schema/auth/updateUser.js b/backend/Schema/auth/updateUser.js index 9840272..4371bba 100644 --- a/backend/Schema/auth/updateUser.js +++ b/backend/Schema/auth/updateUser.js @@ -1,26 +1,26 @@ const schema = { required: ['username'], properties: { - username: {type: 'string', minLength: 4}, + username: { type: 'string', minLength: 4 }, email: { type: 'string', pattern: - '^[a-z]+\\.[0-9]{2}[a-z]{2}[0-9]{4}@([a-z].\\.)?iitism\\.ac\\.in$', + '^[a-z]+\\.[0-9]{2}[a-z]{2}[0-9]{4}@([a-z].\\.)?iitism\\.ac\\.in$' }, - name: {type: 'string'}, - branch: {type: 'number'}, - department: {type: 'number'}, + name: { type: 'string' }, + branch: { type: 'number' }, + department: { type: 'number' }, admission_no: { type: 'string', minLength: 8, maxLength: 8, - pattern: '/^[0-9]{2}[a-z]{2}[0-9]{4}$/', + pattern: '/^[0-9]{2}[a-z]{2}[0-9]{4}$/' }, - semester: {type: 'number', minLength: 1, maxLength: 8}, + semester: { type: 'number', minLength: 1, maxLength: 8 } }, errorMessage: { required: { - username: 'Username requried', + username: 'Username requried' }, properties: { username: 'Invalid username', @@ -29,10 +29,10 @@ const schema = { branch: 'Invalid branch', department: 'Invalid department', admission_no: 'Invalid Admission number', - semester: 'Invalid semester', + semester: 'Invalid semester' }, - _: 'Invalid data', - }, + _: 'Invalid data' + } }; module.exports = schema; diff --git a/backend/Schema/auth/verifyEmail.js b/backend/Schema/auth/verifyEmail.js index 0d8a85e..394c9bc 100644 --- a/backend/Schema/auth/verifyEmail.js +++ b/backend/Schema/auth/verifyEmail.js @@ -1,20 +1,20 @@ const schema = { required: ['otp', 'username'], properties: { - otp: {type: 'number', minLength: 6, maxLength: 6}, - username: {type: 'string', minLength: 4}, + otp: { type: 'number', minLength: 6, maxLength: 6 }, + username: { type: 'string', minLength: 4 } }, errorMessage: { required: { otp: 'OTP required', - username: 'username or email required', + username: 'username or email required' }, properties: { otp: 'Invalid OTP', - username: 'Invalid username', + username: 'Invalid username' }, - _: 'Invalid data', - }, + _: 'Invalid data' + } }; module.exports = schema; diff --git a/backend/Schema/auth/verifyNewEmail.js b/backend/Schema/auth/verifyNewEmail.js index fb154ad..1482e73 100644 --- a/backend/Schema/auth/verifyNewEmail.js +++ b/backend/Schema/auth/verifyNewEmail.js @@ -1,27 +1,27 @@ const schema = { required: ['otp', 'email', 'username'], properties: { - otp: {type: 'number', minLength: 6, maxLength: 6}, - username: {type: 'string', minLength: 4}, + otp: { type: 'number', minLength: 6, maxLength: 6 }, + username: { type: 'string', minLength: 4 }, email: { type: 'string', pattern: - '^[a-z]+\\.[0-9]{2}[a-z]{2}[0-9]{4}@([a-z].\\.)?iitism\\.ac\\.in$', - }, + '^[a-z]+\\.[0-9]{2}[a-z]{2}[0-9]{4}@([a-z].\\.)?iitism\\.ac\\.in$' + } }, errorMessage: { required: { otp: 'OTP required', username: 'username or email required', - email: 'email or username required', + email: 'email or username required' }, properties: { otp: 'Invalid OTP', username: 'Invalid username', - email: 'Invalid email', + email: 'Invalid email' }, - _: 'Invalid data', - }, + _: 'Invalid data' + } }; module.exports = schema; diff --git a/backend/Schema/contestadmin/createNewContestSchema.js b/backend/Schema/contestadmin/createNewContestSchema.js index bba4e1c..41d828a 100644 --- a/backend/Schema/contestadmin/createNewContestSchema.js +++ b/backend/Schema/contestadmin/createNewContestSchema.js @@ -1,17 +1,27 @@ const createNewContestSchema = { - required:['username','title','about','rules','prize','start_time','end_time','group_id','confidential',] + required: [ + 'username', + 'title', + 'about', + 'rules', + 'prize', + 'start_time', + 'end_time', + 'group_id', + 'confidential' + ], properties: { - username: {type: 'string'}, - title:{type:'string'} - about: {type: 'string'}, - rules: {type:'string'}, - prize: {type: 'string'}, - start_time:{type: 'string'}, - end_time:{type: 'string'}, - group_id:{type: 'string'}, - confidential:{type: 'boolean'}, + username: { type: 'string' }, + title: { type: 'string' }, + about: { type: 'string' }, + rules: { type: 'string' }, + prize: { type: 'string' }, + start_time: { type: 'string' }, + end_time: { type: 'string' }, + group_id: { type: 'string' }, + confidential: { type: 'boolean' } }, - errorMessage: { + errorMessage: { required: { username: 'Username required', title: 'Title required', @@ -21,7 +31,7 @@ const createNewContestSchema = { start_time: 'Start time required', end_time: 'End time required', group_id: 'Group Id required', - confidential: 'Confidetial Status required', + confidential: 'Confidetial Status required' }, properties: { username: 'Invalid username', @@ -32,11 +42,10 @@ const createNewContestSchema = { start_time: 'Invalid Start time', end_time: 'Invalid End time', group_id: 'Invalid Group Id', - confidential: 'Invalid Confidetial Status', + confidential: 'Invalid Confidetial Status' }, - _: 'Invalid data', - }, - + _: 'Invalid data' + } }; module.exports = createNewContestSchema; diff --git a/backend/Schema/contestadmin/createNewQuestionSchema.js b/backend/Schema/contestadmin/createNewQuestionSchema.js index e880828..fd7c9c1 100644 --- a/backend/Schema/contestadmin/createNewQuestionSchema.js +++ b/backend/Schema/contestadmin/createNewQuestionSchema.js @@ -1,31 +1,43 @@ const createNewQuestionSchema = { - required: ['username','contest_id','type','question_name','problemstatement','solution','max_score','negative','partial','difficulty','answer'] + required: [ + 'username', + 'contest_id', + 'type', + 'question_name', + 'problemstatement', + 'solution', + 'max_score', + 'negative', + 'partial', + 'difficulty', + 'answer' + ], properties: { - username:{type:'string'}, - contest_id:{type:'number'}, - type:{type:'integer'}, - question_name:{type:'string'}, - problemstatement:{type:'string'}, - solution:{type:'string'}, - max_score:{type:'number'}, - negative:{type:'number'}, - partial:{type:'number'}, - difficulty:{type:'string'}, - answer:{type:'string'} + username: { type: 'string' }, + contest_id: { type: 'number' }, + type: { type: 'integer' }, + question_name: { type: 'string' }, + problemstatement: { type: 'string' }, + solution: { type: 'string' }, + max_score: { type: 'number' }, + negative: { type: 'number' }, + partial: { type: 'number' }, + difficulty: { type: 'string' }, + answer: { type: 'string' } }, errorMessage: { required: { username: 'Username required', contest_id: 'Contest id required', - question_name:'Question name required', - type;'Type required', - problemstatement:'Problem statement required', - solution:'Answer required', - max_score:'Maxscore required', - negative:'Negstive scheming required' - partial:'Partial scheming required', - difficulty:'Difficulty level required' - answer:'Answer required' + question_name: 'Question name required', + type: 'Type required', + problemstatement: 'Problem statement required', + solution: 'Answer required', + max_score: 'Maxscore required', + negative: 'Negstive scheming required', + partial: 'Partial scheming required', + difficulty: 'Difficulty level required', + answer: 'Answer required' }, properties: { username: 'Invalid username', @@ -38,11 +50,10 @@ const createNewQuestionSchema = { negative: 'Invalid negative marking', partial: 'Invalid partial marking', difficulty: 'Invalid difficulty level', - answer: 'Invalid answer', + answer: 'Invalid answer' }, - _: 'Invalid data', - }, - + _: 'Invalid data' + } }; module.exports = createNewQuestionSchema; diff --git a/backend/Schema/contestadmin/deleteAdminSchema.js b/backend/Schema/contestadmin/deleteAdminSchema.js index 27c8ae3..c032bb0 100644 --- a/backend/Schema/contestadmin/deleteAdminSchema.js +++ b/backend/Schema/contestadmin/deleteAdminSchema.js @@ -1,9 +1,9 @@ const deleteAdminSchema = { - required:['username','contest_id','adminname'] + required: ['username', 'contest_id', 'adminname'], properties: { - username: {type: 'string'}, - contest_id:{type:'number'}, - adminname:{type:'string'} + username: { type: 'string' }, + contest_id: { type: 'number' }, + adminname: { type: 'string' } }, errorMessage: { required: { @@ -16,9 +16,8 @@ const deleteAdminSchema = { contest_id: 'Invalid contest id', adminname: 'Invalid name of admin' }, - _: 'Invalid data', + _: 'Invalid data' } - }; module.exports = deleteAdminSchema; diff --git a/backend/Schema/contestadmin/deleteContestSchema.js b/backend/Schema/contestadmin/deleteContestSchema.js index 78718d6..0fb6cf3 100644 --- a/backend/Schema/contestadmin/deleteContestSchema.js +++ b/backend/Schema/contestadmin/deleteContestSchema.js @@ -1,21 +1,20 @@ const deleteContestSchema = { - required:['username','contest_id'] + required: ['username', 'contest_id'], properties: { - username: {type: 'string'}, - contest_id:{type:'number'} + username: { type: 'string' }, + contest_id: { type: 'number' } }, errorMessage: { required: { username: 'Username required', - contest_id: 'Contest Id required', + contest_id: 'Contest Id required' }, properties: { username: 'Invalid username', - contest_id: 'Invalid contest id', + contest_id: 'Invalid contest id' }, - _: 'Invalid data', + _: 'Invalid data' } - }; module.exports = deleteContestSchema; diff --git a/backend/Schema/contestadmin/deleteQuestionSchema.js b/backend/Schema/contestadmin/deleteQuestionSchema.js index 5ed83bb..7ea93eb 100644 --- a/backend/Schema/contestadmin/deleteQuestionSchema.js +++ b/backend/Schema/contestadmin/deleteQuestionSchema.js @@ -1,11 +1,10 @@ const deleteQuestionSchema = { - required:['username','contest_id','question_id'] + required: ['username', 'contest_id', 'question_id'], properties: { - username: {type: 'string'}, - contest_id:{type:'string'}, - question_id:{type:'string'} - }, - + username: { type: 'string' }, + contest_id: { type: 'string' }, + question_id: { type: 'string' } + } }; module.exports = deleteQuestionSchema; diff --git a/backend/Schema/contestadmin/editAdminSchema.js b/backend/Schema/contestadmin/editAdminSchema.js index c8dd322..bc8a384 100644 --- a/backend/Schema/contestadmin/editAdminSchema.js +++ b/backend/Schema/contestadmin/editAdminSchema.js @@ -1,14 +1,14 @@ const editAdminSchema = { - required:['username','contest_id','adminname','newvalue'] + required: ['username', 'contest_id', 'adminname', 'newvalue'], properties: { - username: {type: 'string'}, - contest_id:{type:'number'}, - adminname:{type:'string'}, - newvalue:{type:'integer'} + username: { type: 'string' }, + contest_id: { type: 'number' }, + adminname: { type: 'string' }, + newvalue: { type: 'integer' } }, errorMessage: { required: { - username:'Username required', + username: 'Username required', contest_id: 'Contest id required', adminname: 'Admin name required', newvalue: 'New value required' @@ -19,9 +19,8 @@ const editAdminSchema = { adminname: 'Invalid admin name', newvalue: 'Invalid new value' }, - _: 'Invalid data', + _: 'Invalid data' } - }; module.exports = editAdminSchema; diff --git a/backend/Schema/contestadmin/editContestSchema.js b/backend/Schema/contestadmin/editContestSchema.js index 7ef2f5d..b5c9fff 100644 --- a/backend/Schema/contestadmin/editContestSchema.js +++ b/backend/Schema/contestadmin/editContestSchema.js @@ -1,33 +1,44 @@ const editContestSchema = { - required:['username','contest_id','title','about','rules','prize','start_time','end_time','group_id','confidential'] + required: [ + 'username', + 'contest_id', + 'title', + 'about', + 'rules', + 'prize', + 'start_time', + 'end_time', + 'group_id', + 'confidential' + ], properties: { - username: {type: 'string'}, - contest_id:{type:'string'} - title:{type:'string'} - about: {type: 'string'}, - rules: {type:'number'}, - prize: {type: 'string'}, - start_time:{type: 'string'}, - end_time:{type: 'string'}, - group_id:{type: 'number'}, - confidential:{type: 'boolean'} + username: { type: 'string' }, + contest_id: { type: 'string' }, + title: { type: 'string' }, + about: { type: 'string' }, + rules: { type: 'number' }, + prize: { type: 'string' }, + start_time: { type: 'string' }, + end_time: { type: 'string' }, + group_id: { type: 'number' }, + confidential: { type: 'boolean' } }, errorMessage: { required: { username: 'Username required', contest_id: 'Contest id required', - title:"Title required", + title: 'Title required', about: 'About required', rules: 'Rules required', prize: 'Prize required', start_time: 'Start time required', end_time: 'End time required', group_id: 'Group Id required', - confidential: 'Confidetial Status required', + confidential: 'Confidetial Status required' }, properties: { username: 'Invalid username', - contest_id:'Invalid contest id' + contest_id: 'Invalid contest id', title: 'Invalid Title', about: 'Invalid About', rules: 'Invalid Rules', @@ -35,11 +46,10 @@ const editContestSchema = { start_time: 'Invalid Start time', end_time: 'Invalid End time', group_id: 'Invalid Group Id', - confidential: 'Invalid Confidetial Status', + confidential: 'Invalid Confidetial Status' }, - _: 'Invalid data', + _: 'Invalid data' } - }; module.exports = editContestSchema; diff --git a/backend/Schema/contestadmin/editQuestionSchema.js b/backend/Schema/contestadmin/editQuestionSchema.js index 38905e0..fc9a6ae 100644 --- a/backend/Schema/contestadmin/editQuestionSchema.js +++ b/backend/Schema/contestadmin/editQuestionSchema.js @@ -1,38 +1,51 @@ - const editQuestionSchema = { - required: ['username','contest_id','question_id','type','question_name','problemstatement','solution','max_score','negative','partial','difficulty','answer'] +const editQuestionSchema = { + required: [ + 'username', + 'contest_id', + 'question_id', + 'type', + 'question_name', + 'problemstatement', + 'solution', + 'max_score', + 'negative', + 'partial', + 'difficulty', + 'answer' + ], properties: { - username:{type:'string'}, - contest_id:{type:'number'}, - question_id:{type:'number'}, - question_name:{type:'string'}, - type:{type:'integer'}, - problemstatement:{type:'string'}, - solution:{type:'string'}, - max_score:{type:'number'}, - negative:{type:'number'}, - partial:{type:'number'}, - difficulty:{type:'string'}, - answer:{type:'string'} + username: { type: 'string' }, + contest_id: { type: 'number' }, + question_id: { type: 'number' }, + question_name: { type: 'string' }, + type: { type: 'integer' }, + problemstatement: { type: 'string' }, + solution: { type: 'string' }, + max_score: { type: 'number' }, + negative: { type: 'number' }, + partial: { type: 'number' }, + difficulty: { type: 'string' }, + answer: { type: 'string' } }, errorMessage: { required: { username: 'Username required', contest_id: 'Contest id required', - question_id:'Question id required', - question_name:'Question name required', - type;'Type required', - problemstatement:'Problem statement required', - solution:'Answer required', - max_score:'Maxscore required', - negative:'Negative scheming required' - partial:'Partial scheming required', - difficulty:'Difficulty level required' - answer:'Answer required' + question_id: 'Question id required', + question_name: 'Question name required', + type: 'Type required', + problemstatement: 'Problem statement required', + solution: 'Answer required', + max_score: 'Maxscore required', + negative: 'Negative scheming required', + partial: 'Partial scheming required', + difficulty: 'Difficulty level required', + answer: 'Answer required' }, properties: { username: 'Invalid username', contest_id: 'Invalid contest id', - question_id:'Invalid question id' + question_id: 'Invalid question id', question_name: 'Invalid question name', type: 'Invalid question type', problemstatement: 'Invalid problem statement', @@ -41,11 +54,10 @@ negative: 'Invalid negative marking', partial: 'Invalid partial marking', difficulty: 'Invalid difficulty level', - answer: 'Invalid answer', + answer: 'Invalid answer' }, - _: 'Invalid data', - }, - + _: 'Invalid data' + } }; module.exports = editQuestionSchema; diff --git a/backend/Schema/contestadmin/getAllQuestionsSchema.js b/backend/Schema/contestadmin/getAllQuestionsSchema.js index 63b333e..f953b05 100644 --- a/backend/Schema/contestadmin/getAllQuestionsSchema.js +++ b/backend/Schema/contestadmin/getAllQuestionsSchema.js @@ -1,8 +1,8 @@ const getAllQuestionsSchema = { - required:['username','contest_id'] + required: ['username', 'contest_id'], properties: { - username: {type:'string'}, - contest_id:{type:'number'}, + username: { type: 'string' }, + contest_id: { type: 'number' } }, errorMessage: { required: { @@ -13,7 +13,7 @@ const getAllQuestionsSchema = { username: 'Invalid username', contest_id: 'Invalid contest id' }, - _: 'Invalid data', + _: 'Invalid data' } }; diff --git a/backend/Schema/contestadmin/getSingleContestSchema.js b/backend/Schema/contestadmin/getSingleContestSchema.js index 1c77835..65edb65 100644 --- a/backend/Schema/contestadmin/getSingleContestSchema.js +++ b/backend/Schema/contestadmin/getSingleContestSchema.js @@ -1,21 +1,20 @@ const getSingleContestSchema = { - required:['username','contest_id'] + required: ["username", "contest_id"], properties: { - username: {type: 'string'}, - contest_id:{type:'number'} + username: { type: "string" }, + contest_id: { type: "number" } }, errorMessage: { required: { - username: 'Username required', - contest_id:'Contest id required' + username: "Username required", + contest_id: "Contest id required" }, properties: { - username: 'Invalid username', - contest_id: 'Invalid contest id', + username: "Invalid username", + contest_id: "Invalid contest id" }, - _: 'Invalid data', + _: "Invalid data" } - }; module.exports = getSingleContestSchema; diff --git a/backend/Schema/contestadmin/getSingleQuestionSchema.js b/backend/Schema/contestadmin/getSingleQuestionSchema.js index 8abda1d..6068439 100644 --- a/backend/Schema/contestadmin/getSingleQuestionSchema.js +++ b/backend/Schema/contestadmin/getSingleQuestionSchema.js @@ -1,25 +1,23 @@ const getSingleQuestionSchema = { - required:['username','contest_id','question_id'] + required: ['username', 'contest_id', 'question_id'], properties: { - username: {type:'string'}, - contest_id:{type:'number'}, - question_id:{type:'number'} + username: { type: 'string' }, + contest_id: { type: 'number' }, + question_id: { type: 'number' } }, errorMessage: { required: { username: 'Username required', contest_id: 'Contest id required', - question_id: 'Question id required', - + question_id: 'Question id required' }, properties: { username: 'Invalid username', contest_id: 'Invalid contest id', - question_id: 'Invalid question id', + question_id: 'Invalid question id' }, - _: 'Invalid data', + _: 'Invalid data' } - }; module.exports = getSingleQuestionSchema; diff --git a/backend/Schema/index.js b/backend/Schema/index.js index 2d1235f..a1b82f9 100644 --- a/backend/Schema/index.js +++ b/backend/Schema/index.js @@ -4,7 +4,7 @@ const ajv = new Ajv({ allErrors: true, coerceTypes: true, useDefaults: true, - jsonPointers: true, + jsonPointers: true }); require('ajv-errors')(ajv); diff --git a/backend/package-lock.json b/backend/package-lock.json index c0c897e..5d14ccd 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -1,5 +1,5 @@ { - "name": "online-judge", + "name": "online-judge-backend", "version": "1.0.0", "lockfileVersion": 1, "requires": true, @@ -24,6 +24,71 @@ "js-tokens": "^4.0.0" } }, + "@types/eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", + "dev": true + }, + "@types/json-schema": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.3.tgz", + "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==", + "dev": true + }, + "@typescript-eslint/experimental-utils": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-1.13.0.tgz", + "integrity": "sha512-zmpS6SyqG4ZF64ffaJ6uah6tWWWgZ8m+c54XXgwFtUv0jNz8aJAVx8chMCvnk7yl6xwn8d+d96+tWp7fXzTuDg==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "1.13.0", + "eslint-scope": "^4.0.0" + }, + "dependencies": { + "eslint-scope": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + } + } + }, + "@typescript-eslint/parser": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-1.13.0.tgz", + "integrity": "sha512-ITMBs52PCPgLb2nGPoeT4iU3HdQZHcPaZVw+7CsFagRJHUhyeTgorEwHXhFf3e7Evzi8oujKNpHc8TONth8AdQ==", + "dev": true, + "requires": { + "@types/eslint-visitor-keys": "^1.0.0", + "@typescript-eslint/experimental-utils": "1.13.0", + "@typescript-eslint/typescript-estree": "1.13.0", + "eslint-visitor-keys": "^1.0.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-1.13.0.tgz", + "integrity": "sha512-b5rCmd2e6DCC6tCTN9GSUAuxdYwCM/k/2wdjHGrIRGPSJotWMCe/dGpi66u42bhuh8q3QBzqM4TMA1GUUCJvdw==", + "dev": true, + "requires": { + "lodash.unescape": "4.0.1", + "semver": "5.5.0" + }, + "dependencies": { + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + } + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -40,9 +105,9 @@ } }, "acorn": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", - "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.0.0.tgz", + "integrity": "sha512-PaF/MduxijYYt7unVGRuds1vBC9bFxbNf+VWqhOClfdgy7RlVkQqt610ig1/yxTgsDIfW1cWDel5EBbOy3jdtQ==", "dev": true }, "acorn-jsx": { @@ -153,6 +218,16 @@ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, + "array-includes": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", + "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.7.0" + } + }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", @@ -488,6 +563,12 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "common-tags": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz", + "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw==", + "dev": true + }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -514,6 +595,12 @@ "xdg-basedir": "^3.0.0" } }, + "contains-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", + "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "dev": true + }, "content-disposition": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", @@ -543,6 +630,12 @@ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true }, + "core-js": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.2.1.tgz", + "integrity": "sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw==", + "dev": true + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -600,6 +693,15 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", @@ -651,6 +753,12 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "dlv": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==", + "dev": true + }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -704,6 +812,40 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -716,9 +858,9 @@ "dev": true }, "eslint": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.1.0.tgz", - "integrity": "sha512-QhrbdRD7ofuV09IuE2ySWBz0FyXCq0rriLTZXZqaWSI79CVtHVRdkFuFTViiqzZhkCgfOh9USpriuGN2gIpZDQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.2.0.tgz", + "integrity": "sha512-sS0SZwm5UAoI83F+cgdomz0cBNPs+AnRvEboNYeWvrZ8UcDHCu/5muocwoDL2TkHq9skkP0GvZjmwI8HG7S3sw==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -728,9 +870,9 @@ "debug": "^4.0.1", "doctrine": "^3.0.0", "eslint-scope": "^5.0.0", - "eslint-utils": "^1.3.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^6.0.0", + "eslint-utils": "^1.4.0", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.0", "esquery": "^1.0.1", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", @@ -843,6 +985,101 @@ "get-stdin": "^6.0.0" } }, + "eslint-config-standard": { + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-13.0.1.tgz", + "integrity": "sha512-zLKp4QOgq6JFgRm1dDCVv1Iu0P5uZ4v5Wa4DTOkg2RFMxdCX/9Qf7lz9ezRj2dBRa955cWQF/O/LWEiYWAHbTw==", + "dev": true + }, + "eslint-import-resolver-node": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz", + "integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "resolve": "^1.5.0" + } + }, + "eslint-module-utils": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.1.tgz", + "integrity": "sha512-H6DOj+ejw7Tesdgbfs4jeS4YMFrT8uI8xwd1gtQqXssaR0EQ26L+2O/w6wkYFy2MymON0fTwHmXBvvfLNZVZEw==", + "dev": true, + "requires": { + "debug": "^2.6.8", + "pkg-dir": "^2.0.0" + } + }, + "eslint-plugin-es": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-1.4.0.tgz", + "integrity": "sha512-XfFmgFdIUDgvaRAlaXUkxrRg5JSADoRC8IkKLc/cISeR3yHVMefFHQZpcyXXEUUPHfy5DwviBcrfqlyqEwlQVw==", + "dev": true, + "requires": { + "eslint-utils": "^1.3.0", + "regexpp": "^2.0.1" + } + }, + "eslint-plugin-import": { + "version": "2.18.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.18.2.tgz", + "integrity": "sha512-5ohpsHAiUBRNaBWAF08izwUGlbrJoJJ+W9/TBwsGoR1MnlgfwMIKrFeSjWbt6moabiXW9xNvtFz+97KHRfI4HQ==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "contains-path": "^0.1.0", + "debug": "^2.6.9", + "doctrine": "1.5.0", + "eslint-import-resolver-node": "^0.3.2", + "eslint-module-utils": "^2.4.0", + "has": "^1.0.3", + "minimatch": "^3.0.4", + "object.values": "^1.1.0", + "read-pkg-up": "^2.0.0", + "resolve": "^1.11.0" + }, + "dependencies": { + "doctrine": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", + "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "isarray": "^1.0.0" + } + } + } + }, + "eslint-plugin-node": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-9.1.0.tgz", + "integrity": "sha512-ZwQYGm6EoV2cfLpE1wxJWsfnKUIXfM/KM09/TlorkukgCAwmkgajEJnPCmyzoFPQQkmvo5DrW/nyKutNIw36Mw==", + "dev": true, + "requires": { + "eslint-plugin-es": "^1.4.0", + "eslint-utils": "^1.3.1", + "ignore": "^5.1.1", + "minimatch": "^3.0.4", + "resolve": "^1.10.1", + "semver": "^6.1.0" + }, + "dependencies": { + "ignore": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz", + "integrity": "sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "eslint-plugin-prettier": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.0.tgz", @@ -852,6 +1089,46 @@ "prettier-linter-helpers": "^1.0.0" } }, + "eslint-plugin-promise": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz", + "integrity": "sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw==", + "dev": true + }, + "eslint-plugin-react": { + "version": "7.14.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.14.3.tgz", + "integrity": "sha512-EzdyyBWC4Uz2hPYBiEJrKCUi2Fn+BJ9B/pJQcjw5X+x/H2Nm59S4MJIvL4O5NEE0+WbnQwEBxWY03oUk+Bc3FA==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "doctrine": "^2.1.0", + "has": "^1.0.3", + "jsx-ast-utils": "^2.1.0", + "object.entries": "^1.1.0", + "object.fromentries": "^2.0.0", + "object.values": "^1.1.0", + "prop-types": "^15.7.2", + "resolve": "^1.10.1" + }, + "dependencies": { + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + } + } + }, + "eslint-plugin-standard": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-4.0.0.tgz", + "integrity": "sha512-OwxJkR6TQiYMmt1EsNRMe5qG3GsbjlcOhbGUBY4LtavF9DsLaTcoR+j2Tdjqi23oUwKNUqX7qcn5fPStafMdlA==", + "dev": true + }, "eslint-scope": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", @@ -878,14 +1155,14 @@ "dev": true }, "espree": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.0.0.tgz", - "integrity": "sha512-lJvCS6YbCn3ImT3yKkPe0+tJ+mH6ljhGNjHQH9mRtiO6gjhVAOhVXW1yjnwqGwTkK3bGbye+hb00nFNmu0l/1Q==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.0.tgz", + "integrity": "sha512-boA7CHRLlVWUSg3iL5Kmlt/xT3Q+sXnKoRYYzj1YeM10A76TEJBbotV5pKbnK42hEUIr121zTv+QLRM5LsCPXQ==", "dev": true, "requires": { - "acorn": "^6.0.7", + "acorn": "^7.0.0", "acorn-jsx": "^5.0.0", - "eslint-visitor-keys": "^1.0.0" + "eslint-visitor-keys": "^1.1.0" } }, "esprima": { @@ -1190,6 +1467,15 @@ "unpipe": "~1.0.0" } }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, "flat-cache": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", @@ -1786,6 +2072,12 @@ } } }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", @@ -1885,12 +2177,44 @@ "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", "dev": true }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + } + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -1923,6 +2247,12 @@ } } }, + "hosted-git-info": { + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.4.tgz", + "integrity": "sha512-pzXIvANXEFrc5oFFXRMkbLPQ2rXRoDERwDLyrcUxGhaZhgP54BBSl9Oheh7Vv0T090cszWBxPjkQQ5Sq1PbBRQ==", + "dev": true + }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -1977,6 +2307,12 @@ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, + "indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -2078,6 +2414,12 @@ } } }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", @@ -2093,6 +2435,12 @@ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, "is-ci": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", @@ -2122,6 +2470,12 @@ } } }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -2240,6 +2594,15 @@ "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", "dev": true }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, "is-retry-allowed": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", @@ -2252,6 +2615,15 @@ "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -2326,6 +2698,16 @@ } } }, + "jsx-ast-utils": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.2.1.tgz", + "integrity": "sha512-v3FxCcAf20DayI+uxnCuw795+oOIkVu6EnJ1+kSzhqqTZHNkTZ7B66ZgLp4oLJ/gbA64cI0B7WRoHZMSRdyVRQ==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "object.assign": "^4.1.0" + } + }, "jwa": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", @@ -2370,6 +2752,36 @@ "type-check": "~0.3.2" } }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", @@ -2406,11 +2818,90 @@ "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" }, + "lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, "lodash.once": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" }, + "lodash.unescape": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz", + "integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=", + "dev": true + }, + "loglevel": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.3.tgz", + "integrity": "sha512-LoEDv5pgpvWgPF4kNYuIp0qqSJVWak/dML0RY74xlzMZiT9w77teNAwKYKWBTYjlokMirg+o3jBwp+vlLrcfAA==", + "dev": true + }, + "loglevel-colored-level-prefix": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/loglevel-colored-level-prefix/-/loglevel-colored-level-prefix-1.0.0.tgz", + "integrity": "sha1-akAhj9x64V/HbD0PPmdsRlOIYD4=", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "loglevel": "^1.4.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, "lowercase-keys": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", @@ -2678,6 +3169,18 @@ "abbrev": "1" } }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -2693,6 +3196,12 @@ "path-key": "^2.0.0" } }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, "object-copy": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", @@ -2724,6 +3233,12 @@ } } }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", @@ -2733,6 +3248,42 @@ "isobject": "^3.0.0" } }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.entries": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz", + "integrity": "sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, + "object.fromentries": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.0.tgz", + "integrity": "sha512-9iLiI6H083uiqUuvzyY6qrlmc/Gz8hLQFOcb/Ri/0xXFkSNS3ctV+CbE6yM2+AnkYfOB3dGjdzC0wrMLIhQICA==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.11.0", + "function-bind": "^1.1.1", + "has": "^1.0.1" + } + }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -2742,6 +3293,18 @@ "isobject": "^3.0.1" } }, + "object.values": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz", + "integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -2802,6 +3365,30 @@ "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", "dev": true }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, "package-json": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", @@ -2823,6 +3410,15 @@ "callsites": "^3.0.0" } }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -2840,6 +3436,12 @@ "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", "dev": true }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -2858,17 +3460,49 @@ "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "dev": true }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, "path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } + } + }, "pify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "dev": true }, + "pkg-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + } + }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -2893,6 +3527,128 @@ "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", "dev": true }, + "prettier-eslint": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/prettier-eslint/-/prettier-eslint-9.0.0.tgz", + "integrity": "sha512-0dael2aMpMAxAwClnLi2Coc30v3BubsTX6clqseZ8NFCJZnbZlwxZGHHESYBlqTyN9lvZDHHv+XdeHW0fKhxJQ==", + "dev": true, + "requires": { + "@typescript-eslint/parser": "^1.10.2", + "common-tags": "^1.4.0", + "core-js": "^3.1.4", + "dlv": "^1.1.0", + "eslint": "^5.0.0", + "indent-string": "^4.0.0", + "lodash.merge": "^4.6.0", + "loglevel-colored-level-prefix": "^1.0.0", + "prettier": "^1.7.0", + "pretty-format": "^23.0.1", + "require-relative": "^0.8.7", + "typescript": "^3.2.1", + "vue-eslint-parser": "^2.0.2" + }, + "dependencies": { + "acorn": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", + "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "eslint": { + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", + "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.9.1", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^4.0.3", + "eslint-utils": "^1.3.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^5.0.1", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.7.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^6.2.2", + "js-yaml": "^3.13.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.11", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^5.5.1", + "strip-ansi": "^4.0.0", + "strip-json-comments": "^2.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0" + } + }, + "eslint-scope": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "espree": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", + "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", + "dev": true, + "requires": { + "acorn": "^6.0.7", + "acorn-jsx": "^5.0.0", + "eslint-visitor-keys": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, "prettier-linter-helpers": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", @@ -2902,6 +3658,16 @@ "fast-diff": "^1.1.2" } }, + "pretty-format": { + "version": "23.6.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-23.6.0.tgz", + "integrity": "sha512-zf9NV1NSlDLDjycnwm6hpFATCGl/K1lt0R/GdkAK2O5LN/rwJoB+Mh93gGJjut4YbmecbfgLWVGSTCr0Ewvvbw==", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0", + "ansi-styles": "^3.2.0" + } + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -2913,6 +3679,17 @@ "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, "proxy-addr": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", @@ -2972,6 +3749,33 @@ "strip-json-comments": "~2.0.1" } }, + "react-is": { + "version": "16.9.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz", + "integrity": "sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==", + "dev": true + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + } + }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", @@ -3050,6 +3854,21 @@ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true }, + "require-relative": { + "version": "0.8.7", + "resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz", + "integrity": "sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=", + "dev": true + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, "resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -3368,6 +4187,38 @@ "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", + "dev": true + }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -3441,6 +4292,12 @@ "ansi-regex": "^3.0.0" } }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -3635,6 +4492,12 @@ "mime-types": "~2.1.24" } }, + "typescript": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz", + "integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==", + "dev": true + }, "undefsafe": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.2.tgz", @@ -3785,11 +4648,95 @@ "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", "dev": true }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, + "vue-eslint-parser": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz", + "integrity": "sha512-ZezcU71Owm84xVF6gfurBQUGg8WQ+WZGxgDEQu1IHFBZNx7BFZg3L1yHxrCBNNwbwFtE1GuvfJKMtb6Xuwc/Bw==", + "dev": true, + "requires": { + "debug": "^3.1.0", + "eslint-scope": "^3.7.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^3.5.2", + "esquery": "^1.0.0", + "lodash": "^4.17.4" + }, + "dependencies": { + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", + "dev": true + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "dev": true, + "requires": { + "acorn": "^3.0.4" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + } + } + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "eslint-scope": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", + "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "espree": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "dev": true, + "requires": { + "acorn": "^5.5.0", + "acorn-jsx": "^3.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", diff --git a/backend/package.json b/backend/package.json index a3a07f8..9165ab7 100644 --- a/backend/package.json +++ b/backend/package.json @@ -32,10 +32,17 @@ "otplib": "^11.0.1" }, "devDependencies": { - "eslint": "^6.1.0", + "eslint": "^6.2.0", "eslint-config-prettier": "^6.0.0", + "eslint-config-standard": "^13.0.1", + "eslint-plugin-import": "^2.18.2", + "eslint-plugin-node": "^9.1.0", "eslint-plugin-prettier": "^3.1.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-react": "^7.14.3", + "eslint-plugin-standard": "^4.0.0", "nodemon": "^1.19.1", - "prettier": "^1.18.2" + "prettier": "1.18.2", + "prettier-eslint": "^9.0.0" } }