2025-05-20 10:08:24 +00:00
|
|
|
import { ModuleParams } from "@erp/core";
|
2025-05-04 20:06:57 +00:00
|
|
|
import { Application, NextFunction, Request, Response, Router } from "express";
|
|
|
|
|
import { Sequelize } from "sequelize";
|
2025-05-20 10:08:24 +00:00
|
|
|
import { buildListInvoicesController } from "../../presentation";
|
2025-05-04 20:06:57 +00:00
|
|
|
|
|
|
|
|
export const invoicesRouter = (params: ModuleParams) => {
|
|
|
|
|
const { app, database, baseRoutePath } = params as {
|
|
|
|
|
app: Application;
|
|
|
|
|
database: Sequelize;
|
|
|
|
|
baseRoutePath: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const routes: Router = Router({ mergeParams: true });
|
|
|
|
|
|
|
|
|
|
routes.get(
|
|
|
|
|
"/",
|
|
|
|
|
//checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
|
|
|
|
buildListInvoicesController(database).execute(req, res, next);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2025-05-20 10:08:24 +00:00
|
|
|
/*routes.get(
|
2025-05-04 20:06:57 +00:00
|
|
|
"/:invoiceId",
|
|
|
|
|
//checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
|
|
|
|
buildGetInvoiceController(database).execute(req, res, next);
|
|
|
|
|
}
|
2025-05-20 10:08:24 +00:00
|
|
|
);*/
|
2025-05-04 20:06:57 +00:00
|
|
|
|
|
|
|
|
/*routes.post(
|
|
|
|
|
"/",
|
|
|
|
|
validateAndParseBody(ICreateInvoiceRequestSchema, { sanitize: false }),
|
|
|
|
|
//checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
|
|
|
|
buildCreateInvoiceController(database).execute(req, res, next);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
routes.put(
|
|
|
|
|
"/:invoiceId",
|
|
|
|
|
validateAndParseBody(IUpdateInvoiceRequestSchema),
|
|
|
|
|
checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
|
|
|
|
buildUpdateInvoiceController().execute(req, res, next);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
routes.delete(
|
|
|
|
|
"/:invoiceId",
|
|
|
|
|
validateAndParseBody(IDeleteInvoiceRequestSchema),
|
|
|
|
|
checkTabContext,
|
|
|
|
|
//checkUser,
|
|
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
|
|
|
|
buildDeleteInvoiceController().execute(req, res, next);
|
|
|
|
|
}
|
|
|
|
|
);*/
|
|
|
|
|
|
|
|
|
|
app.use(`${baseRoutePath}/invoices`, routes);
|
|
|
|
|
};
|