// FIXME: https://github.com/nodejs/node/pull/16853
+import { VideosCaptionCache } from './server/lib/cache/videos-caption-cache'
+
require('tls').DEFAULT_ECDH_CURVE = 'auto'
import { isTestInstance } from './server/helpers/core-utils'
// Do not use barrels because we don't want to load all modules here (we need to initialize database first)
import { logger } from './server/helpers/logger'
-import { API_VERSION, CONFIG, STATIC_PATHS } from './server/initializers/constants'
+import { API_VERSION, CONFIG, STATIC_PATHS, CACHE } from './server/initializers/constants'
const missed = checkMissedConfig()
if (missed.length !== 0) {
// ----------- App -----------
-// Enable CORS
-app.use((req, res, next) => {
- // These routes have already cors
- if (
- req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 &&
- req.path.indexOf(STATIC_PATHS.WEBSEED) === -1
- ) {
- return (cors({
- origin: '*',
- exposedHeaders: 'Retry-After',
- credentials: true
- }))(req, res, next)
- }
-
- return next()
-});
+// Enable CORS for develop
+if (isTestInstance()) {
+ app.use((req, res, next) => {
+ // These routes have already cors
+ if (
+ req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 &&
+ req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 &&
+ req.path.startsWith('/api/') === false
+ ) {
+ return (cors({
+ origin: '*',
+ exposedHeaders: 'Retry-After',
+ credentials: true
+ }))(req, res, next)
+ }
+
+ return next()
+ })
+}
// For the logger
app.use(morgan('combined', {
await JobQueue.Instance.init()
// Caches initializations
- VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE)
+ VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE, CACHE.PREVIEWS.MAX_AGE)
+ VideosCaptionCache.Instance.init(CONFIG.CACHE.VIDEO_CAPTIONS.SIZE, CACHE.VIDEO_CAPTIONS.MAX_AGE)
// Enable Schedulers
BadActorFollowScheduler.Instance.enable()