Pavel Ševčík
3 years ago
No known key found for this signature in database
GPG Key ID: CFA54E4C0CD58DF0
1 changed files with
5 additions and
1 deletions
-
lib/http-server/http-server.js
|
|
@ -32,13 +32,17 @@ class HttpServer { |
|
|
|
|
|
|
|
// Initialize the tiny-http app
|
|
|
|
this.app = new App({ |
|
|
|
noMatchHandler: (req, res) => { |
|
|
|
Logger.error(null, `HttpServer : 404 - Not found: ${req.method} - ${req.hostname}${req.path}`) |
|
|
|
HttpServer.sendError(res, {status: '404 - Not found'}, 404) |
|
|
|
}, |
|
|
|
// Error handler
|
|
|
|
onError: (err, req, res) => { |
|
|
|
// Detect if this is auth error
|
|
|
|
if (Object.values(errors.auth).includes(err)) { |
|
|
|
HttpServer.sendError(res, err, 401) |
|
|
|
} else { |
|
|
|
Logger.error(err.stack, 'HttpServer : general error') |
|
|
|
Logger.error(err.stack || err, 'HttpServer : general error') |
|
|
|
const ret = {status: 'Server error'} |
|
|
|
HttpServer.sendError(res, ret, 500) |
|
|
|
} |
|
|
|