]>
Commit | Line | Data |
---|---|---|
1 | import cors from 'cors' | |
2 | import express from 'express' | |
3 | import { handleStaticError } from '@server/middlewares' | |
4 | import { CONFIG } from '../initializers/config' | |
5 | import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants' | |
6 | ||
7 | const staticRouter = express.Router() | |
8 | ||
9 | // Cors is very important to let other servers access torrent and video files | |
10 | staticRouter.use(cors()) | |
11 | ||
12 | // Videos path for webseed | |
13 | staticRouter.use( | |
14 | STATIC_PATHS.WEBSEED, | |
15 | express.static(CONFIG.STORAGE.VIDEOS_DIR, { fallthrough: false }), | |
16 | handleStaticError | |
17 | ) | |
18 | staticRouter.use( | |
19 | STATIC_PATHS.REDUNDANCY, | |
20 | express.static(CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false }), | |
21 | handleStaticError | |
22 | ) | |
23 | ||
24 | // HLS | |
25 | staticRouter.use( | |
26 | STATIC_PATHS.STREAMING_PLAYLISTS.HLS, | |
27 | express.static(HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false }), | |
28 | handleStaticError | |
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.SERVER, fallthrough: false }), | |
36 | handleStaticError | |
37 | ) | |
38 | ||
39 | // --------------------------------------------------------------------------- | |
40 | ||
41 | export { | |
42 | staticRouter | |
43 | } |