@athenna/http 3.0.6 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athenna/http",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "The Athenna Http server. Built on top of fastify.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "João Lenon <lenon@athenna.io>",
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"fastify": "4.9.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@athenna/artisan": "3.0.
|
|
61
|
-
"@athenna/common": "3.0.
|
|
62
|
-
"@athenna/config": "3.0.
|
|
63
|
-
"@athenna/ioc": "3.0.
|
|
64
|
-
"@athenna/logger": "3.0.
|
|
60
|
+
"@athenna/artisan": "3.0.7",
|
|
61
|
+
"@athenna/common": "3.0.1",
|
|
62
|
+
"@athenna/config": "3.0.3",
|
|
63
|
+
"@athenna/ioc": "3.0.1",
|
|
64
|
+
"@athenna/logger": "3.0.6",
|
|
65
65
|
"@fastify/cors": "8.1.1",
|
|
66
66
|
"@fastify/helmet": "10.0.2",
|
|
67
67
|
"@fastify/rate-limit": "7.5.0",
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { Log } from '@athenna/logger'
|
|
11
10
|
import { Config } from '@athenna/config'
|
|
12
|
-
import {
|
|
11
|
+
import { String } from '@athenna/common'
|
|
12
|
+
import { Log, Logger } from '@athenna/logger'
|
|
13
13
|
|
|
14
14
|
export class HttpExceptionHandler {
|
|
15
15
|
/**
|
|
@@ -61,8 +61,6 @@ export class HttpExceptionHandler {
|
|
|
61
61
|
delete body.stack
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
response.status(statusCode).send(body)
|
|
65
|
-
|
|
66
64
|
if (
|
|
67
65
|
this.ignoreCodes.includes(code) ||
|
|
68
66
|
this.ignoreStatuses.includes(statusCode)
|
|
@@ -70,20 +68,20 @@ export class HttpExceptionHandler {
|
|
|
70
68
|
return
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
const logger = Config.exists('logging.channels.exception')
|
|
72
|
+
? Log.channel('exception')
|
|
73
|
+
: Logger.getConsoleLogger({
|
|
74
|
+
level: 'trace',
|
|
75
|
+
streamType: 'stderr',
|
|
76
|
+
formatter: 'none',
|
|
77
|
+
})
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
if (!error.prettify) {
|
|
80
|
+
error = error.toAthennaException()
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
exception.stack = error.stack
|
|
84
|
-
|
|
85
|
-
const prettyError = await exception.prettify()
|
|
83
|
+
logger.error((await error.prettify()).concat('\n'))
|
|
86
84
|
|
|
87
|
-
|
|
85
|
+
return response.status(statusCode).send(body)
|
|
88
86
|
}
|
|
89
87
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import rTracer from 'cls-rtracer'
|
|
11
11
|
|
|
12
|
-
import { Log } from '@athenna/logger'
|
|
12
|
+
import { Log, Logger } from '@athenna/logger'
|
|
13
13
|
import { Config } from '@athenna/config'
|
|
14
14
|
import { Server } from '#src/Facades/Server'
|
|
15
15
|
import { Module, Path } from '@athenna/common'
|
|
@@ -184,6 +184,15 @@ export class HttpKernel {
|
|
|
184
184
|
return
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
Server.use(async ctx =>
|
|
187
|
+
Server.use(async ctx => {
|
|
188
|
+
const logger = Config.exists('logging.channels.request')
|
|
189
|
+
? Log.channel('request')
|
|
190
|
+
: Logger.getConsoleLogger({
|
|
191
|
+
level: 'trace',
|
|
192
|
+
formatter: 'none',
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
logger.info(ctx)
|
|
196
|
+
}, 'terminate')
|
|
188
197
|
}
|
|
189
198
|
}
|