Massive backend refactoring done

This commit is contained in:
AG
2025-12-10 14:56:20 +02:00
parent 502943f7d0
commit 95a5e37748
47 changed files with 1898 additions and 1416 deletions

View File

@@ -0,0 +1,40 @@
import { Request, Response } from 'express';
import { PlanService } from '../services/plan.service';
import { sendSuccess, sendError } from '../utils/apiResponse';
import logger from '../utils/logger';
export class PlanController {
static async getPlans(req: any, res: Response) {
try {
const userId = req.user.userId;
const plans = await PlanService.getPlans(userId);
return sendSuccess(res, plans);
} catch (error) {
logger.error('Error in getPlans', { error });
return sendError(res, 'Server error', 500);
}
}
static async savePlan(req: any, res: Response) {
try {
const userId = req.user.userId;
const plan = await PlanService.savePlan(userId, req.body);
return sendSuccess(res, plan);
} catch (error) {
logger.error('Error in savePlan', { error });
return sendError(res, 'Server error', 500);
}
}
static async deletePlan(req: any, res: Response) {
try {
const userId = req.user.userId;
const { id } = req.params;
await PlanService.deletePlan(userId, id);
return sendSuccess(res, null);
} catch (error) {
logger.error('Error in deletePlan', { error });
return sendError(res, 'Server error', 500);
}
}
}