From a883c8c538fa46a1904ebc41a9a7efc4fb77518a Mon Sep 17 00:00:00 2001 From: zulfikarrosadi Date: Fri, 15 Nov 2024 14:43:44 +0700 Subject: [PATCH] feat(role): add adminAccess middleware to protected endpoint --- src/routes.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/routes.ts b/src/routes.ts index 5f54264..446c3bf 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -10,6 +10,7 @@ import AuthHandler from './auth/handler' import AuthRepository from './auth/repository' import AuthService from './auth/service' import multer from './lib/upload' +import adminAccess from './middlewares/adminAccess' import formDataParse from './middlewares/formDataParser' import ProductHandler from './product/handler' import ProductRepository from './product/repository' @@ -46,6 +47,7 @@ router.get('/users', userHandler.getCurrentUser) router.post( '/products', formDataParse(multer.array('images', 5)), + adminAccess, validateInput(createProduct), productHandler.createProduct, ) @@ -53,6 +55,7 @@ router.get('/products', productHandler.getProducts) router.put( '/products/:id', formDataParse(multer.array('images', 5)), + adminAccess, validateInput(updateProduct), productHandler.updateProductById, )