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.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
new file mode 100644
index 000000000..51f75c57e
--- /dev/null
+++ b/server/controllers/static.ts
@@ -0,0 +1,49 @@
1import express = require('express')
2import cors = require('cors')
3
4import {
5 CONFIG,
6 STATIC_MAX_AGE,
7 STATIC_PATHS
8} from '../initializers'
9
10const staticRouter = express.Router()
11
12/*
13 Cors is very important to let other pods access torrent and video files
14*/
15
16const torrentsPhysicalPath = CONFIG.STORAGE.TORRENTS_DIR
17staticRouter.use(
18 STATIC_PATHS.TORRENTS,
19 cors(),
20 express.static(torrentsPhysicalPath, { maxAge: STATIC_MAX_AGE })
21)
22
23// Videos path for webseeding
24const videosPhysicalPath = CONFIG.STORAGE.VIDEOS_DIR
25staticRouter.use(
26 STATIC_PATHS.WEBSEED,
27 cors(),
28 express.static(videosPhysicalPath, { maxAge: STATIC_MAX_AGE })
29)
30
31// Thumbnails path for express
32const thumbnailsPhysicalPath = CONFIG.STORAGE.THUMBNAILS_DIR
33staticRouter.use(
34 STATIC_PATHS.THUMBNAILS,
35 express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE })
36)
37
38// Video previews path for express
39const previewsPhysicalPath = CONFIG.STORAGE.PREVIEWS_DIR
40staticRouter.use(
41 STATIC_PATHS.PREVIEWS,
42 express.static(previewsPhysicalPath, { maxAge: STATIC_MAX_AGE })
43)
44
45// ---------------------------------------------------------------------------
46
47export {
48 staticRouter
49}