-import * as cors from 'cors'
-import * as express from 'express'
+import cors from 'cors'
+import express from 'express'
import { join } from 'path'
import { serveIndexHTML } from '@server/lib/client-html'
import { ServerConfigManager } from '@server/lib/server-config-manager'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model'
-import { root } from '../helpers/core-utils'
+import { root } from '@shared/core-utils'
import { CONFIG, isEmailEnabled } from '../initializers/config'
import {
CONSTRAINTS_FIELDS,
} from '../initializers/constants'
import { getThemeOrDefault } from '../lib/plugins/theme-utils'
import { asyncMiddleware } from '../middlewares'
-import { cacheRoute } from '../middlewares/cache'
+import { cacheRoute } from '../middlewares/cache/cache'
import { UserModel } from '../models/user/user'
import { VideoModel } from '../models/video/video'
import { VideoCommentModel } from '../models/video/video-comment'
Cors is very important to let other servers access torrent and video files
*/
-// FIXME: deprecated in 3.2, use lazy-statics instead
-// Due to historical reasons, we can't really remove this controller
-const torrentsPhysicalPath = CONFIG.STORAGE.TORRENTS_DIR
-staticRouter.use(
- STATIC_PATHS.TORRENTS,
- express.static(torrentsPhysicalPath, { maxAge: 0 }) // Don't cache because we could regenerate the torrent file
-)
-
// Videos path for webseed
staticRouter.use(
STATIC_PATHS.WEBSEED,
// robots.txt service
staticRouter.get('/robots.txt',
- asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ROBOTS)),
+ cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS),
(_, res: express.Response) => {
res.type('text/plain')
+
return res.send(CONFIG.INSTANCE.ROBOTS)
}
)
)
staticRouter.get('/.well-known/security.txt',
- asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.SECURITYTXT)),
+ cacheRoute(ROUTE_CACHE_LIFETIME.SECURITYTXT),
(_, res: express.Response) => {
res.type('text/plain')
return res.send(CONFIG.INSTANCE.SECURITYTXT + CONFIG.INSTANCE.SECURITYTXT_CONTACT)
// nodeinfo service
staticRouter.use('/.well-known/nodeinfo',
- asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.NODEINFO)),
+ cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO),
(_, res: express.Response) => {
return res.json({
links: [
}
)
staticRouter.use('/nodeinfo/:version.json',
- asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.NODEINFO)),
+ cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO),
asyncMiddleware(generateNodeinfo)
)
// dnt-policy.txt service (see https://www.eff.org/dnt-policy)
staticRouter.use('/.well-known/dnt-policy.txt',
- asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.DNT_POLICY)),
+ cacheRoute(ROUTE_CACHE_LIFETIME.DNT_POLICY),
(_, res: express.Response) => {
res.type('text/plain')