]>
Commit | Line | Data |
---|---|---|
41fb13c3 C |
1 | import cors from 'cors' |
2 | import express from 'express' | |
eb7b48ce | 3 | import { handleStaticError } from '@server/middlewares' |
ea8107bf C |
4 | import { CONFIG } from '../initializers/config' |
5 | import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants' | |
65fcc311 C |
6 | |
7 | const staticRouter = express.Router() | |
8 | ||
ea8107bf | 9 | // Cors is very important to let other servers access torrent and video files |
62945f06 C |
10 | staticRouter.use(cors()) |
11 | ||
90a8bd30 | 12 | // Videos path for webseed |
65fcc311 C |
13 | staticRouter.use( |
14 | STATIC_PATHS.WEBSEED, | |
f7ce623d C |
15 | express.static(CONFIG.STORAGE.VIDEOS_DIR, { fallthrough: false }), |
16 | handleStaticError | |
65fcc311 | 17 | ) |
6040f87d | 18 | staticRouter.use( |
b9fffa29 | 19 | STATIC_PATHS.REDUNDANCY, |
f7ce623d C |
20 | express.static(CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false }), |
21 | handleStaticError | |
6040f87d C |
22 | ) |
23 | ||
09209296 C |
24 | // HLS |
25 | staticRouter.use( | |
9c6ca37f | 26 | STATIC_PATHS.STREAMING_PLAYLISTS.HLS, |
f7ce623d C |
27 | express.static(HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false }), |
28 | handleStaticError | |
09209296 C |
29 | ) |
30 | ||
65fcc311 C |
31 | // Thumbnails path for express |
32 | const thumbnailsPhysicalPath = CONFIG.STORAGE.THUMBNAILS_DIR | |
33 | staticRouter.use( | |
34 | STATIC_PATHS.THUMBNAILS, | |
f7ce623d C |
35 | express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE.SERVER, fallthrough: false }), |
36 | handleStaticError | |
65fcc311 C |
37 | ) |
38 | ||
65fcc311 C |
39 | // --------------------------------------------------------------------------- |
40 | ||
41 | export { | |
42 | staticRouter | |
43 | } |