diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/server/stats.ts | 4 | ||||
-rw-r--r-- | server/controllers/bots.ts | 4 | ||||
-rw-r--r-- | server/controllers/feeds.ts | 24 | ||||
-rw-r--r-- | server/controllers/static.ts | 12 |
5 files changed, 20 insertions, 28 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index d7de1b9bd..bef4bc068 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -24,7 +24,7 @@ import { | |||
24 | videosCustomGetValidator, | 24 | videosCustomGetValidator, |
25 | videosShareValidator | 25 | videosShareValidator |
26 | } from '../../middlewares' | 26 | } from '../../middlewares' |
27 | import { cacheRoute } from '../../middlewares/cache' | 27 | import { cacheRoute } from '../../middlewares/cache/cache' |
28 | import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators' | 28 | import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators' |
29 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' | 29 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' |
30 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' | 30 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' |
@@ -77,7 +77,7 @@ activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId', | |||
77 | activityPubClientRouter.get( | 77 | activityPubClientRouter.get( |
78 | [ '/videos/watch/:id', '/w/:id' ], | 78 | [ '/videos/watch/:id', '/w/:id' ], |
79 | executeIfActivityPub, | 79 | executeIfActivityPub, |
80 | asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS)), | 80 | cacheRoute(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS), |
81 | asyncMiddleware(videosCustomGetValidator('all')), | 81 | asyncMiddleware(videosCustomGetValidator('all')), |
82 | asyncMiddleware(videoController) | 82 | asyncMiddleware(videoController) |
83 | ) | 83 | ) |
diff --git a/server/controllers/api/server/stats.ts b/server/controllers/api/server/stats.ts index 3aea12450..397702548 100644 --- a/server/controllers/api/server/stats.ts +++ b/server/controllers/api/server/stats.ts | |||
@@ -2,12 +2,12 @@ import * as express from 'express' | |||
2 | import { StatsManager } from '@server/lib/stat-manager' | 2 | import { StatsManager } from '@server/lib/stat-manager' |
3 | import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' | 3 | import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' |
4 | import { asyncMiddleware } from '../../../middlewares' | 4 | import { asyncMiddleware } from '../../../middlewares' |
5 | import { cacheRoute } from '../../../middlewares/cache' | 5 | import { cacheRoute } from '../../../middlewares/cache/cache' |
6 | 6 | ||
7 | const statsRouter = express.Router() | 7 | const statsRouter = express.Router() |
8 | 8 | ||
9 | statsRouter.get('/stats', | 9 | statsRouter.get('/stats', |
10 | asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.STATS)), | 10 | cacheRoute(ROUTE_CACHE_LIFETIME.STATS), |
11 | asyncMiddleware(getStats) | 11 | asyncMiddleware(getStats) |
12 | ) | 12 | ) |
13 | 13 | ||
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts index 9e92063d4..93aa0cf30 100644 --- a/server/controllers/bots.ts +++ b/server/controllers/bots.ts | |||
@@ -5,7 +5,7 @@ import { SitemapStream, streamToPromise } from 'sitemap' | |||
5 | import { VideoModel } from '../models/video/video' | 5 | import { VideoModel } from '../models/video/video' |
6 | import { VideoChannelModel } from '../models/video/video-channel' | 6 | import { VideoChannelModel } from '../models/video/video-channel' |
7 | import { AccountModel } from '../models/account/account' | 7 | import { AccountModel } from '../models/account/account' |
8 | import { cacheRoute } from '../middlewares/cache' | 8 | import { cacheRoute } from '../middlewares/cache/cache' |
9 | import { buildNSFWFilter } from '../helpers/express-utils' | 9 | import { buildNSFWFilter } from '../helpers/express-utils' |
10 | import { truncate } from 'lodash' | 10 | import { truncate } from 'lodash' |
11 | 11 | ||
@@ -14,7 +14,7 @@ const botsRouter = express.Router() | |||
14 | // Special route that add OpenGraph and oEmbed tags | 14 | // Special route that add OpenGraph and oEmbed tags |
15 | // Do not use a template engine for a so little thing | 15 | // Do not use a template engine for a so little thing |
16 | botsRouter.use('/sitemap.xml', | 16 | botsRouter.use('/sitemap.xml', |
17 | asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.SITEMAP)), | 17 | cacheRoute(ROUTE_CACHE_LIFETIME.SITEMAP), |
18 | asyncMiddleware(getSitemap) | 18 | asyncMiddleware(getSitemap) |
19 | ) | 19 | ) |
20 | 20 | ||
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index 435b12193..cdc6bfb8b 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts | |||
@@ -16,20 +16,20 @@ import { | |||
16 | videosSortValidator, | 16 | videosSortValidator, |
17 | videoSubscriptionFeedsValidator | 17 | videoSubscriptionFeedsValidator |
18 | } from '../middlewares' | 18 | } from '../middlewares' |
19 | import { cacheRoute } from '../middlewares/cache' | 19 | import { cacheRouteFactory } from '../middlewares/cache/cache' |
20 | import { VideoModel } from '../models/video/video' | 20 | import { VideoModel } from '../models/video/video' |
21 | import { VideoCommentModel } from '../models/video/video-comment' | 21 | import { VideoCommentModel } from '../models/video/video-comment' |
22 | 22 | ||
23 | const feedsRouter = express.Router() | 23 | const feedsRouter = express.Router() |
24 | 24 | ||
25 | const cacheRoute = cacheRouteFactory({ | ||
26 | headerBlacklist: [ 'Content-Type' ] | ||
27 | }) | ||
28 | |||
25 | feedsRouter.get('/feeds/video-comments.:format', | 29 | feedsRouter.get('/feeds/video-comments.:format', |
26 | feedsFormatValidator, | 30 | feedsFormatValidator, |
27 | setFeedFormatContentType, | 31 | setFeedFormatContentType, |
28 | asyncMiddleware(cacheRoute({ | 32 | cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS), |
29 | headerBlacklist: [ | ||
30 | 'Content-Type' | ||
31 | ] | ||
32 | })(ROUTE_CACHE_LIFETIME.FEEDS)), | ||
33 | asyncMiddleware(videoFeedsValidator), | 33 | asyncMiddleware(videoFeedsValidator), |
34 | asyncMiddleware(videoCommentsFeedsValidator), | 34 | asyncMiddleware(videoCommentsFeedsValidator), |
35 | asyncMiddleware(generateVideoCommentsFeed) | 35 | asyncMiddleware(generateVideoCommentsFeed) |
@@ -40,11 +40,7 @@ feedsRouter.get('/feeds/videos.:format', | |||
40 | setDefaultVideosSort, | 40 | setDefaultVideosSort, |
41 | feedsFormatValidator, | 41 | feedsFormatValidator, |
42 | setFeedFormatContentType, | 42 | setFeedFormatContentType, |
43 | asyncMiddleware(cacheRoute({ | 43 | cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS), |
44 | headerBlacklist: [ | ||
45 | 'Content-Type' | ||
46 | ] | ||
47 | })(ROUTE_CACHE_LIFETIME.FEEDS)), | ||
48 | commonVideosFiltersValidator, | 44 | commonVideosFiltersValidator, |
49 | asyncMiddleware(videoFeedsValidator), | 45 | asyncMiddleware(videoFeedsValidator), |
50 | asyncMiddleware(generateVideoFeed) | 46 | asyncMiddleware(generateVideoFeed) |
@@ -55,11 +51,7 @@ feedsRouter.get('/feeds/subscriptions.:format', | |||
55 | setDefaultVideosSort, | 51 | setDefaultVideosSort, |
56 | feedsFormatValidator, | 52 | feedsFormatValidator, |
57 | setFeedFormatContentType, | 53 | setFeedFormatContentType, |
58 | asyncMiddleware(cacheRoute({ | 54 | cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS), |
59 | headerBlacklist: [ | ||
60 | 'Content-Type' | ||
61 | ] | ||
62 | })(ROUTE_CACHE_LIFETIME.FEEDS)), | ||
63 | commonVideosFiltersValidator, | 55 | commonVideosFiltersValidator, |
64 | asyncMiddleware(videoSubscriptionFeedsValidator), | 56 | asyncMiddleware(videoSubscriptionFeedsValidator), |
65 | asyncMiddleware(generateVideoFeedForSubscriptions) | 57 | asyncMiddleware(generateVideoFeedForSubscriptions) |
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 5900eaff3..912d7e36c 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -19,7 +19,7 @@ import { | |||
19 | } from '../initializers/constants' | 19 | } from '../initializers/constants' |
20 | import { getThemeOrDefault } from '../lib/plugins/theme-utils' | 20 | import { getThemeOrDefault } from '../lib/plugins/theme-utils' |
21 | import { asyncMiddleware } from '../middlewares' | 21 | import { asyncMiddleware } from '../middlewares' |
22 | import { cacheRoute } from '../middlewares/cache' | 22 | import { cacheRoute } from '../middlewares/cache/cache' |
23 | import { UserModel } from '../models/user/user' | 23 | import { UserModel } from '../models/user/user' |
24 | import { VideoModel } from '../models/video/video' | 24 | import { VideoModel } from '../models/video/video' |
25 | import { VideoCommentModel } from '../models/video/video-comment' | 25 | import { VideoCommentModel } from '../models/video/video-comment' |
@@ -66,7 +66,7 @@ staticRouter.use( | |||
66 | 66 | ||
67 | // robots.txt service | 67 | // robots.txt service |
68 | staticRouter.get('/robots.txt', | 68 | staticRouter.get('/robots.txt', |
69 | asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ROBOTS)), | 69 | cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS), |
70 | (_, res: express.Response) => { | 70 | (_, res: express.Response) => { |
71 | res.type('text/plain') | 71 | res.type('text/plain') |
72 | return res.send(CONFIG.INSTANCE.ROBOTS) | 72 | return res.send(CONFIG.INSTANCE.ROBOTS) |
@@ -86,7 +86,7 @@ staticRouter.get('/security.txt', | |||
86 | ) | 86 | ) |
87 | 87 | ||
88 | staticRouter.get('/.well-known/security.txt', | 88 | staticRouter.get('/.well-known/security.txt', |
89 | asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.SECURITYTXT)), | 89 | cacheRoute(ROUTE_CACHE_LIFETIME.SECURITYTXT), |
90 | (_, res: express.Response) => { | 90 | (_, res: express.Response) => { |
91 | res.type('text/plain') | 91 | res.type('text/plain') |
92 | return res.send(CONFIG.INSTANCE.SECURITYTXT + CONFIG.INSTANCE.SECURITYTXT_CONTACT) | 92 | return res.send(CONFIG.INSTANCE.SECURITYTXT + CONFIG.INSTANCE.SECURITYTXT_CONTACT) |
@@ -95,7 +95,7 @@ staticRouter.get('/.well-known/security.txt', | |||
95 | 95 | ||
96 | // nodeinfo service | 96 | // nodeinfo service |
97 | staticRouter.use('/.well-known/nodeinfo', | 97 | staticRouter.use('/.well-known/nodeinfo', |
98 | asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.NODEINFO)), | 98 | cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO), |
99 | (_, res: express.Response) => { | 99 | (_, res: express.Response) => { |
100 | return res.json({ | 100 | return res.json({ |
101 | links: [ | 101 | links: [ |
@@ -108,13 +108,13 @@ staticRouter.use('/.well-known/nodeinfo', | |||
108 | } | 108 | } |
109 | ) | 109 | ) |
110 | staticRouter.use('/nodeinfo/:version.json', | 110 | staticRouter.use('/nodeinfo/:version.json', |
111 | asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.NODEINFO)), | 111 | cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO), |
112 | asyncMiddleware(generateNodeinfo) | 112 | asyncMiddleware(generateNodeinfo) |
113 | ) | 113 | ) |
114 | 114 | ||
115 | // dnt-policy.txt service (see https://www.eff.org/dnt-policy) | 115 | // dnt-policy.txt service (see https://www.eff.org/dnt-policy) |
116 | staticRouter.use('/.well-known/dnt-policy.txt', | 116 | staticRouter.use('/.well-known/dnt-policy.txt', |
117 | asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.DNT_POLICY)), | 117 | cacheRoute(ROUTE_CACHE_LIFETIME.DNT_POLICY), |
118 | (_, res: express.Response) => { | 118 | (_, res: express.Response) => { |
119 | res.type('text/plain') | 119 | res.type('text/plain') |
120 | 120 | ||