fix: global camelCase mapping for all technical data tables
This commit is contained in:
@@ -2,6 +2,7 @@ import { Request, Response } from 'express';
|
||||
import * as projectService from '../services/projectService.js';
|
||||
import { IAppUser } from '../middleware/authMiddleware.js';
|
||||
import { notificationService } from '../services/notificationService.js';
|
||||
import { toCamelCase } from '../utils/caseMapper.js';
|
||||
|
||||
interface AuthRequest extends Request {
|
||||
appUser?: IAppUser;
|
||||
@@ -11,7 +12,7 @@ export const createProject = async (req: AuthRequest, res: Response) => {
|
||||
try {
|
||||
const organizationId = req.appUser?.organizationId;
|
||||
const project = await projectService.createProject({ ...req.body, organizationId });
|
||||
res.status(201).json(project);
|
||||
res.status(201).json(toCamelCase(project));
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Unknown error';
|
||||
res.status(500).json({ error: message });
|
||||
@@ -23,14 +24,11 @@ export const getAllProjects = async (req: AuthRequest, res: Response) => {
|
||||
const organizationId = req.appUser?.organizationId;
|
||||
const isGlobalAdmin = req.appUser?.email === 'admtracksteel@gmail.com';
|
||||
const { status } = req.query;
|
||||
console.log('getAllProjects controller:', { organizationId, isGlobalAdmin, status });
|
||||
const projects = await projectService.getAllProjects(organizationId, isGlobalAdmin, status as string);
|
||||
console.log('getAllProjects result:', projects?.length);
|
||||
res.json(projects);
|
||||
res.json(toCamelCase(projects));
|
||||
} catch (error: unknown) {
|
||||
console.error('Error in getAllProjects controller:', error);
|
||||
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
||||
console.log('Sending error response:', message);
|
||||
res.status(500).json({ error: message });
|
||||
}
|
||||
};
|
||||
@@ -40,7 +38,7 @@ export const archiveProject = async (req: AuthRequest, res: Response) => {
|
||||
const organizationId = req.appUser?.organizationId;
|
||||
const isGlobalAdmin = req.appUser?.email === 'admtracksteel@gmail.com';
|
||||
const project = await projectService.archiveProject(req.params.id as string, organizationId, isGlobalAdmin);
|
||||
res.json(project);
|
||||
res.json(toCamelCase(project));
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Unknown error';
|
||||
res.status(500).json({ error: message });
|
||||
@@ -51,7 +49,7 @@ export const getDashboardProjects = async (req: AuthRequest, res: Response) => {
|
||||
try {
|
||||
const organizationId = req.appUser?.organizationId;
|
||||
const projects = await projectService.getDashboardProjects(organizationId);
|
||||
res.json(projects);
|
||||
res.json(toCamelCase(projects));
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Unknown error';
|
||||
res.status(500).json({ error: message });
|
||||
@@ -61,7 +59,7 @@ export const getDashboardProjects = async (req: AuthRequest, res: Response) => {
|
||||
export const getProjectById = async (req: AuthRequest, res: Response) => {
|
||||
try {
|
||||
const project = await projectService.getProjectById(req.params.id as string);
|
||||
res.json(project);
|
||||
res.json(toCamelCase(project));
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Unknown error';
|
||||
res.status(404).json({ error: message });
|
||||
@@ -83,7 +81,7 @@ export const updateProject = async (req: AuthRequest, res: Response) => {
|
||||
});
|
||||
}
|
||||
|
||||
res.json(project);
|
||||
res.json(toCamelCase(project));
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Unknown error';
|
||||
res.status(500).json({ error: message });
|
||||
|
||||
Reference in New Issue
Block a user