]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/controllers/static.ts
Fix error logging
[github/Chocobozzz/PeerTube.git] / server / controllers / static.ts
1 import * as express from 'express'
2 import * as cors from '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 }