diff --git a/api/src/database.ts b/api/src/database.ts index 859a3b0e..8682aac4 100644 --- a/api/src/database.ts +++ b/api/src/database.ts @@ -2,6 +2,12 @@ import logger from "./utils/logger.js"; import fs from "fs"; +/** + * Connects to the database. + * If the database folder does not exist, it creates it. + * @returns {Promise} A promise that resolves when the connection is successful. + * @throws {Error} If there is an error while connecting to the database. + */ const connectToDatabase = async () => { try { //check if the database folder exists diff --git a/api/src/validators/affix-confirmation.validator.ts b/api/src/validators/affix-confirmation.validator.ts index 5bbea21a..837393da 100644 --- a/api/src/validators/affix-confirmation.validator.ts +++ b/api/src/validators/affix-confirmation.validator.ts @@ -1,6 +1,11 @@ import { checkSchema } from "express-validator"; import { VALIDATION_ERRORS } from "../constants/index.js"; +/** + * Validates the affix_confirmation field in the request body. + * + * @returns {Object} The validation schema for the affix_confirmation field. + */ export default checkSchema({ affix_confirmation: { in: "body", diff --git a/api/src/validators/affix.validator.ts b/api/src/validators/affix.validator.ts index 62cf4af8..1dc70b5c 100644 --- a/api/src/validators/affix.validator.ts +++ b/api/src/validators/affix.validator.ts @@ -1,6 +1,11 @@ import { checkSchema } from "express-validator"; import { VALIDATION_ERRORS, AFFIX_REGEX } from "../constants/index.js"; +/** + * Validates the 'affix' property in the request body. + * + * @returns {Object} The validation schema for the 'affix' property. + */ export default checkSchema({ affix: { in: "body", diff --git a/api/src/validators/auth.validator.ts b/api/src/validators/auth.validator.ts index 8ba097fe..2148ae87 100644 --- a/api/src/validators/auth.validator.ts +++ b/api/src/validators/auth.validator.ts @@ -1,7 +1,15 @@ import { checkSchema } from "express-validator"; import { VALIDATION_ERRORS, CS_REGIONS } from "../constants/index.js"; +/** + * Validates the authentication request body. + * + * @returns {Object} The validation schema for the authentication request body. + */ export default checkSchema({ + /** + * The email field in the request body. + */ email: { in: "body", isString: { @@ -22,6 +30,9 @@ export default checkSchema({ bail: true, }, }, + /** + * The password field in the request body. + */ password: { in: "body", isString: { @@ -30,6 +41,9 @@ export default checkSchema({ }, trim: true, }, + /** + * The region field in the request body. + */ region: { in: "body", isString: { @@ -43,6 +57,9 @@ export default checkSchema({ bail: true, }, }, + /** + * The 2FA token field in the request body. + */ tfa_token: { optional: true, in: "body", diff --git a/api/src/validators/cms.validator.ts b/api/src/validators/cms.validator.ts index 3b04f062..7d391949 100644 --- a/api/src/validators/cms.validator.ts +++ b/api/src/validators/cms.validator.ts @@ -1,6 +1,11 @@ import { checkSchema } from "express-validator"; import { VALIDATION_ERRORS } from "../constants/index.js"; +/** + * Validates the 'legacy_cms' field in the request body. + * + * @returns {Object} The validation schema for 'legacy_cms' field. + */ export default checkSchema({ legacy_cms: { in: "body", diff --git a/api/src/validators/destination-stack.validator.ts b/api/src/validators/destination-stack.validator.ts index 3c48f193..e2043997 100644 --- a/api/src/validators/destination-stack.validator.ts +++ b/api/src/validators/destination-stack.validator.ts @@ -1,6 +1,11 @@ import { checkSchema } from "express-validator"; import { VALIDATION_ERRORS } from "../constants/index.js"; +/** + * Validates the destination stack API key. + * + * @returns {Object} The validation schema for the destination stack API key. + */ export default checkSchema({ stack_api_key: { in: "body", diff --git a/api/src/validators/file-format.validator.ts b/api/src/validators/file-format.validator.ts index 22aa06b1..a8755511 100644 --- a/api/src/validators/file-format.validator.ts +++ b/api/src/validators/file-format.validator.ts @@ -1,6 +1,11 @@ import { checkSchema } from "express-validator"; import { VALIDATION_ERRORS } from "../constants/index.js"; +/** + * Validates the file format. + * + * @returns {Object} The validation schema for the file format. + */ export default checkSchema({ file_format: { in: "body", diff --git a/api/src/validators/fileformat-confirmation.validator.ts b/api/src/validators/fileformat-confirmation.validator.ts index 19926096..4beb54b3 100644 --- a/api/src/validators/fileformat-confirmation.validator.ts +++ b/api/src/validators/fileformat-confirmation.validator.ts @@ -1,6 +1,11 @@ import { checkSchema } from "express-validator"; import { VALIDATION_ERRORS } from "../constants/index.js"; +/** + * Validates the file format confirmation field in the request body. + * + * @returns {Object} The validation schema for the file format confirmation field. + */ export default checkSchema({ fileformat_confirmation: { in: "body", diff --git a/api/src/validators/index.ts b/api/src/validators/index.ts index 269e5893..1dd1e154 100644 --- a/api/src/validators/index.ts +++ b/api/src/validators/index.ts @@ -10,6 +10,11 @@ import affixValidator from "./affix.validator.js"; import affixConfirmationValidator from "./affix-confirmation.validator.js"; import fileformatConfirmationValidator from "./fileformat-confirmation.validator.js"; +/** + * Middleware function that validates the request based on the specified route. + * @param route - The route to determine the validator to use. + * @returns The middleware function that performs the validation. + */ export default (route: string = "") => asyncRouter(async (req: Request, res: Response, next: NextFunction) => { const appValidators = { diff --git a/api/src/validators/project.validator.ts b/api/src/validators/project.validator.ts index d3e97973..2df47ac1 100644 --- a/api/src/validators/project.validator.ts +++ b/api/src/validators/project.validator.ts @@ -1,6 +1,11 @@ import { checkSchema } from "express-validator"; import { VALIDATION_ERRORS } from "../constants/index.js"; +/** + * Validates the project data. + * + * @returns {Object} The validation schema for the project data. + */ export default checkSchema({ name: { in: "body",