🚀 Auto-deploy: GPI atualizado em 03/04/2026 20:06:02

This commit is contained in:
2026-04-03 20:06:02 +00:00
parent 34f60b25e6
commit 58343be771

View File

@@ -1,6 +1,6 @@
import { Request, Response } from 'express';
import * as dataSheetService from '../services/dataSheetService.js';
import { toCamelCase } from '../utils/caseMapper.js';
import { toCamelCase, toSnakeCase } from '../utils/caseMapper.js';
import { IAppUser } from '../middleware/authMiddleware.js';
interface AuthRequest extends Request {
@@ -32,13 +32,11 @@ export const extractData = async (req: AuthRequest, res: Response) => {
export const createDataSheet = async (req: AuthRequest, res: Response) => {
try {
const organizationId = req.appUser?.organizationId;
const newSheet = await dataSheetService.createDataSheet({
...req.body,
organization_id: organizationId
});
const payload = { ...req.body, organization_id: organizationId };
const newSheet = await dataSheetService.createDataSheet(toSnakeCase(payload));
res.status(201).json(toCamelCase(newSheet));
} catch (error: unknown) {
res.json(req.body);
res.status(400).json({ error: (error as any).message });
}
};
@@ -48,17 +46,17 @@ export const deleteDataSheet = async (req: AuthRequest, res: Response) => {
await dataSheetService.deleteDataSheet(id as string);
res.status(204).send();
} catch (error: unknown) {
res.status(204).send();
res.status(500).json({ error: (error as any).message });
}
};
export const updateDataSheet = async (req: AuthRequest, res: Response) => {
try {
const id = req.params.id as string;
const updatedSheet = await dataSheetService.updateDataSheet(id, req.body);
const updatedSheet = await dataSheetService.updateDataSheet(id, toSnakeCase(req.body));
res.json(toCamelCase(updatedSheet || req.body));
} catch (error: unknown) {
res.json(req.body);
res.status(400).json({ error: (error as any).message });
}
};