1 import cors from 'cors'
2 import express from 'express'
3 import { CONFIG } from '../initializers/config'
4 import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants'
6 const staticRouter = express.Router()
8 // Cors is very important to let other servers access torrent and video files
9 staticRouter.use(cors())
11 // Videos path for webseed
14 express.static(CONFIG.STORAGE.VIDEOS_DIR, { fallthrough: false }) // 404 because we don't have this video
17 STATIC_PATHS.REDUNDANCY,
18 express.static(CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false }) // 404 because we don't have this video
23 STATIC_PATHS.STREAMING_PLAYLISTS.HLS,
24 express.static(HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false }) // 404 if the file does not exist
27 // Thumbnails path for express
28 const thumbnailsPhysicalPath = CONFIG.STORAGE.THUMBNAILS_DIR
30 STATIC_PATHS.THUMBNAILS,
31 express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE.SERVER, fallthrough: false }) // 404 if the file does not exist
34 // ---------------------------------------------------------------------------