diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 17:30:46 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:43:01 +0100 |
commit | a2431b7dcbc72c05101dcdbe631ff84a823aeb51 (patch) | |
tree | 09278a822905622a70ff976a75e09d99bc45639a /server/middlewares/async.ts | |
parent | fcaf1e0aa84213a1b1f1b1a44a3276eae35ebe70 (diff) | |
download | PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.tar.gz PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.tar.zst PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.zip |
Refractor validators
Diffstat (limited to 'server/middlewares/async.ts')
-rw-r--r-- | server/middlewares/async.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/server/middlewares/async.ts b/server/middlewares/async.ts index 9692f9be7..534891899 100644 --- a/server/middlewares/async.ts +++ b/server/middlewares/async.ts | |||
@@ -1,9 +1,12 @@ | |||
1 | import { Request, Response, NextFunction, RequestHandler } from 'express' | ||
2 | import { eachSeries } from 'async' | 1 | import { eachSeries } from 'async' |
2 | import { NextFunction, Request, RequestHandler, Response } from 'express' | ||
3 | 3 | ||
4 | // Syntactic sugar to avoid try/catch in express controllers | 4 | // Syntactic sugar to avoid try/catch in express controllers |
5 | // Thanks: https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016 | 5 | // Thanks: https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016 |
6 | function asyncMiddleware (fun: RequestHandler | RequestHandler[]) { | 6 | |
7 | export type RequestPromiseHandler = (req: Request, res: Response, next: NextFunction) => Promise<any> | ||
8 | |||
9 | function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[]) { | ||
7 | return (req: Request, res: Response, next: NextFunction) => { | 10 | return (req: Request, res: Response, next: NextFunction) => { |
8 | if (Array.isArray(fun) === true) { | 11 | if (Array.isArray(fun) === true) { |
9 | return eachSeries(fun as RequestHandler[], (f, cb) => { | 12 | return eachSeries(fun as RequestHandler[], (f, cb) => { |