From b2808150eeeb8c75e1fb324d1589ec1af18a4567 Mon Sep 17 00:00:00 2001 From: Saransh Balyan Date: Wed, 7 Aug 2024 00:50:28 +0530 Subject: [PATCH] refractor --- Routes/dev.unprotected.routes.js | 2 +- User/Controllers/auth.controller.js | 2 +- User/Controllers/superAdmin.controller.js | 2 +- User/Controllers/user.controller.js | 2 +- User/Seed/superadmin.seed.js | 2 +- User/Service/database.service.js | 2 +- User/Service/user.service.js | 2 +- .../Database/mongo.connection.js | 0 Utils/Middlewares/default.middleware.js | 2 +- Utils/Middlewares/jwt.middleware.js | 2 +- swagger.js => Utils/Swagger/swagger.js | 0 swagger.json => Utils/Swagger/swagger.json | 0 index.js | 2 +- package.json | 162 +++++++++--------- 14 files changed, 91 insertions(+), 91 deletions(-) rename mongo.connection.js => Utils/Database/mongo.connection.js (100%) rename swagger.js => Utils/Swagger/swagger.js (100%) rename swagger.json => Utils/Swagger/swagger.json (100%) diff --git a/Routes/dev.unprotected.routes.js b/Routes/dev.unprotected.routes.js index 068b287..4953f1c 100644 --- a/Routes/dev.unprotected.routes.js +++ b/Routes/dev.unprotected.routes.js @@ -4,7 +4,7 @@ import { createRequire } from 'module'; import passport from 'passport'; import swaggerUi from 'swagger-ui-express'; const require = createRequire(import.meta.url); -const swaggerFile = require('../swagger.json'); +const swaggerFile = require('../Utils/Swagger/swagger.json'); // Swagger const Router = express.Router(); diff --git a/User/Controllers/auth.controller.js b/User/Controllers/auth.controller.js index ce95543..10db907 100644 --- a/User/Controllers/auth.controller.js +++ b/User/Controllers/auth.controller.js @@ -2,7 +2,7 @@ import pkg from 'jsonwebtoken'; import errorConstants from '#constants/error.constant.js'; import successConstants from '#constants/success.contant.js'; -import { getTenantDB } from '#root/mongo.connection.js'; +import { getTenantDB } from '#utils/Database/mongo.connection.js'; // import { createBucket } from '#storage/Service/awsService.js'; import getError from '#utils/error.js'; // import { createToken, getTokenError } from '#utils/jwt.js'; diff --git a/User/Controllers/superAdmin.controller.js b/User/Controllers/superAdmin.controller.js index dce6bf1..ac897db 100644 --- a/User/Controllers/superAdmin.controller.js +++ b/User/Controllers/superAdmin.controller.js @@ -1,5 +1,5 @@ import errorContstants from '#constants/error.constant.js'; -import { getTenantDB } from '#root/mongo.connection.js'; +import { getTenantDB } from '#utils/Database/mongo.connection.js'; import { deleteCustomer } from '#user/Service/database.service.js'; import { getCachedKeys } from '#utils/Cache/cache.service.js'; import cache from '#utils/Cache/index.js'; diff --git a/User/Controllers/user.controller.js b/User/Controllers/user.controller.js index adf0af0..788945c 100644 --- a/User/Controllers/user.controller.js +++ b/User/Controllers/user.controller.js @@ -1,7 +1,7 @@ // import successConstants from '#constants/success.contant.js'; import mongoose from 'mongoose'; -import { getTenantDB } from '#root/mongo.connection.js'; +import { getTenantDB } from '#utils/Database/mongo.connection.js'; /* * import { s3, uploadFile } from '#storage/Service/awsService.js'; */ diff --git a/User/Seed/superadmin.seed.js b/User/Seed/superadmin.seed.js index 4979f78..b526edd 100644 --- a/User/Seed/superadmin.seed.js +++ b/User/Seed/superadmin.seed.js @@ -1,4 +1,4 @@ -import { getTenantDB } from '#root/mongo.connection.js'; +import { getTenantDB } from '#utils/Database/mongo.connection.js'; const seedSuperAdmin = async () => { const conn = await getTenantDB(); diff --git a/User/Service/database.service.js b/User/Service/database.service.js index a422609..43fe8f3 100644 --- a/User/Service/database.service.js +++ b/User/Service/database.service.js @@ -1,5 +1,5 @@ import errorContstants from '#constants/error.constant.js'; -import { getTenantDB, removeTenantDB } from '#root/mongo.connection.js'; +import { getTenantDB, removeTenantDB } from '#utils/Database/mongo.connection.js'; // import { deleteBucket } from '#storage/Service/awsService.js'; const deleteCustomer = async (tenant) => { diff --git a/User/Service/user.service.js b/User/Service/user.service.js index 23a9b94..7420031 100644 --- a/User/Service/user.service.js +++ b/User/Service/user.service.js @@ -1,5 +1,5 @@ import errorContstants from '#constants/error.constant.js'; -import { getTenantDB } from '#root/mongo.connection.js'; +import { getTenantDB } from '#utils/Database/mongo.connection.js'; import cache from '#utils/Cache/index.js'; import { createToken } from '#utils/jwt.js'; diff --git a/mongo.connection.js b/Utils/Database/mongo.connection.js similarity index 100% rename from mongo.connection.js rename to Utils/Database/mongo.connection.js diff --git a/Utils/Middlewares/default.middleware.js b/Utils/Middlewares/default.middleware.js index 795f54e..297b28d 100644 --- a/Utils/Middlewares/default.middleware.js +++ b/Utils/Middlewares/default.middleware.js @@ -1,4 +1,4 @@ -import { getTenantDB } from '#root/mongo.connection.js'; +import { getTenantDB } from '#utils/Database/mongo.connection.js'; const defaultMiddleware = () => async (req, _res, next) => { try { diff --git a/Utils/Middlewares/jwt.middleware.js b/Utils/Middlewares/jwt.middleware.js index fdcdda5..9deabec 100644 --- a/Utils/Middlewares/jwt.middleware.js +++ b/Utils/Middlewares/jwt.middleware.js @@ -1,7 +1,7 @@ import pkg from 'jsonwebtoken'; import errorContstants from '#constants/error.constant.js'; -import { getTenantDB } from '#root/mongo.connection.js'; +import { getTenantDB } from '#utils/Database/mongo.connection.js'; import cache from '#utils/Cache/index.js'; import getError from '#utils/error.js'; diff --git a/swagger.js b/Utils/Swagger/swagger.js similarity index 100% rename from swagger.js rename to Utils/Swagger/swagger.js diff --git a/swagger.json b/Utils/Swagger/swagger.json similarity index 100% rename from swagger.json rename to Utils/Swagger/swagger.json diff --git a/index.js b/index.js index 405cee3..2a363e7 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ import helmet from 'helmet'; import defaultMiddleware from '#middlewares/default.middleware.js'; import { setupCors, setupErrorInterceptor, setupRateLimiter, setupResponseInterceptor, setupTimeout, setupValidationErrorInterceptor } from '#middlewares/server.middleware.js'; -import { getTenantDB } from '#root/mongo.connection.js'; +import { getTenantDB } from '#utils/Database/mongo.connection.js'; import seedSuperAdmin from '#user/Seed/superadmin.seed.js'; import morgalApiLogger from '#utils/Logger/api.logger.js'; import overrideConsole from '#utils/Logger/console.logger.js'; diff --git a/package.json b/package.json index 975f610..60c02f8 100644 --- a/package.json +++ b/package.json @@ -1,83 +1,83 @@ { - "name": "startex", - "version": "2.1", - "description": "now with mongo", - "main": "index.js", - "type": "module", - "scripts": { - "start": "node --env-file=env/.env --env-file=env/.env.database --env-file=env/.env.logger --env-file=env/.env.server --env-file=env/.env.token --env-file=env/.env.mailer --env-file=env/.env.passport --no-warnings --trace-warnings --experimental-permission --allow-child-process --allow-fs-read=/ --watch index.js", - "swagger": "node swagger.js", - "lint": "eslint . --quiet --cache --cache-location=node_modules/.cache/eslint", - "lint-fix": "eslint . --fix", - "clean": "rimraf node_modules && npm install", - "test": "node Test/Api/index.js" - }, - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-s3": "^3.360.0", - "@aws-sdk/lib-storage": "^3.620.1", - "@hapi/joi": "^17.1.1", - "axios": "^1.7.3", - "bcryptjs": "^2.4.3", - "body-parser": "^1.20.0", - "chalk": "^5.3.0", - "cors": "^2.8.5", - "crypto": "^1.0.1", - "express": "^4.18.1", - "express-fileupload": "^1.4.0", - "express-rate-limit": "^7.1.5", - "express-validation": "^4.1.1", - "helmet": "^7.1.0", - "jsonwebtoken": "^9.0.2", - "lodash": "^4.17.21", - "mongoose": "^8.5.2", - "morgan-body": "^2.6.8", - "node-cache": "^5.1.2", - "nodemailer": "^6.9.14", - "passport": "^0.7.0", - "passport-github2": "^0.1.12", - "passport-google-oauth20": "^2.0.0", - "passport-http": "^0.3.0", - "passport-linkedin-oauth2": "^2.0.0", - "passport-microsoft": "^2.1.0", - "swagger-autogen": "^2.23.7", - "swagger-ui-express": "^5.0.1" - }, - "devDependencies": { - "eslint": "^8.57.0", - "eslint-config-standard": "^17.1.0", - "eslint-import-resolver-alias": "^1.1.2", - "eslint-plugin-autofix": "^2.1.0", - "eslint-plugin-deprecation": "^3.0.0", - "eslint-plugin-eqeqeq-fix": "^1.0.3", - "eslint-plugin-import": "^2.29.1", - "eslint-plugin-promise": "^6.6.0", - "eslint-plugin-react": "^7.34.1", - "eslint-plugin-react-hooks": "^4.6.2", - "eslint-plugin-react-redux": "^4.1.0", - "eslint-plugin-simple-import-sort": "^12.1.1", - "eslint-plugin-sonar": "^0.14.1", - "eslint-plugin-sonarjs": "^0.25.1", - "eslint-plugin-sort-keys-fix": "^1.1.2", - "eslint-plugin-unused-imports": "^3.1.0" - }, - "overrides": { - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.0.0" - }, - "imports": { - "#validations/*": "./Utils/Validations/*", - "#middlewares/*": "./Utils/Middlewares/*", - "#constants/*": "./Utils/Constants/*", - "#utils/*": "./Utils/*", - "#storage/*": "./Storage/*", - "#user/*": "./User/*", - "#project/*": "./Project/*", - "#controllers/*": "./Controllers/*", - "#routes/*": "./Routes/*", - "#encryption/*": "./Encryption/*", - "#scheduler/*": "./Scheduler/*", - "#root/*": "./*" - } + "name": "startex", + "version": "2.1", + "description": "now with mongo", + "main": "index.js", + "type": "module", + "scripts": { + "start": "node --env-file=env/.env --env-file=env/.env.database --env-file=env/.env.logger --env-file=env/.env.server --env-file=env/.env.token --env-file=env/.env.mailer --env-file=env/.env.passport --no-warnings --trace-warnings --experimental-permission --allow-child-process --allow-fs-read=/ --watch index.js", + "swagger": "node ./Utils/Swagger/swagger.js", + "lint": "eslint . --quiet --cache --cache-location=node_modules/.cache/eslint", + "lint-fix": "eslint . --fix", + "clean": "rimraf node_modules && npm install", + "test": "node Test/Api/index.js" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@aws-sdk/client-s3": "^3.360.0", + "@aws-sdk/lib-storage": "^3.620.1", + "@hapi/joi": "^17.1.1", + "axios": "^1.7.3", + "bcryptjs": "^2.4.3", + "body-parser": "^1.20.0", + "chalk": "^5.3.0", + "cors": "^2.8.5", + "crypto": "^1.0.1", + "express": "^4.18.1", + "express-fileupload": "^1.4.0", + "express-rate-limit": "^7.1.5", + "express-validation": "^4.1.1", + "helmet": "^7.1.0", + "jsonwebtoken": "^9.0.2", + "lodash": "^4.17.21", + "mongoose": "^8.5.2", + "morgan-body": "^2.6.8", + "node-cache": "^5.1.2", + "nodemailer": "^6.9.14", + "passport": "^0.7.0", + "passport-github2": "^0.1.12", + "passport-google-oauth20": "^2.0.0", + "passport-http": "^0.3.0", + "passport-linkedin-oauth2": "^2.0.0", + "passport-microsoft": "^2.1.0", + "swagger-autogen": "^2.23.7", + "swagger-ui-express": "^5.0.1" + }, + "devDependencies": { + "eslint": "^8.57.0", + "eslint-config-standard": "^17.1.0", + "eslint-import-resolver-alias": "^1.1.2", + "eslint-plugin-autofix": "^2.1.0", + "eslint-plugin-deprecation": "^3.0.0", + "eslint-plugin-eqeqeq-fix": "^1.0.3", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-promise": "^6.6.0", + "eslint-plugin-react": "^7.34.1", + "eslint-plugin-react-hooks": "^4.6.2", + "eslint-plugin-react-redux": "^4.1.0", + "eslint-plugin-simple-import-sort": "^12.1.1", + "eslint-plugin-sonar": "^0.14.1", + "eslint-plugin-sonarjs": "^0.25.1", + "eslint-plugin-sort-keys-fix": "^1.1.2", + "eslint-plugin-unused-imports": "^3.1.0" + }, + "overrides": { + "@typescript-eslint/eslint-plugin": "^7.6.0", + "@typescript-eslint/parser": "^7.0.0" + }, + "imports": { + "#validations/*": "./Utils/Validations/*", + "#middlewares/*": "./Utils/Middlewares/*", + "#constants/*": "./Utils/Constants/*", + "#utils/*": "./Utils/*", + "#storage/*": "./Storage/*", + "#user/*": "./User/*", + "#project/*": "./Project/*", + "#controllers/*": "./Controllers/*", + "#routes/*": "./Routes/*", + "#encryption/*": "./Encryption/*", + "#scheduler/*": "./Scheduler/*", + "#root/*": "./*" + } }