- 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>
42 lines
1.0 KiB
TypeScript
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; |