diff options
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -106,6 +106,7 @@ import { | |||
106 | downloadRouter | 106 | downloadRouter |
107 | } from './server/controllers' | 107 | } from './server/controllers' |
108 | import { advertiseDoNotTrack } from './server/middlewares/dnt' | 108 | import { advertiseDoNotTrack } from './server/middlewares/dnt' |
109 | import { apiFailMiddleware } from './server/middlewares/error' | ||
109 | import { Redis } from './server/lib/redis' | 110 | import { Redis } from './server/lib/redis' |
110 | import { ActorFollowScheduler } from './server/lib/schedulers/actor-follow-scheduler' | 111 | import { ActorFollowScheduler } from './server/lib/schedulers/actor-follow-scheduler' |
111 | import { RemoveOldViewsScheduler } from './server/lib/schedulers/remove-old-views-scheduler' | 112 | import { RemoveOldViewsScheduler } from './server/lib/schedulers/remove-old-views-scheduler' |
@@ -127,7 +128,6 @@ import { LiveManager } from './server/lib/live-manager' | |||
127 | import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes' | 128 | import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes' |
128 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' | 129 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' |
129 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 130 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
130 | import { apiResponseHelpers } from '@server/helpers/express-utils' | ||
131 | 131 | ||
132 | // ----------- Command line ----------- | 132 | // ----------- Command line ----------- |
133 | 133 | ||
@@ -169,8 +169,8 @@ app.use(morgan('combined', { | |||
169 | skip: req => CONFIG.LOG.LOG_PING_REQUESTS === false && req.originalUrl === '/api/v1/ping' | 169 | skip: req => CONFIG.LOG.LOG_PING_REQUESTS === false && req.originalUrl === '/api/v1/ping' |
170 | })) | 170 | })) |
171 | 171 | ||
172 | // Response helpers used for errors | 172 | // Add .fail() helper to response |
173 | app.use(apiResponseHelpers) | 173 | app.use(apiFailMiddleware) |
174 | 174 | ||
175 | // For body requests | 175 | // For body requests |
176 | app.use(express.urlencoded({ extended: false })) | 176 | app.use(express.urlencoded({ extended: false })) |
@@ -179,6 +179,7 @@ app.use(express.json({ | |||
179 | limit: '500kb', | 179 | limit: '500kb', |
180 | verify: (req: express.Request, res: express.Response, buf: Buffer) => { | 180 | verify: (req: express.Request, res: express.Response, buf: Buffer) => { |
181 | const valid = isHTTPSignatureDigestValid(buf, req) | 181 | const valid = isHTTPSignatureDigestValid(buf, req) |
182 | |||
182 | if (valid !== true) { | 183 | if (valid !== true) { |
183 | res.fail({ | 184 | res.fail({ |
184 | status: HttpStatusCode.FORBIDDEN_403, | 185 | status: HttpStatusCode.FORBIDDEN_403, |