aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/static.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-15 22:22:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-20 09:57:40 +0200
commit65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch)
tree4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/controllers/static.ts
parentd5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff)
downloadPeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip
First typescript iteration
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}