Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Changed the module type" #843

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions backend/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import express from "express";
import cors from "cors";
import helmet from "helmet"
import responseTime from "response-time";
import routes from "./app/routes"
import {errorHandler} from "./helpers/error"
const express = require('express');
const cors = require('cors');
const helmet = require('helmet');
const responseTime = require('response-time');
const routes = require('./app/routes');
const { errorHandler } = require('./helpers/error');
require('colors');
require('./helpers/dbConnection');

Expand Down Expand Up @@ -43,4 +43,4 @@ process.on('uncaughtException', (err) => {
console.log(err);
});

export default app;
module.exports = app;
2 changes: 1 addition & 1 deletion backend/app/models/Admin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const { Schema } = mongoose;

Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/Broadcast.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const { Schema } = mongoose;
const broadcastSchema = new Schema(
Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/TeamMember.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const { Schema } = mongoose;

Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/answers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const { Schema } = mongoose;

Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/contactUs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const { Schema } = mongoose;

Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/faq.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const { Schema } = mongoose;

Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/joinUs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const { Schema } = mongoose;

Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/question.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const { Schema } = mongoose;

Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/resource.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const resourceSchema = new mongoose.Schema(
{
Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/tinyURL.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from "mongoose";
const mongoose = require('mongoose');

const { Schema } = mongoose;
const tinyURLSchema = new Schema({
Expand Down
4 changes: 2 additions & 2 deletions backend/app/routes/Q&A/answers/@validationSchema/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Joi from "joi";
const Joi = require('joi');

const answerValidationSchema = Joi.object().keys({
question_id: Joi.string().trim().required().max(24).min(24),
Expand All @@ -16,7 +16,7 @@ const updateAnswerStatusSchema = Joi.object().keys({
status : Joi.boolean().required()
});

export {
module.exports = {
answerValidationSchema,
getAnswerValidationSchema,
updateAnswerStatusSchema
Expand Down
11 changes: 5 additions & 6 deletions backend/app/routes/Q&A/answers/downvoteAnswer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import to from "await-to-js";
import answer from '../../../models/answers';
import { ErrorHandler } from "../../../../helpers/error";
import constants from "../../../../constants";
const to = require('await-to-js').default;
const answer = require('../../../models/answers');
const { ErrorHandler } = require('../../../../helpers/error');
const constants = require('../../../../constants');


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const { answerId } = req.body;
const [err] = await to(
answer.updateOne({ _id: answerId }, [
Expand Down
13 changes: 6 additions & 7 deletions backend/app/routes/Q&A/answers/getAnswers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import to from "await-to-js"
import mongoose from "mongoose";
import Answer from '../../../models/answers'
import { ErrorHandler } from "../../../../helpers/error";
import constants from "../../../../constants";
const to = require('await-to-js').default;
const mongoose = require('mongoose');
const Answer = require('../../../models/answers');
const { ErrorHandler } = require('../../../../helpers/error');
const constants = require('../../../../constants');


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const qId = req.body.question_id;

const [err, answers] = await to(
Expand Down
20 changes: 10 additions & 10 deletions backend/app/routes/Q&A/answers/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import express from "express";
import {answerValidationSchema, getAnswerValidationSchema, updateAnswerStatus} from './@validationSchema'
import validation from '../../../../helpers/middlewares/validation'
import postAnswer from "./post";
import getAnswers from "./getAnswers"
import upvoteAnswer from "./upvoteAnswer";
import downvoteAnswer from "./downvoteAnswer"
import updateAnswerStatus from "./updateAnswerStatus";
const router = express.Router({mergeParams:true});
const router = require('express').Router({ mergeParams: true });
const { answerValidationSchema, getAnswerValidationSchema, updateAnswerStatusSchema } = require('./@validationSchema');
const validation = require('../../../../helpers/middlewares/validation');

const postAnswer = require('./post');
const getAnswers = require('./getAnswers');
const upvoteAnswer = require('./upvoteAnswer');
const downvoteAnswer = require('./downvoteAnswer');
const updateAnswerStatus = require('./updateAnswerStatus');

// POST API FOR ANSWER
router.post('/', validation(answerValidationSchema), postAnswer);
Expand All @@ -23,4 +23,4 @@ router.patch('/downvote', downvoteAnswer);
// Update Answer Status
router.patch('/updateStatus', validation(updateAnswerStatusSchema), updateAnswerStatus);

export default router;
module.exports = router;
11 changes: 5 additions & 6 deletions backend/app/routes/Q&A/answers/post.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import to from "await-to-js"
import answer from '../../../models/answers'
import { ErrorHandler } from "../../../../helpers/error";
import constants from "../../../../constants";
const to = require('await-to-js').default;
const answer = require('../../../models/answers');
const { ErrorHandler } = require('../../../../helpers/error');
const constants = require('../../../../constants');


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const [err, body] = await to(answer.create({ ...req.body }));

if (err) {
Expand Down
11 changes: 6 additions & 5 deletions backend/app/routes/Q&A/answers/updateAnswerStatus.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import to from "await-to-js";
import constants from "../../../../constants";
import { ErrorHandler } from "../../../../helpers/error";
import answers from "../../../models/answers"
const to = require("await-to-js").default;

const constants = require("../../../../constants");
const { ErrorHandler } = require("../../../../helpers/error");

export default async (req, res, next) => {
const answers = require("../../../models/answers");

module.exports = async (req, res, next) => {
// getting id and status from body
const id = req.body.id;
const status = req.body.status
Expand Down
11 changes: 5 additions & 6 deletions backend/app/routes/Q&A/answers/upvoteAnswer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import to from "await-to-js"
import answer from '../../../models/answers'
import { ErrorHandler } from "../../../../helpers/error";
import constants from "../../../../constants";
const to = require('await-to-js').default;
const answer = require('../../../models/answers');
const { ErrorHandler } = require('../../../../helpers/error');
const constants = require('../../../../constants');


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const { answerId } = req.body;
const [err] = await to(answer.updateOne({ _id: answerId }, { $inc: { upvotes: 1 } }));
if (err) {
Expand Down
4 changes: 2 additions & 2 deletions backend/app/routes/Q&A/question/@validationSchema/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Joi from "joi"
const Joi = require('joi');

const QuestionValidationSchema = Joi.object().keys({
title: Joi.string().trim().required().min(5),
Expand All @@ -11,4 +11,4 @@ const updateQuestionStatusSchema = Joi.object().keys({
status : Joi.boolean().required()
});

export { QuestionValidationSchema, updateQuestionStatusSchema };
module.exports = { QuestionValidationSchema, updateQuestionStatusSchema };
11 changes: 5 additions & 6 deletions backend/app/routes/Q&A/question/downvoteQuestion.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import to from "await-to-js"
import question from '../../../models/question';
import { ErrorHandler } from "../../../../helpers/error";
import constants from "../../../../constants";
const to = require('await-to-js').default;
const question = require('../../../models/question');
const { ErrorHandler } = require('../../../../helpers/error');
const constants = require('../../../../constants');


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const { questionId } = req.body;
const [err] = await to(
question.updateOne({ _id: questionId }, [
Expand Down
4 changes: 2 additions & 2 deletions backend/app/routes/Q&A/question/getAllQuestion.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import question from '../../../models/question'
const question = require('../../../models/question');

export default async (req, res) => {
module.exports = async (req, res) => {
try {
const questions = {}; // Empty object filter which matches all the documents

Expand Down
4 changes: 2 additions & 2 deletions backend/app/routes/Q&A/question/getQuestionById.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import question from '../../../models/question';
const question = require('../../../models/question');

export default async (req, res) => {
module.exports = async (req, res) => {
try {
const { questionId } = req.body; // Getting question id from body
const result = await question.findOne({ _id: questionId }); // Find the question corresponding to the given id
Expand Down
22 changes: 10 additions & 12 deletions backend/app/routes/Q&A/question/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

import express from "express";
import postQuestion from "./post";
import {QuestionValidationSchema , updateQuestionStatusSchema} from './@validationSchema'
import getAllQuestion from './getAllQuestion'
import getQuestionById from "./getQuestionById"
import validation from '../../../../helpers/middlewares/validation'
import upvoteQuestion from "./upvoteQuestion"
import downvoteQuestion from "./downvoteQuestion"
import updateQuestionStatus from "./updateQuestionStatus"
const router = express.Router({mergeParams:true})
const router = require('express').Router({ mergeParams: true });
const postQuestion = require('./post');
const { QuestionValidationSchema, updateQuestionStatusSchema } = require('./@validationSchema');
const getAllQuestion = require('./getAllQuestion');
const getQuestionById = require('./getQuestionById');
const validation = require('../../../../helpers/middlewares/validation');
const upvoteQuestion = require('./upvoteQuestion');
const downvoteQuestion = require('./downvoteQuestion');
const updateQuestionStatus = require('./updateQuestionStatus');

router.post('/', validation(QuestionValidationSchema), postQuestion);

Expand All @@ -27,4 +25,4 @@ router.patch('/downvote', downvoteQuestion);
// route for updating the question status
router.patch('/updateStatus', validation(updateQuestionStatusSchema), updateQuestionStatus);

export default router;
module.exports = router;
12 changes: 5 additions & 7 deletions backend/app/routes/Q&A/question/post.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
const to = require('await-to-js').default;
const question = require('../../../models/question');
const { ErrorHandler } = require('../../../../helpers/error');
const constants = require('../../../../constants');

import to from "await-to-js"
import question from '../../../models/question'
import { ErrorHandler } from "../../../../helpers/error";
import constants from "../../../../constants";


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const [err, body] = await to(question.create({ ...req.body }));

if (err) {
Expand Down
11 changes: 5 additions & 6 deletions backend/app/routes/Q&A/question/updateQuestionStatus.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const to = require("await-to-js").default;

import to from "await-to-js"
import constants from "../../../../constants";
import { ErrorHandler } from "../../../../helpers/error";
import question from "../../../models/question"
const constants = require("../../../../constants");
const { ErrorHandler } = require("../../../../helpers/error");

const question = require("../../../models/question");


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
// getting id and status from body
const id = req.body.id;
const status = req.body.status
Expand Down
12 changes: 5 additions & 7 deletions backend/app/routes/Q&A/question/upvoteQuestion.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
const to = require('await-to-js').default;
const question = require('../../../models/question');
const { ErrorHandler } = require('../../../../helpers/error');
const constants = require('../../../../constants');

import to from "await-to-js"
import question from '../../../models/question'
import { ErrorHandler } from "../../../../helpers/error";
import constants from "../../../../constants";


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const { questionId } = req.body;
const [err] = await to(question.updateOne({ _id: questionId }, { $inc: { upvotes: 1 } }));
if (err) {
Expand Down
4 changes: 2 additions & 2 deletions backend/app/routes/admin/@validationSchema/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Joi from "joi"
const Joi = require('joi');

const postSuperAdminSchema = Joi.object({
firstName: Joi.string()
Expand Down Expand Up @@ -53,7 +53,7 @@ const deleteAdminSchema = Joi.object({
id : Joi.string().min(24).max(24).required()
})

export {
module.exports = {
postSuperAdminSchema,
getAdminsSchema,
passwordChangeSchema,
Expand Down
13 changes: 6 additions & 7 deletions backend/app/routes/admin/changePassword.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import to from "await-to-js"
import argon2 from "argon2"
import Admin from '../../models/Admin';
import { ErrorHandler } from '../../../helpers/error';
import constants from '../../../constants';
const to = require('await-to-js').default;
const argon2 = require('argon2');
const Admin = require('../../models/Admin');
const { ErrorHandler } = require('../../../helpers/error');
const constants = require('../../../constants');


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const { oldPassword, newPassword } = req.body;

if (oldPassword === newPassword) {
Expand Down
11 changes: 5 additions & 6 deletions backend/app/routes/admin/createSuperAdmin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import to from "await-to-js"
import Admin from '../../models/Admin';
import {ErrorHandler} from '../../../helpers/error';
import constants from "../../../constants";
const to = require('await-to-js').default;
const Admin = require('../../models/Admin');
const { ErrorHandler } = require('../../../helpers/error');
const constants = require('../../../constants');


export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const options = { upsert: true, new: true, setDefaultsOnInsert: true };
const adminData = {
firstName: 'Root',
Expand Down
10 changes: 5 additions & 5 deletions backend/app/routes/admin/deleteAdmin.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import to from "await-to-js"
import constants from "../../../constants";
import {ErrorHandler} from "../../../helpers/error";
import Admin from "../../models/Admin";
const { default: to } = require("await-to-js");
const constants = require("../../../constants");
const { ErrorHandler } = require("../../../helpers/error");
const Admin = require("../../models/Admin");

export default async (req, res, next) => {
module.exports = async (req, res, next) => {
const { isSuperAdmin } = res.locals.decode;

if(!isSuperAdmin) {
Expand Down
Loading
Loading