Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 0 additions & 34 deletions .eslintrc.js

This file was deleted.

33 changes: 33 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"env": {
"es2021": true,
"node": true,
"mocha": true
},
"extends": [
"standard",
"plugin:mocha/recommended",
"plugin:security/recommended",
"plugin:prettier/recommended"
],
"plugins": ["mocha", "security", "prettier"],
"parserOptions": {
"ecmaVersion": 13,
"sourceType": "module"
},
"globals": {
"config": "readonly",
"logger": "readonly"
},
"rules": {
"no-trailing-spaces": "error",
"consistent-return": "error",
"no-console": "error",
"import/extensions": ["error", "always"],
"import/no-commonjs": "error",
"mocha/no-skipped-tests": "error",
"mocha/no-exclusive-tests": "error",
"prettier/prettier": "error"
},
"ignorePatterns": ["public/*", "dist/*"]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,6 @@ dist

# Local config file
config/local.js
config/local.cjs

package-lock.json
package-lock.json
2 changes: 1 addition & 1 deletion .mocharc.js → .mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
module.exports = {
timeout: "5000",
extension: ["ts", "js"],
require: "ts-node/register",
require: ["ts-node/register/transpile-only"]
};
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The following project structure should be followed:
| | |-- services
| |-- utils // Utility functions to be used while testing
|-- utils // Files containing utility functions
| |-- logger.js
| |-- logger
|-- .github
| |-- workflows
| |-- // Github actions files
Expand Down
35 changes: 0 additions & 35 deletions app.js

This file was deleted.

37 changes: 37 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import createError from "http-errors";
import express from "express";
import { isMulterError, multerErrorHandling } from "./utils/multer.js";

// Attach response headers
import { responseHeaders } from "./middlewares/responseHeaders.js";

// import app middlewares
import { middleware } from "./middlewares/index.js";

// import routes
import { appRoutes } from "./routes/index.js";
import logger from "./utils/logger.js";

const app = express();

// Add Middlewares, routes
middleware(app);
app.use("/", responseHeaders, appRoutes);

// catch 404 and forward to error handler
app.use(function (req, res, next) {
next(createError(404));
});

// error handler
app.use(function (err, req, res, next) {
if (isMulterError(err)) {
return multerErrorHandling(err, req, res, next);
}
console.error(err); // TODO: add logger here
return res.boom.boomify(err, {
statusCode: err.statusCode,
});
});

export default app;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*
* Documentation: https://github.com/lorenwest/node-config/wiki/Environment-Variables
*/
// @ts-ignore
// eslint-disable-next-line import/no-commonjs
module.exports = {
port: {
__name: "PORT",
Expand Down
2 changes: 2 additions & 0 deletions config/default.js → config/default.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/

const NODE_ENV = process.env.NODE_ENV;
// @ts-ignore
// eslint-disable-next-line import/no-commonjs
module.exports = {
port: 3000,
enableFileLogs: true,
Expand Down
2 changes: 2 additions & 0 deletions config/development.js → config/development.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
const port = 3000;
const localUrl = `http://localhost:${port}`;

// @ts-ignore
// eslint-disable-next-line import/no-commonjs
module.exports = {
port: port,
enableFileLogs: false,
Expand Down
2 changes: 2 additions & 0 deletions config/production.js → config/production.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Set the environment specific config in this file.
* Defaults set from default.js
*/
// @ts-ignore
// eslint-disable-next-line import/no-commonjs
module.exports = {
discordUnverifiedRoleId: "1103047289330745386",
discordDeveloperRoleId: "915490782939582485",
Expand Down
2 changes: 2 additions & 0 deletions config/staging.js → config/staging.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Set the environment specific config in this file.
* Defaults set from default.js
*/
// @ts-ignore
// eslint-disable-next-line import/no-commonjs
module.exports = {
discordUnverifiedRoleId: "1120875993771544687",
discordDeveloperRoleId: "1121445071213056071",
Expand Down
2 changes: 1 addition & 1 deletion constants/answers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const ANSWER_STATUS = {
REJECTED: "REJECTED",
}

module.exports = { ANSWER_STATUS }
export { ANSWER_STATUS };
2 changes: 1 addition & 1 deletion constants/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const API_RESPONSE_MESSAGES = {
APPLICATION_RETURN_SUCCESS: "Applications returned successfully",
};

module.exports = { APPLICATION_STATUS_TYPES, API_RESPONSE_MESSAGES };
export { APPLICATION_STATUS_TYPES, API_RESPONSE_MESSAGES };
4 changes: 1 addition & 3 deletions constants/authorities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const AUTHORITIES = {
export const AUTHORITIES = {
SUPERUSER: "super_user",
MEMBER: "member",
USER: "user",
};

module.exports = { AUTHORITIES };
5 changes: 1 addition & 4 deletions constants/badges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,4 @@ const SUCCESS_MESSAGES = {
},
};

module.exports = {
ERROR_MESSAGES,
SUCCESS_MESSAGES,
};
export { ERROR_MESSAGES, SUCCESS_MESSAGES };
14 changes: 7 additions & 7 deletions constants/bot.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const CLOUDFLARE_WORKER = "Cloudflare Worker";
const BAD_TOKEN = "BAD.JWT.TOKEN";
const CRON_JOB_HANDLER = "Cron Job Handler";
const DISCORD_SERVICE = "Discord Service";
export const CLOUDFLARE_WORKER = "Cloudflare Worker";
export const BAD_TOKEN = "BAD.JWT.TOKEN";
export const CRON_JOB_HANDLER = "Cron Job Handler";
export const DISCORD_SERVICE = "Discord Service";

const Services = {
export const Services = {
CLOUDFLARE_WORKER: CLOUDFLARE_WORKER,
CRON_JOB_HANDLER: CRON_JOB_HANDLER,
};

const DiscordServiceHeader = {
export const DiscordServiceHeader = {
name: "x-service-name"
}

module.exports = { CLOUDFLARE_WORKER, BAD_TOKEN, CRON_JOB_HANDLER, Services, DISCORD_SERVICE, DiscordServiceHeader };
export default { CLOUDFLARE_WORKER, BAD_TOKEN, CRON_JOB_HANDLER, Services, DISCORD_SERVICE, DiscordServiceHeader };
2 changes: 1 addition & 1 deletion constants/cacheKeys.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const ALL_TASKS = "cache:ALL-TASKS";

module.exports = { ALL_TASKS };
export { ALL_TASKS };
8 changes: 4 additions & 4 deletions constants/cloudflareCache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const MAX_CACHE_PURGE_COUNT = 3;
const CLOUDFLARE_ZONE_ID = config.get("cloudflare.CLOUDFLARE_ZONE_ID");
const CLOUDFLARE_PURGE_CACHE_API = `https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache`;
import config from 'config';

module.exports = { MAX_CACHE_PURGE_COUNT, CLOUDFLARE_PURGE_CACHE_API };
export const MAX_CACHE_PURGE_COUNT = 3;
export const CLOUDFLARE_ZONE_ID = config.get("cloudflare.CLOUDFLARE_ZONE_ID");
export const CLOUDFLARE_PURGE_CACHE_API = `https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache`;
2 changes: 1 addition & 1 deletion constants/cloudinary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
PROFILE: {
FOLDER: "/profile/",
TAGS: ["profile", "user"],
Expand Down
6 changes: 1 addition & 5 deletions constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ const HEADERS_FOR_SSE = {
"Cache-Control": "no-cache",
};

module.exports = {
DOCUMENT_WRITE_SIZE,
daysOfWeek,
HEADERS_FOR_SSE,
};
export { DOCUMENT_WRITE_SIZE, daysOfWeek, HEADERS_FOR_SSE };
22 changes: 10 additions & 12 deletions constants/errorMessages.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
module.exports = {
INTERNAL_SERVER_ERROR: "An internal server error occurred",
SOMETHING_WENT_WRONG: "Something went wrong. Please try again or contact admin",
ONLY_IMAGE_SUPPORTED: "Only image/jpeg, image/png supported",
ONLY_ONE_FILE_ALLOWED: "Only one file allowed",
DATA_ADDED_SUCCESSFULLY: "User Device Info added successfully!",
USER_DATA_ALREADY_PRESENT: "The authentication document has already been created",
BAD_REQUEST: "BAD_REQUEST",
INVALID_QUERY_PARAM: "Invalid Query Parameters Passed",
FILE_TOO_LARGE: (size) => `File too large, max accepted size is ${size} MB`,
USER_DOES_NOT_EXIST_ERROR: "User does not exist!",
};
export const INTERNAL_SERVER_ERROR = "An internal server error occurred";
export const SOMETHING_WENT_WRONG = "Something went wrong. Please try again or contact admin";
export const ONLY_IMAGE_SUPPORTED = "Only image/jpeg, image/png supported";
export const ONLY_ONE_FILE_ALLOWED = "Only one file allowed";
export const DATA_ADDED_SUCCESSFULLY = "User Device Info added successfully!";
export const USER_DATA_ALREADY_PRESENT = "The authentication document has already been created";
export const BAD_REQUEST = "BAD_REQUEST";
export const INVALID_QUERY_PARAM = "Invalid Query Parameters Passed";
export const FILE_TOO_LARGE = (size: number) => `File too large, max accepted size is ${size} MB`;
export const USER_DOES_NOT_EXIST_ERROR = "User does not exist!";
2 changes: 1 addition & 1 deletion constants/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ const EVENT_ROLES = {
GUEST: "guest",
};

module.exports = { API_100MS_BASE_URL, GET_ALL_EVENTS_LIMIT_MIN, UNWANTED_PROPERTIES_FROM_100MS, EVENT_ROLES };
export { API_100MS_BASE_URL, GET_ALL_EVENTS_LIMIT_MIN, UNWANTED_PROPERTIES_FROM_100MS, EVENT_ROLES };
4 changes: 1 addition & 3 deletions constants/extensionRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ const EXTENSION_REQUEST_STATUS = {
DENIED: "DENIED",
};

module.exports = {
EXTENSION_REQUEST_STATUS,
};
export { EXTENSION_REQUEST_STATUS };
4 changes: 1 addition & 3 deletions constants/external-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ const EXTERNAL_ACCOUNTS_POST_ACTIONS = {
DISCORD_USERS_SYNC: "discord-users-sync",
};

module.exports = {
EXTERNAL_ACCOUNTS_POST_ACTIONS,
};
export { EXTERNAL_ACCOUNTS_POST_ACTIONS };
4 changes: 1 addition & 3 deletions constants/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const BATCH_SIZE_IN_CLAUSE = 30; // since only 30 comparision values are allowed in 'in' clause

module.exports = {
BATCH_SIZE_IN_CLAUSE,
};
export { BATCH_SIZE_IN_CLAUSE };
2 changes: 1 addition & 1 deletion constants/imageVerificationTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const IMAGE_VERIFICATION_TYPES = ["profile", "discord"];

module.exports = { IMAGE_VERIFICATION_TYPES };
export { IMAGE_VERIFICATION_TYPES };
4 changes: 1 addition & 3 deletions constants/items.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module.exports = {
TYPES: ["TASK", "USER"],
};
export const TYPES = ["TASK", "USER"];
2 changes: 1 addition & 1 deletion constants/logs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { REQUEST_LOG_TYPE } from "./requests";
import { REQUEST_LOG_TYPE } from "./requests.js";

export const logType = {
PROFILE_DIFF_APPROVED: "PROFILE_DIFF_APPROVED",
Expand Down
2 changes: 1 addition & 1 deletion constants/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ const RESPONSE_MESSAGES = {
RESOURCE_ALREADY_TRACKED,
};

module.exports = { RESPONSE_MESSAGES };
export { RESPONSE_MESSAGES };
6 changes: 2 additions & 4 deletions constants/multer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
module.exports = {
FILE_SIZE_1MB: 1_000_000, // in bytes, 1000000 bytes = 1MB
PROFILE_FILE_SIZE: 2_000_000, // Limiting profile upload size to 2MB
};
export const FILE_SIZE_1MB = 1_000_000; // in bytes, 1000000 bytes = 1MB
export const PROFILE_FILE_SIZE = 2_000_000; // Limiting profile upload size to 2MB
2 changes: 1 addition & 1 deletion constants/profileDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const profileDiffStatus = {
PENDING: "PENDING",
};

module.exports = { profileDiffStatus };
export { profileDiffStatus };
Loading
Loading