diff options
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -128,6 +128,7 @@ import { LiveManager } from './server/lib/live-manager' | |||
128 | import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes' | 128 | import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes' |
129 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' | 129 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' |
130 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 130 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
131 | import { 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 |
187 | app.use(advertiseDoNotTrack) | 188 | app.use(advertiseDoNotTrack) |
188 | 189 | ||
190 | // Response helpers used in developement | ||
191 | app.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 | ||
241 | const server = createWebsocketTrackerServer(app) | 249 | const server = createWebsocketTrackerServer(app) |