aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/async.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/async.ts')
-rw-r--r--server/middlewares/async.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/server/middlewares/async.ts b/server/middlewares/async.ts
index 25b22596c..3a1bdabb8 100644
--- a/server/middlewares/async.ts
+++ b/server/middlewares/async.ts
@@ -1,12 +1,13 @@
1import { eachSeries } from 'async' 1import { eachSeries } from 'async'
2import { NextFunction, Request, RequestHandler, Response } from 'express' 2import { NextFunction, Request, RequestHandler, Response } from 'express'
3import { retryTransactionWrapper } from '../helpers/database-utils'
4import { ValidationChain } from 'express-validator' 3import { ValidationChain } from 'express-validator'
4import { ExpressPromiseHandler } from '@server/types/express'
5import { retryTransactionWrapper } from '../helpers/database-utils'
5 6
6// Syntactic sugar to avoid try/catch in express controllers 7// Syntactic sugar to avoid try/catch in express controllers
7// Thanks: https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016 8// Thanks: https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016
8 9
9export type RequestPromiseHandler = ValidationChain | ((req: Request, res: Response, next: NextFunction) => Promise<any>) 10export type RequestPromiseHandler = ValidationChain | ExpressPromiseHandler
10 11
11function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[]) { 12function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[]) {
12 return (req: Request, res: Response, next: NextFunction) => { 13 return (req: Request, res: Response, next: NextFunction) => {