aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server.ts')
-rw-r--r--server.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/server.ts b/server.ts
index 7aaf1e553..1834256d5 100644
--- a/server.ts
+++ b/server.ts
@@ -128,6 +128,7 @@ import { LiveManager } from './server/lib/live-manager'
128import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes' 128import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes'
129import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' 129import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
130import { ServerConfigManager } from '@server/lib/server-config-manager' 130import { ServerConfigManager } from '@server/lib/server-config-manager'
131import { apiResponseHelpers } from '@server/helpers/express-utils'
131 132
132// ----------- Command line ----------- 133// ----------- Command line -----------
133 134
@@ -186,6 +187,9 @@ app.use(cookieParser())
186// W3C DNT Tracking Status 187// W3C DNT Tracking Status
187app.use(advertiseDoNotTrack) 188app.use(advertiseDoNotTrack)
188 189
190// Response helpers used in developement
191app.use(apiResponseHelpers)
192
189// ----------- Views, routes and static files ----------- 193// ----------- Views, routes and static files -----------
190 194
191// API 195// API
@@ -235,7 +239,11 @@ app.use(function (err, req, res, next) {
235 const sql = err.parent ? err.parent.sql : undefined 239 const sql = err.parent ? err.parent.sql : undefined
236 240
237 logger.error('Error in controller.', { err: error, sql }) 241 logger.error('Error in controller.', { err: error, sql })
238 return res.status(err.status || HttpStatusCode.INTERNAL_SERVER_ERROR_500).end() 242 return res.fail({
243 status: err.status || HttpStatusCode.INTERNAL_SERVER_ERROR_500,
244 message: err.message,
245 type: err.name
246 })
239}) 247})
240 248
241const server = createWebsocketTrackerServer(app) 249const server = createWebsocketTrackerServer(app)