diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-05-15 22:22:03 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-05-20 09:57:40 +0200 |
commit | 65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch) | |
tree | 4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/controllers/static.ts | |
parent | d5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff) | |
download | PeerTube-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.ts | 49 |
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 @@ | |||
1 | import express = require('express') | ||
2 | import cors = require('cors') | ||
3 | |||
4 | import { | ||
5 | CONFIG, | ||
6 | STATIC_MAX_AGE, | ||
7 | STATIC_PATHS | ||
8 | } from '../initializers' | ||
9 | |||
10 | const staticRouter = express.Router() | ||
11 | |||
12 | /* | ||
13 | Cors is very important to let other pods access torrent and video files | ||
14 | */ | ||
15 | |||
16 | const torrentsPhysicalPath = CONFIG.STORAGE.TORRENTS_DIR | ||
17 | staticRouter.use( | ||
18 | STATIC_PATHS.TORRENTS, | ||
19 | cors(), | ||
20 | express.static(torrentsPhysicalPath, { maxAge: STATIC_MAX_AGE }) | ||
21 | ) | ||
22 | |||
23 | // Videos path for webseeding | ||
24 | const videosPhysicalPath = CONFIG.STORAGE.VIDEOS_DIR | ||
25 | staticRouter.use( | ||
26 | STATIC_PATHS.WEBSEED, | ||
27 | cors(), | ||
28 | express.static(videosPhysicalPath, { maxAge: STATIC_MAX_AGE }) | ||
29 | ) | ||
30 | |||
31 | // Thumbnails path for express | ||
32 | const thumbnailsPhysicalPath = CONFIG.STORAGE.THUMBNAILS_DIR | ||
33 | staticRouter.use( | ||
34 | STATIC_PATHS.THUMBNAILS, | ||
35 | express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE }) | ||
36 | ) | ||
37 | |||
38 | // Video previews path for express | ||
39 | const previewsPhysicalPath = CONFIG.STORAGE.PREVIEWS_DIR | ||
40 | staticRouter.use( | ||
41 | STATIC_PATHS.PREVIEWS, | ||
42 | express.static(previewsPhysicalPath, { maxAge: STATIC_MAX_AGE }) | ||
43 | ) | ||
44 | |||
45 | // --------------------------------------------------------------------------- | ||
46 | |||
47 | export { | ||
48 | staticRouter | ||
49 | } | ||