diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-07 14:32:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 14:32:36 +0100 |
commit | 2d53be0267acc49cda46707b885096193a1f4e9c (patch) | |
tree | 887061a34bc67f40acbb96a6278f9544bf83caeb /server.ts | |
parent | adc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff) | |
download | PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip |
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -121,7 +121,8 @@ import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls' | |||
121 | import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler' | 121 | import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler' |
122 | import { Hooks } from './server/lib/plugins/hooks' | 122 | import { Hooks } from './server/lib/plugins/hooks' |
123 | import { PluginManager } from './server/lib/plugins/plugin-manager' | 123 | import { PluginManager } from './server/lib/plugins/plugin-manager' |
124 | import { LiveManager } from '@server/lib/live-manager' | 124 | import { LiveManager } from './server/lib/live-manager' |
125 | import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes' | ||
125 | 126 | ||
126 | // ----------- Command line ----------- | 127 | // ----------- Command line ----------- |
127 | 128 | ||
@@ -210,7 +211,7 @@ if (cli.client) app.use('/', clientsRouter) | |||
210 | // Catch 404 and forward to error handler | 211 | // Catch 404 and forward to error handler |
211 | app.use(function (req, res, next) { | 212 | app.use(function (req, res, next) { |
212 | const err = new Error('Not Found') | 213 | const err = new Error('Not Found') |
213 | err['status'] = 404 | 214 | err['status'] = HttpStatusCode.NOT_FOUND_404 |
214 | next(err) | 215 | next(err) |
215 | }) | 216 | }) |
216 | 217 | ||
@@ -224,7 +225,7 @@ app.use(function (err, req, res, next) { | |||
224 | const sql = err.parent ? err.parent.sql : undefined | 225 | const sql = err.parent ? err.parent.sql : undefined |
225 | 226 | ||
226 | logger.error('Error in controller.', { err: error, sql }) | 227 | logger.error('Error in controller.', { err: error, sql }) |
227 | return res.status(err.status || 500).end() | 228 | return res.status(err.status || HttpStatusCode.INTERNAL_SERVER_ERROR_500).end() |
228 | }) | 229 | }) |
229 | 230 | ||
230 | const server = createWebsocketTrackerServer(app) | 231 | const server = createWebsocketTrackerServer(app) |