Skip to content

Commit 08d8bdd

Browse files
committed
added documenting
2 parents 5815ac2 + a0c0e38 commit 08d8bdd

File tree

163 files changed

+4023
-528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+4023
-528
lines changed

api/src/config/dev.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export const devConfig = {
1010
AZURE_NA: "https://azure-na-app.contentstack.com/#!",
1111
AZURE_EU: "https://azure-eu-app.contentstack.com/#!",
1212
},
13+
LOG_FILE_PATH: process.platform === "win32" ? ".\\combine.log" : "./combine.log", // Replace with the actual path to your log file
1314
};

api/src/config/index.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ dotenv.config({
77
path: path.resolve(process.cwd(), `${process.env.NODE_ENV}.env`),
88
});
99

10+
/**
11+
* Configuration type for the application.
12+
*/
1013
export type ConfigType = {
1114
APP_TOKEN_EXP: string;
1215
APP_TOKEN_KEY: string;
1316
FILE_UPLOAD_KEY: string;
1417
PORT: string;
1518
APP_ENV: string;
1619
MONGODB_URI: string;
20+
LOG_FILE_PATH : string;
1721
CS_API: {
1822
NA: string;
1923
EU: string;
@@ -28,12 +32,36 @@ export type ConfigType = {
2832
};
2933
};
3034

35+
/**
36+
* Loads the configuration from environment variables and returns the configuration object.
37+
* @returns The configuration object.
38+
*/
3139
export const config: ConfigType = {
40+
/**
41+
* Expiration time for the application token.
42+
*/
3243
APP_TOKEN_EXP: "1d",
33-
PORT: process.env.PORT!,
34-
APP_ENV: process.env.NODE_ENV!,
44+
/**
45+
* Key used to sign the application token.
46+
*/
3547
APP_TOKEN_KEY: process.env.APP_TOKEN_KEY!,
48+
/**
49+
* Key used for file uploads.
50+
*/
3651
FILE_UPLOAD_KEY: process.env.FILE_UPLOAD_KEY!,
52+
/**
53+
* Port on which the server will listen.
54+
*/
55+
PORT: process.env.PORT!,
56+
/**
57+
* Environment in which the application is running.
58+
*/
59+
APP_ENV: process.env.NODE_ENV!,
60+
/**
61+
* MongoDB connection URI.
62+
*/
3763
MONGODB_URI: process.env.MONGODB_URI!,
64+
3865
...(process.env.NODE_ENV === "production" ? prodConfig : devConfig),
3966
};
67+

api/src/config/prod.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ export const prodConfig = {
1111
AZURE_NA: "https://azure-na-app.contentstack.com/#!",
1212
AZURE_EU: "https://azure-eu-app.contentstack.com/#!",
1313
},
14+
LOG_FILE_PATH: process.platform === "win32" ? ".\\combine.log" : "./combine.log", // Replace with the actual path to your log file
1415
};

api/src/controllers/auth.controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import { Request, Response } from "express";
22
import { authService } from "../services/auth.service.js";
33

4+
/**
5+
* Handles the login request.
6+
*
7+
* @param req The request object.
8+
* @param res The response object.
9+
*/
410
const login = async (req: Request, res: Response) => {
511
const resp = await authService.login(req);
612
res.status(resp?.status).json(resp?.data);
713
};
814

15+
/**
16+
* Handles the request for sending an SMS.
17+
*
18+
* @param req The request object.
19+
* @param res The response object.
20+
*/
921
const RequestSms = async (req: Request, res: Response) => {
1022
const resp = await authService.requestSms(req);
1123
res.status(resp.status).json(resp.data);

api/src/controllers/migration.controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import { Request, Response } from "express";
22
import { migrationService } from "../services/migration.service.js";
33

4+
/**
5+
* Creates a test stack.
6+
* @param {Request} req - The request object.
7+
* @param {Response} res - The response object.
8+
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
9+
*/
410
const createTestStack = async (req: Request, res: Response): Promise<void> => {
511
const resp = await migrationService.createTestStack(req);
612
res.status(200).json(resp);
713
};
814

15+
/**
16+
* Deletes a test stack.
17+
* @param {Request} req - The request object.
18+
* @param {Response} res - The response object.
19+
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
20+
*/
921
const deleteTestStack = async (req: Request, res: Response): Promise<void> => {
1022
const resp = await migrationService.deleteTestStack(req);
1123
res.status(200).json(resp);

api/src/controllers/org.controller.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
11
import { Request, Response } from "express";
22
import { orgService } from "../services/org.service.js";
33

4+
/**
5+
* Get all stacks
6+
* @param req - Express request object
7+
* @param res - Express response object
8+
*/
49
const getAllStacks = async (req: Request, res: Response) => {
510
const resp = await orgService.getAllStacks(req);
611
res.status(resp?.status).json(resp?.data);
712
};
813

14+
/**
15+
* Create a new stack
16+
* @param req - Express request object
17+
* @param res - Express response object
18+
*/
919
const createStack = async (req: Request, res: Response) => {
1020
const resp = await orgService.createStack(req);
1121
res.status(resp.status).json(resp.data);
1222
};
1323

24+
/**
25+
* Get all locales
26+
* @param req - Express request object
27+
* @param res - Express response object
28+
*/
1429
const getLocales = async (req: Request, res: Response) => {
1530
const resp = await orgService.getLocales(req);
1631
res.status(resp.status).json(resp.data);
1732
};
1833

34+
/**
35+
* Get stack status
36+
* @param req - Express request object
37+
* @param res - Express response object
38+
*/
1939
const getStackStatus = async (req: Request, res: Response) => {
2040
const resp = await orgService.getStackStatus(req);
2141
res.status(resp.status).json(resp.data);

api/src/controllers/projects.contentMapper.controller.ts

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,84 @@
11
import { Request, Response } from "express";
22
import { contentMapperService } from "../services/contentMapper.service.js";
3+
4+
/**
5+
* Puts test data.
6+
* @param req - The request object.
7+
* @param res - The response object.
8+
* @returns Promise<void>
9+
*/
310
const putTestData = async (req: Request, res: Response): Promise<void> => {
411
const resp = await contentMapperService.putTestData(req);
512
res.status(200).json(resp);
613
};
714

15+
/**
16+
* Gets content types.
17+
* @param req - The request object.
18+
* @param res - The response object.
19+
* @returns Promise<void>
20+
*/
821
const getContentTypes = async (req: Request, res: Response): Promise<void> => {
922
const resp = await contentMapperService.getContentTypes(req);
1023
res.status(200).json(resp);
1124
};
25+
26+
/**
27+
* Gets field mapping.
28+
* @param req - The request object.
29+
* @param res - The response object.
30+
* @returns Promise<void>
31+
*/
1232
const getFieldMapping = async (req: Request, res: Response): Promise<void> => {
1333
const resp = await contentMapperService.getFieldMapping(req);
1434
res.status(200).json(resp);
1535
};
36+
37+
/**
38+
* Gets existing content types.
39+
* @param req - The request object.
40+
* @param res - The response object.
41+
* @returns Promise<void>
42+
*/
1643
const getExistingContentTypes = async (
1744
req: Request,
1845
res: Response
1946
): Promise<void> => {
2047
const resp = await contentMapperService.getExistingContentTypes(req);
2148
res.status(201).json(resp);
2249
};
50+
51+
/**
52+
* Puts content type fields.
53+
* @param req - The request object.
54+
* @param res - The response object.
55+
* @returns Promise<void>
56+
*/
2357
const putContentTypeFields = async (
2458
req: Request,
2559
res: Response
2660
): Promise<void> => {
2761
const resp = await contentMapperService.updateContentType(req);
2862
res.status(200).json(resp);
2963
};
64+
65+
/**
66+
* Resets content type.
67+
* @param req - The request object.
68+
* @param res - The response object.
69+
* @returns Promise<void>
70+
*/
3071
const resetContentType = async (req: Request, res: Response): Promise<void> => {
3172
const resp = await contentMapperService.resetToInitialMapping(req);
3273
res.status(200).json(resp);
3374
};
34-
// TODO Will remove if not required
35-
// const removeMapping = async (req: Request, res: Response): Promise<void> => {
36-
// const resp = await contentMapperService.removeMapping(req);
37-
// res.status(200).json(resp);
38-
// };
3975

76+
/**
77+
* Removes content mapper.
78+
* @param req - The request object.
79+
* @param res - The response object.
80+
* @returns Promise<void>
81+
*/
4082
const removeContentMapper = async (
4183
req: Request,
4284
res: Response
@@ -45,6 +87,12 @@ const removeContentMapper = async (
4587
res.status(200).json(resp);
4688
};
4789

90+
/**
91+
* Gets single content types.
92+
* @param req - The request object.
93+
* @param res - The response object.
94+
* @returns Promise<void>
95+
*/
4896
const getSingleContentTypes = async (
4997
req: Request,
5098
res: Response
@@ -53,6 +101,17 @@ const getSingleContentTypes = async (
53101
res.status(201).json(resp);
54102
};
55103

104+
/**
105+
* Removes mapping.
106+
* @param req - The request object.
107+
* @param res - The response object.
108+
* @returns Promise<void>
109+
*/
110+
// const removeMapping = async (req: Request, res: Response): Promise<void> => {
111+
// const resp = await contentMapperService.removeMapping(req);
112+
// res.status(200).json(resp);
113+
// };
114+
56115
export const contentMapperController = {
57116
getContentTypes,
58117
getFieldMapping,

0 commit comments

Comments
 (0)