Files
brief-05-back/src/routes/catalog/catalogRouter.ts
Mathis a6593cb76f feat(all): refactor code for readability and simplicity
The controllers, services, routes, and others have been updated to reduce code complexity and improve readability. Changes include removing unnecessary lines, replacing long function signatures with simpler versions, and streamlining condition checks and logger statements.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 11:03:28 +02:00

42 lines
1.4 KiB
TypeScript

import BrandController from "@controllers/brand.controller";
import CategoryController from "@controllers/category.controller";
import ModelController from "@controllers/model.controller";
import AdminGuard from "@validators/AdminGuard";
import UserGuard from "@validators/UserGuard";
import express, { type Router } from "express";
const CatalogRouter: Router = express.Router();
//-- MODELS >>
CatalogRouter.route("/model/new").get(AdminGuard, ModelController.create);
CatalogRouter.route("/model/all").get(ModelController.getAll);
CatalogRouter.route("/model/:modelSlug")
.get(UserGuard, ModelController.getBySlug)
.patch(AdminGuard, ModelController.update)
.delete(AdminGuard, ModelController.delete);
//-- CATEGORY >>
CatalogRouter.route("/category/new").get(AdminGuard, CategoryController.create);
CatalogRouter.route("/category/all").get(CategoryController.getAll);
CatalogRouter.route("/category/:categorySlug")
.get(UserGuard, CategoryController.getBySlug)
.patch(AdminGuard, CategoryController.update)
.delete(AdminGuard, CategoryController.delete);
//-- BRAND >>
CatalogRouter.route("/brand/new").post(AdminGuard, BrandController.create);
CatalogRouter.route("/brand/all").get(BrandController.getAll);
CatalogRouter.route("/brand/:brandSlug")
.get(UserGuard, BrandController.getBySlug)
.patch(AdminGuard, BrandController.update)
.delete(AdminGuard, BrandController.delete);
export default CatalogRouter;