Skip to content
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
6 changes: 6 additions & 0 deletions api/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>} 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
Expand Down
5 changes: 5 additions & 0 deletions api/src/validators/affix-confirmation.validator.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions api/src/validators/affix.validator.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
17 changes: 17 additions & 0 deletions api/src/validators/auth.validator.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -22,6 +30,9 @@ export default checkSchema({
bail: true,
},
},
/**
* The password field in the request body.
*/
password: {
in: "body",
isString: {
Expand All @@ -30,6 +41,9 @@ export default checkSchema({
},
trim: true,
},
/**
* The region field in the request body.
*/
region: {
in: "body",
isString: {
Expand All @@ -43,6 +57,9 @@ export default checkSchema({
bail: true,
},
},
/**
* The 2FA token field in the request body.
*/
tfa_token: {
optional: true,
in: "body",
Expand Down
5 changes: 5 additions & 0 deletions api/src/validators/cms.validator.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions api/src/validators/destination-stack.validator.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions api/src/validators/file-format.validator.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions api/src/validators/fileformat-confirmation.validator.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions api/src/validators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 5 additions & 0 deletions api/src/validators/project.validator.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down