feat: Implement async handler for routes

This commit is contained in:
Faruk AYDIN
2024-02-26 01:02:21 +01:00
parent 51abd74304
commit 8b4aee1afa
14 changed files with 151 additions and 30 deletions

View File

@@ -1,4 +1,5 @@
import { Router } from 'express';
import asyncHandler from 'express-async-handler';
import { authenticateUser } from '../../../helpers/authentication.js';
import checkIsCloud from '../../../helpers/check-is-cloud.js';
import getCurrentUserAction from '../../../controllers/api/v1/users/get-current-user.js';
@@ -7,14 +8,19 @@ import getInvoicesAction from '../../../controllers/api/v1/users/get-invoices.ee
const router = Router();
router.get('/me', authenticateUser, getCurrentUserAction);
router.get('/invoices', authenticateUser, checkIsCloud, getInvoicesAction);
router.get('/me', authenticateUser, asyncHandler(getCurrentUserAction));
router.get(
'/invoices',
authenticateUser,
checkIsCloud,
asyncHandler(getInvoicesAction)
);
router.get(
'/:userId/trial',
authenticateUser,
checkIsCloud,
getUserTrialAction
asyncHandler(getUserTrialAction)
);
export default router;