aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/activitypub/client.ts2
-rw-r--r--server/controllers/api/overviews.ts2
-rw-r--r--server/controllers/api/server/stats.ts2
-rw-r--r--server/controllers/bots.ts2
-rw-r--r--server/controllers/feeds.ts25
-rw-r--r--server/controllers/static.ts10
6 files changed, 26 insertions, 17 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index 5ed0435ff..62412cd62 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -74,7 +74,7 @@ activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId',
74 74
75activityPubClientRouter.get('/videos/watch/:id', 75activityPubClientRouter.get('/videos/watch/:id',
76 executeIfActivityPub, 76 executeIfActivityPub,
77 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS)), 77 asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS)),
78 asyncMiddleware(videosCustomGetValidator('only-video-with-rights')), 78 asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
79 asyncMiddleware(videoController) 79 asyncMiddleware(videoController)
80) 80)
diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts
index 23706767a..46e76ac6b 100644
--- a/server/controllers/api/overviews.ts
+++ b/server/controllers/api/overviews.ts
@@ -11,7 +11,7 @@ import * as memoizee from 'memoizee'
11const overviewsRouter = express.Router() 11const overviewsRouter = express.Router()
12 12
13overviewsRouter.get('/videos', 13overviewsRouter.get('/videos',
14 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.OVERVIEWS.VIDEOS)), 14 asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.OVERVIEWS.VIDEOS)),
15 asyncMiddleware(getVideosOverview) 15 asyncMiddleware(getVideosOverview)
16) 16)
17 17
diff --git a/server/controllers/api/server/stats.ts b/server/controllers/api/server/stats.ts
index 951b98209..3616c074d 100644
--- a/server/controllers/api/server/stats.ts
+++ b/server/controllers/api/server/stats.ts
@@ -14,7 +14,7 @@ import { CONFIG } from '../../../initializers/config'
14const statsRouter = express.Router() 14const statsRouter = express.Router()
15 15
16statsRouter.get('/stats', 16statsRouter.get('/stats',
17 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.STATS)), 17 asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.STATS)),
18 asyncMiddleware(getStats) 18 asyncMiddleware(getStats)
19) 19)
20 20
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts
index f3e778b04..63280dabb 100644
--- a/server/controllers/bots.ts
+++ b/server/controllers/bots.ts
@@ -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
16botsRouter.use('/sitemap.xml', 16botsRouter.use('/sitemap.xml',
17 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.SITEMAP)), 17 asyncMiddleware(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 fa6c7ac71..72628dffb 100644
--- a/server/controllers/feeds.ts
+++ b/server/controllers/feeds.ts
@@ -6,7 +6,9 @@ import {
6 setDefaultSort, 6 setDefaultSort,
7 videoCommentsFeedsValidator, 7 videoCommentsFeedsValidator,
8 videoFeedsValidator, 8 videoFeedsValidator,
9 videosSortValidator 9 videosSortValidator,
10 feedsFormatValidator,
11 setFeedFormatContentType
10} from '../middlewares' 12} from '../middlewares'
11import { VideoModel } from '../models/video/video' 13import { VideoModel } from '../models/video/video'
12import * as Feed from 'pfeed' 14import * as Feed from 'pfeed'
@@ -18,7 +20,13 @@ import { CONFIG } from '../initializers/config'
18const feedsRouter = express.Router() 20const feedsRouter = express.Router()
19 21
20feedsRouter.get('/feeds/video-comments.:format', 22feedsRouter.get('/feeds/video-comments.:format',
21 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS)), 23 feedsFormatValidator,
24 setFeedFormatContentType,
25 asyncMiddleware(cacheRoute({
26 headerBlacklist: [
27 'Content-Type'
28 ]
29 })(ROUTE_CACHE_LIFETIME.FEEDS)),
22 asyncMiddleware(videoCommentsFeedsValidator), 30 asyncMiddleware(videoCommentsFeedsValidator),
23 asyncMiddleware(generateVideoCommentsFeed) 31 asyncMiddleware(generateVideoCommentsFeed)
24) 32)
@@ -26,7 +34,13 @@ feedsRouter.get('/feeds/video-comments.:format',
26feedsRouter.get('/feeds/videos.:format', 34feedsRouter.get('/feeds/videos.:format',
27 videosSortValidator, 35 videosSortValidator,
28 setDefaultSort, 36 setDefaultSort,
29 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS)), 37 feedsFormatValidator,
38 setFeedFormatContentType,
39 asyncMiddleware(cacheRoute({
40 headerBlacklist: [
41 'Content-Type'
42 ]
43 })(ROUTE_CACHE_LIFETIME.FEEDS)),
30 commonVideosFiltersValidator, 44 commonVideosFiltersValidator,
31 asyncMiddleware(videoFeedsValidator), 45 asyncMiddleware(videoFeedsValidator),
32 asyncMiddleware(generateVideoFeed) 46 asyncMiddleware(generateVideoFeed)
@@ -224,26 +238,21 @@ function sendFeed (feed, req: express.Request, res: express.Response) {
224 const format = req.params.format 238 const format = req.params.format
225 239
226 if (format === 'atom' || format === 'atom1') { 240 if (format === 'atom' || format === 'atom1') {
227 res.set('Content-Type', 'application/atom+xml')
228 return res.send(feed.atom1()).end() 241 return res.send(feed.atom1()).end()
229 } 242 }
230 243
231 if (format === 'json' || format === 'json1') { 244 if (format === 'json' || format === 'json1') {
232 res.set('Content-Type', 'application/json')
233 return res.send(feed.json1()).end() 245 return res.send(feed.json1()).end()
234 } 246 }
235 247
236 if (format === 'rss' || format === 'rss2') { 248 if (format === 'rss' || format === 'rss2') {
237 res.set('Content-Type', 'application/rss+xml')
238 return res.send(feed.rss2()).end() 249 return res.send(feed.rss2()).end()
239 } 250 }
240 251
241 // We're in the ambiguous '.xml' case and we look at the format query parameter 252 // We're in the ambiguous '.xml' case and we look at the format query parameter
242 if (req.query.format === 'atom' || req.query.format === 'atom1') { 253 if (req.query.format === 'atom' || req.query.format === 'atom1') {
243 res.set('Content-Type', 'application/atom+xml')
244 return res.send(feed.atom1()).end() 254 return res.send(feed.atom1()).end()
245 } 255 }
246 256
247 res.set('Content-Type', 'application/rss+xml')
248 return res.send(feed.rss2()).end() 257 return res.send(feed.rss2()).end()
249} 258}
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index f86a0cb5b..a4bb3a4d9 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -112,7 +112,7 @@ staticRouter.use(
112 112
113// robots.txt service 113// robots.txt service
114staticRouter.get('/robots.txt', 114staticRouter.get('/robots.txt',
115 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS)), 115 asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ROBOTS)),
116 (_, res: express.Response) => { 116 (_, res: express.Response) => {
117 res.type('text/plain') 117 res.type('text/plain')
118 return res.send(CONFIG.INSTANCE.ROBOTS) 118 return res.send(CONFIG.INSTANCE.ROBOTS)
@@ -127,7 +127,7 @@ staticRouter.get('/security.txt',
127) 127)
128 128
129staticRouter.get('/.well-known/security.txt', 129staticRouter.get('/.well-known/security.txt',
130 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.SECURITYTXT)), 130 asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.SECURITYTXT)),
131 (_, res: express.Response) => { 131 (_, res: express.Response) => {
132 res.type('text/plain') 132 res.type('text/plain')
133 return res.send(CONFIG.INSTANCE.SECURITYTXT + CONFIG.INSTANCE.SECURITYTXT_CONTACT) 133 return res.send(CONFIG.INSTANCE.SECURITYTXT + CONFIG.INSTANCE.SECURITYTXT_CONTACT)
@@ -136,7 +136,7 @@ staticRouter.get('/.well-known/security.txt',
136 136
137// nodeinfo service 137// nodeinfo service
138staticRouter.use('/.well-known/nodeinfo', 138staticRouter.use('/.well-known/nodeinfo',
139 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO)), 139 asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.NODEINFO)),
140 (_, res: express.Response) => { 140 (_, res: express.Response) => {
141 return res.json({ 141 return res.json({
142 links: [ 142 links: [
@@ -149,13 +149,13 @@ staticRouter.use('/.well-known/nodeinfo',
149 } 149 }
150) 150)
151staticRouter.use('/nodeinfo/:version.json', 151staticRouter.use('/nodeinfo/:version.json',
152 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO)), 152 asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.NODEINFO)),
153 asyncMiddleware(generateNodeinfo) 153 asyncMiddleware(generateNodeinfo)
154) 154)
155 155
156// dnt-policy.txt service (see https://www.eff.org/dnt-policy) 156// dnt-policy.txt service (see https://www.eff.org/dnt-policy)
157staticRouter.use('/.well-known/dnt-policy.txt', 157staticRouter.use('/.well-known/dnt-policy.txt',
158 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.DNT_POLICY)), 158 asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.DNT_POLICY)),
159 (_, res: express.Response) => { 159 (_, res: express.Response) => {
160 res.type('text/plain') 160 res.type('text/plain')
161 161