Uecko_ERP/modules/customer-invoices/src/api/infrastructure/express/customer-invoices.routes.ts

72 lines
2.1 KiB
TypeScript
Raw Normal View History

2025-06-24 18:38:57 +00:00
import { ILogger, ModuleParams, validateRequest } from "@erp/core/api";
2025-05-04 20:06:57 +00:00
import { Application, NextFunction, Request, Response, Router } from "express";
import { Sequelize } from "sequelize";
2025-06-24 18:38:57 +00:00
import {
CreateCustomerInvoiceCommandSchema,
ListCustomerInvoicesQuerySchema,
} from "../../../common/dto";
import { buildListCustomerInvoicesController } from "../../controllers";
2025-05-04 20:06:57 +00:00
2025-06-12 06:55:17 +00:00
export const customerInvoicesRouter = (params: ModuleParams) => {
const { app, database, baseRoutePath, logger } = params as {
2025-05-04 20:06:57 +00:00
app: Application;
database: Sequelize;
baseRoutePath: string;
2025-06-12 06:55:17 +00:00
logger: ILogger;
2025-05-04 20:06:57 +00:00
};
const routes: Router = Router({ mergeParams: true });
routes.get(
"/",
//checkTabContext,
//checkUser,
2025-06-24 18:38:57 +00:00
validateRequest(ListCustomerInvoicesQuerySchema, "query"),
2025-05-04 20:06:57 +00:00
(req: Request, res: Response, next: NextFunction) => {
2025-06-11 15:13:44 +00:00
buildListCustomerInvoicesController(database).execute(req, res, next);
2025-05-04 20:06:57 +00:00
}
);
2025-05-20 10:08:24 +00:00
/*routes.get(
2025-06-12 06:55:17 +00:00
"/:customerInvoiceId",
2025-05-04 20:06:57 +00:00
//checkTabContext,
//checkUser,
2025-06-24 18:38:57 +00:00
validateRequest(GetCustomerInvoiceByIdQuerySchema, "query"),
2025-05-04 20:06:57 +00:00
(req: Request, res: Response, next: NextFunction) => {
2025-06-11 15:13:44 +00:00
buildGetCustomerInvoiceController(database).execute(req, res, next);
2025-05-04 20:06:57 +00:00
}
2025-05-20 10:08:24 +00:00
);*/
2025-05-04 20:06:57 +00:00
2025-06-24 18:38:57 +00:00
routes.post(
2025-05-04 20:06:57 +00:00
"/",
//checkTabContext,
//checkUser,
2025-06-24 18:38:57 +00:00
validateRequest(CreateCustomerInvoiceCommandSchema),
2025-05-04 20:06:57 +00:00
(req: Request, res: Response, next: NextFunction) => {
2025-06-11 15:13:44 +00:00
buildCreateCustomerInvoiceController(database).execute(req, res, next);
2025-05-04 20:06:57 +00:00
}
);
2025-06-24 18:38:57 +00:00
/*routes.put(
2025-06-12 06:55:17 +00:00
"/:customerInvoiceId",
2025-06-11 15:13:44 +00:00
validateAndParseBody(IUpdateCustomerInvoiceRequestSchema),
2025-05-04 20:06:57 +00:00
checkTabContext,
//checkUser,
(req: Request, res: Response, next: NextFunction) => {
2025-06-11 15:13:44 +00:00
buildUpdateCustomerInvoiceController().execute(req, res, next);
2025-05-04 20:06:57 +00:00
}
);
routes.delete(
2025-06-12 06:55:17 +00:00
"/:customerInvoiceId",
2025-06-11 15:13:44 +00:00
validateAndParseBody(IDeleteCustomerInvoiceRequestSchema),
2025-05-04 20:06:57 +00:00
checkTabContext,
//checkUser,
(req: Request, res: Response, next: NextFunction) => {
2025-06-11 15:13:44 +00:00
buildDeleteCustomerInvoiceController().execute(req, res, next);
2025-05-04 20:06:57 +00:00
}
);*/
2025-06-24 18:38:57 +00:00
app.use(`${baseRoutePath}/customer-invoices`, routes);
2025-05-04 20:06:57 +00:00
};