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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@contentstack/cli-utilities": "^1.17.1",
"@contentstack/json-rte-serializer": "^3.0.5",
"@contentstack/marketplace-sdk": "^1.5.0",
"axios": "^1.12.0",
"axios": "^1.13.5",
"chokidar": "^3.6.0",
"cors": "^2.8.5",
"dayjs": "^1.11.18",
Expand Down
22 changes: 18 additions & 4 deletions api/src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ import { authService } from "../services/auth.service.js";
* @param res - The response object.
*/
const login = async (req: Request, res: Response) => {
const resp = await authService.login(req);
res.status(resp?.status).json(resp?.data);
try {
const resp = await authService.login(req);
res.status(resp?.status || 500).json(resp?.data);
} catch (error: any) {
const statusCode = error?.statusCode || error?.status || 500;
res.status(statusCode).json({
message: error?.message || 'Login failed',
});
}
};

/**
Expand All @@ -19,8 +26,15 @@ const login = async (req: Request, res: Response) => {
* @param res - The response object.
*/
const RequestSms = async (req: Request, res: Response) => {
const resp = await authService.requestSms(req);
res.status(resp.status).json(resp.data);
try {
const resp = await authService.requestSms(req);
res.status(resp?.status || 500).json(resp?.data);
} catch (error: any) {
const statusCode = error?.statusCode || error?.status || 500;
res.status(statusCode).json({
message: error?.message || 'SMS request failed',
});
}
};

export const authController = {
Expand Down
25 changes: 10 additions & 15 deletions api/src/models/project-lowdb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { JSONFile } from "lowdb/node";
import LowWithLodash from "../utils/lowdb-lodash.utils.js";
import { JSONFile } from 'lowdb/node';
import LowWithLodash from '../utils/lowdb-lodash.utils.js';

/**
* Represents the LegacyCMS object.
Expand Down Expand Up @@ -28,14 +28,6 @@ interface LegacyCMS {
is_localPath: boolean;
}

interface StackDetails {
uid: string;
label: string;
master_locale: string;
created_at: string;
isNewStack: boolean;
}

/**
* Represents an execution log.
*/
Expand Down Expand Up @@ -71,11 +63,12 @@ interface Project {
isNewStack: boolean;
newStackId: string;
stackDetails: [];
mapperKeys: {};
mapperKeys: object;
extract_path: string;
isMigrationStarted: boolean;
isMigrationCompleted:boolean;
isMigrationCompleted: boolean;
migration_execution: boolean;
taxonomies?: any[];
}

interface ProjectDocument {
Expand All @@ -88,8 +81,10 @@ const defaultData: ProjectDocument = { projects: [] };
* Represents the database instance for the project.
*/
const db = new LowWithLodash(
new JSONFile<ProjectDocument>(path.join(process.cwd(), "database", "project.json")),
defaultData
new JSONFile<ProjectDocument>(
path.join(process.cwd(), 'database', 'project.json'),
),
defaultData,
);

export default db;
export default db;
8 changes: 4 additions & 4 deletions api/src/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const login = async (req: Request): Promise<LoginServiceType> => {
);

return {
data: err?.response?.data,
status: err?.response?.status,
data: err?.response?.data || { message: err?.message || HTTP_TEXTS.INTERNAL_ERROR },
status: err?.response?.status || err?.status || HTTP_CODES.SERVER_ERROR,
};
}
if (res?.data?.user?.organizations === undefined) {
Expand Down Expand Up @@ -171,8 +171,8 @@ const requestSms = async (req: Request): Promise<LoginServiceType> => {
);

return {
data: err?.response?.data,
status: err?.response?.status,
data: err?.response?.data || { message: err?.message || HTTP_TEXTS.INTERNAL_ERROR },
status: err?.response?.status || err?.status || HTTP_CODES.SERVER_ERROR,
};
}

Expand Down
Loading