diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-24 15:48:47 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-07-25 11:00:41 +0200 |
commit | 523990dbe63b533a598732fc5927e7505458e260 (patch) | |
tree | 90fe188f15f3c378de78345a8811e04f9410d684 /server/middlewares | |
parent | 4511437e19d2ce521e28f8417512d47773207da4 (diff) | |
download | PeerTube-523990dbe63b533a598732fc5927e7505458e260.tar.gz PeerTube-523990dbe63b533a598732fc5927e7505458e260.tar.zst PeerTube-523990dbe63b533a598732fc5927e7505458e260.zip |
Upgrade server dependencies
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/async.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/server/middlewares/async.ts b/server/middlewares/async.ts index f770bc120..25b22596c 100644 --- a/server/middlewares/async.ts +++ b/server/middlewares/async.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { eachSeries } from 'async' | 1 | import { eachSeries } from 'async' |
2 | import { NextFunction, Request, RequestHandler, Response } from 'express' | 2 | import { NextFunction, Request, RequestHandler, Response } from 'express' |
3 | import { retryTransactionWrapper } from '../helpers/database-utils' | 3 | import { retryTransactionWrapper } from '../helpers/database-utils' |
4 | import { ValidationChain } from 'express-validator' | ||
4 | 5 | ||
5 | // Syntactic sugar to avoid try/catch in express controllers | 6 | // Syntactic sugar to avoid try/catch in express controllers |
6 | // Thanks: https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016 | 7 | // Thanks: https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016 |
7 | 8 | ||
8 | export type RequestPromiseHandler = (req: Request, res: Response, next: NextFunction) => Promise<any> | 9 | export type RequestPromiseHandler = ValidationChain | ((req: Request, res: Response, next: NextFunction) => Promise<any>) |
9 | 10 | ||
10 | function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[]) { | 11 | function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[]) { |
11 | return (req: Request, res: Response, next: NextFunction) => { | 12 | return (req: Request, res: Response, next: NextFunction) => { |
@@ -21,7 +22,7 @@ function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[]) | |||
21 | } | 22 | } |
22 | } | 23 | } |
23 | 24 | ||
24 | function asyncRetryTransactionMiddleware (fun: RequestPromiseHandler) { | 25 | function asyncRetryTransactionMiddleware (fun: (req: Request, res: Response, next: NextFunction) => Promise<any>) { |
25 | return (req: Request, res: Response, next: NextFunction) => { | 26 | return (req: Request, res: Response, next: NextFunction) => { |
26 | return Promise.resolve( | 27 | return Promise.resolve( |
27 | retryTransactionWrapper(fun, req, res, next) | 28 | retryTransactionWrapper(fun, req, res, next) |