brief-05-back/src/routes/catalog/catalogRouter.ts
Mathis 9bdcdef88f
feat(routes): apply routers and rename files
- Routers `AuthRouter`, `CatalogRouter`, and `RentRouter` are used in the application in `src/app.ts` with error handling.
- The router files under `src/routes/auth`, `src/routes/catalog`, and `src/routes/rent` are renamed to `authRouter.ts`, `catalogRouter.ts`, `rentRouter.ts` respectively.
- The default exports in these router files have been updated to reflect their new names.
- The imports in `src/routes/index.ts` are updated according to the renamed files.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 12:21:13 +02:00

42 lines
1.0 KiB
TypeScript

import express, {type Router} from "express";
import AdminGuard from "@validators/AdminGuard";
import UserGuard from "@validators/UserGuard";
import CategoryController from "@controllers/category.controller";
const CatalogRouter: Router = express.Router();
//-- MODELS >>
CatalogRouter.route('/model/new').get(AdminGuard)
CatalogRouter.route('/model/all').get()
CatalogRouter.route('/model/:modelSlug')
.get(UserGuard)
.patch(AdminGuard)
.delete(AdminGuard)
//-- 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)
CatalogRouter.route('/brand/all').get()
CatalogRouter.route('/brand/:brandSlug')
.get(UserGuard)
.patch(AdminGuard)
.delete(AdminGuard)
export default CatalogRouter;