]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/controllers/static.ts
Merge branch 'feature/otp' into develop
[github/Chocobozzz/PeerTube.git] / server / controllers / static.ts
CommitLineData
41fb13c3
C
1import cors from 'cors'
2import express from 'express'
eb7b48ce 3import { handleStaticError } from '@server/middlewares'
ea8107bf
C
4import { CONFIG } from '../initializers/config'
5import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants'
65fcc311
C
6
7const staticRouter = express.Router()
8
ea8107bf 9// Cors is very important to let other servers access torrent and video files
62945f06
C
10staticRouter.use(cors())
11
90a8bd30 12// Videos path for webseed
65fcc311
C
13staticRouter.use(
14 STATIC_PATHS.WEBSEED,
f7ce623d
C
15 express.static(CONFIG.STORAGE.VIDEOS_DIR, { fallthrough: false }),
16 handleStaticError
65fcc311 17)
6040f87d 18staticRouter.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
25staticRouter.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
32const thumbnailsPhysicalPath = CONFIG.STORAGE.THUMBNAILS_DIR
33staticRouter.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
41export {
42 staticRouter
43}