aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/static.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-11-25 12:32:21 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-11-25 14:21:41 +0100
commit79530164b6c8f96a6ccf6d33b591d565f1575e67 (patch)
treef610a32ad5cb7151247af12dcc1534d4adb7de37 /server/controllers/static.js
parent8e124f999b8cf7d461ef7a923711d18edc69d84c (diff)
downloadPeerTube-79530164b6c8f96a6ccf6d33b591d565f1575e67.tar.gz
PeerTube-79530164b6c8f96a6ccf6d33b591d565f1575e67.tar.zst
PeerTube-79530164b6c8f96a6ccf6d33b591d565f1575e67.zip
Server: move static/client routes in controllers/
Diffstat (limited to 'server/controllers/static.js')
-rw-r--r--server/controllers/static.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/server/controllers/static.js b/server/controllers/static.js
new file mode 100644
index 000000000..a91ff044d
--- /dev/null
+++ b/server/controllers/static.js
@@ -0,0 +1,46 @@
1'use strict'
2
3const express = require('express')
4const cors = require('cors')
5
6const constants = require('../initializers/constants')
7
8const router = express.Router()
9
10/*
11 Cors is very important to let other pods access torrent and video files
12*/
13
14const torrentsPhysicalPath = constants.CONFIG.STORAGE.TORRENTS_DIR
15router.use(
16 constants.STATIC_PATHS.TORRENTS,
17 cors(),
18 express.static(torrentsPhysicalPath, { maxAge: constants.STATIC_MAX_AGE })
19)
20
21// Videos path for webseeding
22const videosPhysicalPath = constants.CONFIG.STORAGE.VIDEOS_DIR
23router.use(
24 constants.STATIC_PATHS.WEBSEED,
25 cors(),
26 express.static(videosPhysicalPath, { maxAge: constants.STATIC_MAX_AGE })
27)
28
29// Thumbnails path for express
30const thumbnailsPhysicalPath = constants.CONFIG.STORAGE.THUMBNAILS_DIR
31router.use(
32 constants.STATIC_PATHS.THUMBNAILS,
33 express.static(thumbnailsPhysicalPath, { maxAge: constants.STATIC_MAX_AGE })
34)
35
36// Video previews path for express
37const previewsPhysicalPath = constants.CONFIG.STORAGE.PREVIEWS_DIR
38router.use(
39 constants.STATIC_PATHS.PREVIEWS,
40 express.static(previewsPhysicalPath, { maxAge: constants.STATIC_MAX_AGE })
41)
42
43// ---------------------------------------------------------------------------
44
45module.exports = router
46