feat: Implement async handler for routes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import { authenticateUser } from '../../../../helpers/authentication.js';
|
||||
import { authorizeAdmin } from '../../../../helpers/authorization.js';
|
||||
import { checkIsEnterprise } from '../../../../helpers/check-is-enterprise.js';
|
||||
@@ -11,7 +12,7 @@ router.get(
|
||||
authenticateUser,
|
||||
authorizeAdmin,
|
||||
checkIsEnterprise,
|
||||
getAdminAppAuthClientsAction
|
||||
asyncHandler(getAdminAppAuthClientsAction)
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import { authenticateUser } from '../../../../helpers/authentication.js';
|
||||
import { authorizeAdmin } from '../../../../helpers/authorization.js';
|
||||
import { checkIsEnterprise } from '../../../../helpers/check-is-enterprise.js';
|
||||
@@ -11,7 +12,7 @@ router.get(
|
||||
authenticateUser,
|
||||
authorizeAdmin,
|
||||
checkIsEnterprise,
|
||||
getPermissionsCatalogAction
|
||||
asyncHandler(getPermissionsCatalogAction)
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import { authenticateUser } from '../../../../helpers/authentication.js';
|
||||
import { authorizeAdmin } from '../../../../helpers/authorization.js';
|
||||
import { checkIsEnterprise } from '../../../../helpers/check-is-enterprise.js';
|
||||
@@ -12,7 +13,7 @@ router.get(
|
||||
authenticateUser,
|
||||
authorizeAdmin,
|
||||
checkIsEnterprise,
|
||||
getRolesAction
|
||||
asyncHandler(getRolesAction)
|
||||
);
|
||||
|
||||
router.get(
|
||||
@@ -20,7 +21,7 @@ router.get(
|
||||
authenticateUser,
|
||||
authorizeAdmin,
|
||||
checkIsEnterprise,
|
||||
getRoleAction
|
||||
asyncHandler(getRoleAction)
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import { authenticateUser } from '../../../../helpers/authentication.js';
|
||||
import { authorizeAdmin } from '../../../../helpers/authorization.js';
|
||||
import { checkIsEnterprise } from '../../../../helpers/check-is-enterprise.js';
|
||||
@@ -12,7 +13,7 @@ router.get(
|
||||
authenticateUser,
|
||||
authorizeAdmin,
|
||||
checkIsEnterprise,
|
||||
getSamlAuthProvidersAction
|
||||
asyncHandler(getSamlAuthProvidersAction)
|
||||
);
|
||||
|
||||
router.get(
|
||||
@@ -20,7 +21,7 @@ router.get(
|
||||
authenticateUser,
|
||||
authorizeAdmin,
|
||||
checkIsEnterprise,
|
||||
getSamlAuthProviderAction
|
||||
asyncHandler(getSamlAuthProviderAction)
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import { authenticateUser } from '../../../../helpers/authentication.js';
|
||||
import { authorizeAdmin } from '../../../../helpers/authorization.js';
|
||||
import { checkIsEnterprise } from '../../../../helpers/check-is-enterprise.js';
|
||||
@@ -12,7 +13,7 @@ router.get(
|
||||
authenticateUser,
|
||||
authorizeAdmin,
|
||||
checkIsEnterprise,
|
||||
getUsersAction
|
||||
asyncHandler(getUsersAction)
|
||||
);
|
||||
|
||||
router.get(
|
||||
@@ -20,7 +21,7 @@ router.get(
|
||||
authenticateUser,
|
||||
authorizeAdmin,
|
||||
checkIsEnterprise,
|
||||
getUserAction
|
||||
asyncHandler(getUserAction)
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import { authenticateUser } from '../../../helpers/authentication.js';
|
||||
import { checkIsEnterprise } from '../../../helpers/check-is-enterprise.js';
|
||||
import getAppAuthClientAction from '../../../controllers/api/v1/app-auth-clients/get-app-auth-client.js';
|
||||
@@ -9,7 +10,7 @@ router.get(
|
||||
'/:appAuthClientId',
|
||||
authenticateUser,
|
||||
checkIsEnterprise,
|
||||
getAppAuthClientAction
|
||||
asyncHandler(getAppAuthClientAction)
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import versionAction from '../../../controllers/api/v1/automatisch/version.js';
|
||||
import notificationsAction from '../../../controllers/api/v1/automatisch/notifications.js';
|
||||
import infoAction from '../../../controllers/api/v1/automatisch/info.js';
|
||||
@@ -6,9 +7,9 @@ import licenseAction from '../../../controllers/api/v1/automatisch/license.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/version', versionAction);
|
||||
router.get('/notifications', notificationsAction);
|
||||
router.get('/info', infoAction);
|
||||
router.get('/license', licenseAction);
|
||||
router.get('/version', asyncHandler(versionAction));
|
||||
router.get('/notifications', asyncHandler(notificationsAction));
|
||||
router.get('/info', asyncHandler(infoAction));
|
||||
router.get('/license', asyncHandler(licenseAction));
|
||||
|
||||
export default router;
|
||||
|
@@ -1,10 +1,16 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import { authenticateUser } from '../../../helpers/authentication.js';
|
||||
import { authorizeUser } from '../../../helpers/authorization.js';
|
||||
import getFlowAction from '../../../controllers/api/v1/flows/get-flow.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/:flowId', authenticateUser, authorizeUser, getFlowAction);
|
||||
router.get(
|
||||
'/:flowId',
|
||||
authenticateUser,
|
||||
authorizeUser,
|
||||
asyncHandler(getFlowAction)
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
@@ -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 getPlansAction from '../../../controllers/api/v1/payment/get-plans.ee.js';
|
||||
@@ -6,7 +7,18 @@ import getPaddleInfoAction from '../../../controllers/api/v1/payment/get-paddle-
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/plans', authenticateUser, checkIsCloud, getPlansAction);
|
||||
router.get('/paddle-info', authenticateUser, checkIsCloud, getPaddleInfoAction);
|
||||
router.get(
|
||||
'/plans',
|
||||
authenticateUser,
|
||||
checkIsCloud,
|
||||
asyncHandler(getPlansAction)
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/paddle-info',
|
||||
authenticateUser,
|
||||
checkIsCloud,
|
||||
asyncHandler(getPaddleInfoAction)
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
@@ -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;
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import indexAction from '../controllers/healthcheck/index.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/', indexAction);
|
||||
router.get('/', asyncHandler(indexAction));
|
||||
|
||||
export default router;
|
||||
|
@@ -1,16 +1,9 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import webhooksHandler from '../controllers/paddle/webhooks.ee.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
const exposeError = (handler) => async (req, res, next) => {
|
||||
try {
|
||||
await handler(req, res, next);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
};
|
||||
|
||||
router.post('/webhooks', exposeError(webhooksHandler));
|
||||
router.post('/webhooks', asyncHandler(webhooksHandler));
|
||||
|
||||
export default router;
|
||||
|
Reference in New Issue
Block a user