2024-05-15 19:56:22 +00:00
|
|
|
import { AuthRouter } from "@/contexts/auth";
|
|
|
|
|
import { CatalogRouter } from "@/contexts/catalog";
|
2024-05-23 15:38:41 +00:00
|
|
|
import { SalesRouter } from "@/contexts/sales/infrastructure/express";
|
2024-05-16 18:16:00 +00:00
|
|
|
import { UserRouter } from "@/contexts/users";
|
2024-05-15 19:56:22 +00:00
|
|
|
import Express from "express";
|
2024-05-19 22:04:23 +00:00
|
|
|
import { createContextMiddleware } from "./context.middleware";
|
2024-04-23 15:29:38 +00:00
|
|
|
|
2024-05-15 19:56:22 +00:00
|
|
|
export const v1Routes = () => {
|
|
|
|
|
const routes = Express.Router({ mergeParams: true });
|
2024-04-23 15:29:38 +00:00
|
|
|
|
2024-05-15 19:56:22 +00:00
|
|
|
routes.get("/hello", (req, res) => {
|
|
|
|
|
res.send("Hello world!");
|
|
|
|
|
});
|
2024-04-23 15:29:38 +00:00
|
|
|
|
2024-05-21 16:48:40 +00:00
|
|
|
routes.use((req: Express.Request, res: Express.Response, next: Express.NextFunction) => {
|
|
|
|
|
res.locals["context"] = createContextMiddleware();
|
2024-05-23 15:38:41 +00:00
|
|
|
//res.locals["middlewares"] = createMiddlewareMap();
|
2024-05-15 19:56:22 +00:00
|
|
|
|
2024-05-21 16:48:40 +00:00
|
|
|
return next();
|
|
|
|
|
});
|
2024-05-15 19:56:22 +00:00
|
|
|
routes.use((req, res, next) => {
|
2024-05-21 16:48:40 +00:00
|
|
|
console.log(`[${new Date().toLocaleTimeString()}] Incoming request to ${req.path}`);
|
2024-05-15 19:56:22 +00:00
|
|
|
next();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AuthRouter(routes);
|
2024-05-16 18:16:00 +00:00
|
|
|
UserRouter(routes);
|
2024-05-15 19:56:22 +00:00
|
|
|
CatalogRouter(routes);
|
2024-05-23 15:38:41 +00:00
|
|
|
SalesRouter(routes);
|
2024-05-15 19:56:22 +00:00
|
|
|
|
|
|
|
|
return routes;
|
|
|
|
|
};
|