aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/static.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/static.ts')
-rw-r--r--server/controllers/static.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 8fbf9cc97..c7c952d6f 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -7,6 +7,7 @@ import {
7 STATIC_PATHS 7 STATIC_PATHS
8} from '../initializers' 8} from '../initializers'
9import { VideosPreviewCache } from '../lib' 9import { VideosPreviewCache } from '../lib'
10import { asyncMiddleware } from '../middlewares'
10 11
11const staticRouter = express.Router() 12const staticRouter = express.Router()
12 13
@@ -39,7 +40,7 @@ staticRouter.use(
39// Video previews path for express 40// Video previews path for express
40staticRouter.use( 41staticRouter.use(
41 STATIC_PATHS.PREVIEWS + ':uuid.jpg', 42 STATIC_PATHS.PREVIEWS + ':uuid.jpg',
42 getPreview 43 asyncMiddleware(getPreview)
43) 44)
44 45
45// --------------------------------------------------------------------------- 46// ---------------------------------------------------------------------------
@@ -50,11 +51,9 @@ export {
50 51
51// --------------------------------------------------------------------------- 52// ---------------------------------------------------------------------------
52 53
53function getPreview (req: express.Request, res: express.Response, next: express.NextFunction) { 54async function getPreview (req: express.Request, res: express.Response, next: express.NextFunction) {
54 VideosPreviewCache.Instance.getPreviewPath(req.params.uuid) 55 const path = await VideosPreviewCache.Instance.getPreviewPath(req.params.uuid)
55 .then(path => { 56 if (!path) return res.sendStatus(404)
56 if (!path) return res.sendStatus(404)
57 57
58 return res.sendFile(path, { maxAge: STATIC_MAX_AGE }) 58 return res.sendFile(path, { maxAge: STATIC_MAX_AGE })
59 })
60} 59}