aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-22 11:15:17 +0200
committerChocobozzz <me@florianbigard.com>2021-07-22 11:48:24 +0200
commit20bafcb61bee2a9a10a500908850c9a7d5e3c8c5 (patch)
tree18d0e8eb693b0fce88b21b282ea6f28836763fe6 /server/controllers
parent13e13377918b65c30b9334920fef4b43e70b964e (diff)
downloadPeerTube-20bafcb61bee2a9a10a500908850c9a7d5e3c8c5.tar.gz
PeerTube-20bafcb61bee2a9a10a500908850c9a7d5e3c8c5.tar.zst
PeerTube-20bafcb61bee2a9a10a500908850c9a7d5e3c8c5.zip
Move apicache in peertube
Allow us to upgrade to node 16
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/activitypub/client.ts4
-rw-r--r--server/controllers/api/server/stats.ts4
-rw-r--r--server/controllers/bots.ts4
-rw-r--r--server/controllers/feeds.ts24
-rw-r--r--server/controllers/static.ts12
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'
27import { cacheRoute } from '../../middlewares/cache' 27import { cacheRoute } from '../../middlewares/cache/cache'
28import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators' 28import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators'
29import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' 29import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy'
30import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' 30import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
@@ -77,7 +77,7 @@ activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId',
77activityPubClientRouter.get( 77activityPubClientRouter.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'
2import { StatsManager } from '@server/lib/stat-manager' 2import { StatsManager } from '@server/lib/stat-manager'
3import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' 3import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
4import { asyncMiddleware } from '../../../middlewares' 4import { asyncMiddleware } from '../../../middlewares'
5import { cacheRoute } from '../../../middlewares/cache' 5import { cacheRoute } from '../../../middlewares/cache/cache'
6 6
7const statsRouter = express.Router() 7const statsRouter = express.Router()
8 8
9statsRouter.get('/stats', 9statsRouter.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'
5import { VideoModel } from '../models/video/video' 5import { VideoModel } from '../models/video/video'
6import { VideoChannelModel } from '../models/video/video-channel' 6import { VideoChannelModel } from '../models/video/video-channel'
7import { AccountModel } from '../models/account/account' 7import { AccountModel } from '../models/account/account'
8import { cacheRoute } from '../middlewares/cache' 8import { cacheRoute } from '../middlewares/cache/cache'
9import { buildNSFWFilter } from '../helpers/express-utils' 9import { buildNSFWFilter } from '../helpers/express-utils'
10import { truncate } from 'lodash' 10import { 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
16botsRouter.use('/sitemap.xml', 16botsRouter.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'
19import { cacheRoute } from '../middlewares/cache' 19import { cacheRouteFactory } from '../middlewares/cache/cache'
20import { VideoModel } from '../models/video/video' 20import { VideoModel } from '../models/video/video'
21import { VideoCommentModel } from '../models/video/video-comment' 21import { VideoCommentModel } from '../models/video/video-comment'
22 22
23const feedsRouter = express.Router() 23const feedsRouter = express.Router()
24 24
25const cacheRoute = cacheRouteFactory({
26 headerBlacklist: [ 'Content-Type' ]
27})
28
25feedsRouter.get('/feeds/video-comments.:format', 29feedsRouter.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'
20import { getThemeOrDefault } from '../lib/plugins/theme-utils' 20import { getThemeOrDefault } from '../lib/plugins/theme-utils'
21import { asyncMiddleware } from '../middlewares' 21import { asyncMiddleware } from '../middlewares'
22import { cacheRoute } from '../middlewares/cache' 22import { cacheRoute } from '../middlewares/cache/cache'
23import { UserModel } from '../models/user/user' 23import { UserModel } from '../models/user/user'
24import { VideoModel } from '../models/video/video' 24import { VideoModel } from '../models/video/video'
25import { VideoCommentModel } from '../models/video/video-comment' 25import { VideoCommentModel } from '../models/video/video-comment'
@@ -66,7 +66,7 @@ staticRouter.use(
66 66
67// robots.txt service 67// robots.txt service
68staticRouter.get('/robots.txt', 68staticRouter.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
88staticRouter.get('/.well-known/security.txt', 88staticRouter.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
97staticRouter.use('/.well-known/nodeinfo', 97staticRouter.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)
110staticRouter.use('/nodeinfo/:version.json', 110staticRouter.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)
116staticRouter.use('/.well-known/dnt-policy.txt', 116staticRouter.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