aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /server.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-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.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/server.ts b/server.ts
index 6963bbf23..f2e589243 100644
--- a/server.ts
+++ b/server.ts
@@ -121,7 +121,8 @@ import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls'
121import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler' 121import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler'
122import { Hooks } from './server/lib/plugins/hooks' 122import { Hooks } from './server/lib/plugins/hooks'
123import { PluginManager } from './server/lib/plugins/plugin-manager' 123import { PluginManager } from './server/lib/plugins/plugin-manager'
124import { LiveManager } from '@server/lib/live-manager' 124import { LiveManager } from './server/lib/live-manager'
125import { 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
211app.use(function (req, res, next) { 212app.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
230const server = createWebsocketTrackerServer(app) 231const server = createWebsocketTrackerServer(app)