@ditojs/server 1.14.0 → 1.14.2
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 +3 -3
- package/src/app/Application.js +10 -15
- package/src/errors/ResponseError.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/server",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
|
|
6
6
|
"repository": "https://github.com/ditojs/dito/tree/master/packages/server",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"node >= 18"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ditojs/admin": "^1.14.
|
|
28
|
+
"@ditojs/admin": "^1.14.1",
|
|
29
29
|
"@ditojs/build": "^1.14.0",
|
|
30
30
|
"@ditojs/router": "^1.14.0",
|
|
31
31
|
"@ditojs/utils": "^1.14.0",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"typescript": "^4.9.3"
|
|
96
96
|
},
|
|
97
97
|
"types": "types",
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "3165af9ce8e5c8143fd5940ff9d2ae7c3fa45d8e"
|
|
99
99
|
}
|
package/src/app/Application.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import os from 'os'
|
|
2
1
|
import path from 'path'
|
|
3
2
|
import util from 'util'
|
|
4
3
|
import zlib from 'zlib'
|
|
@@ -32,7 +31,7 @@ import { Controller, AdminController } from '../controllers/index.js'
|
|
|
32
31
|
import { Service } from '../services/index.js'
|
|
33
32
|
import { Storage } from '../storage/index.js'
|
|
34
33
|
import { convertSchema } from '../schema/index.js'
|
|
35
|
-
import { deprecate
|
|
34
|
+
import { deprecate } from '../utils/index.js'
|
|
36
35
|
import {
|
|
37
36
|
ResponseError,
|
|
38
37
|
ValidationError,
|
|
@@ -595,7 +594,7 @@ export class Application extends Koa {
|
|
|
595
594
|
prettyPrint: {
|
|
596
595
|
colorize: true,
|
|
597
596
|
// List of keys to ignore in pretty mode.
|
|
598
|
-
ignore: 'req,res,durationMs,user,requestId',
|
|
597
|
+
ignore: 'req,res,durationMs,user,requestId,err.message',
|
|
599
598
|
// SYS to use system time and not UTC.
|
|
600
599
|
translateTime: 'SYS:HH:MM:ss.l'
|
|
601
600
|
},
|
|
@@ -690,24 +689,20 @@ export class Application extends Koa {
|
|
|
690
689
|
return this.config.app.normalizePaths ? hyphenate(path) : path
|
|
691
690
|
}
|
|
692
691
|
|
|
693
|
-
formatError(err) {
|
|
694
|
-
const message = err.toJSON
|
|
695
|
-
? formatJson(err.toJSON())
|
|
696
|
-
: err.message || err
|
|
697
|
-
const str = `${err.name}: ${message}`
|
|
698
|
-
return err.stack && this.config.log.errors?.stack !== false
|
|
699
|
-
? `${str}\n${err.stack.split(/\n|\r\n|\r/).slice(1).join(os.EOL)}`
|
|
700
|
-
: str
|
|
701
|
-
}
|
|
702
|
-
|
|
703
692
|
logError(err, ctx) {
|
|
704
693
|
if (!err.expose && !this.silent) {
|
|
705
694
|
try {
|
|
706
|
-
const
|
|
695
|
+
const clone = structuredClone(err)
|
|
696
|
+
// Remove headers added by the CORS middleware.
|
|
697
|
+
delete clone.headers
|
|
698
|
+
if (this.config.log.errors?.stack === false) {
|
|
699
|
+
delete clone.stack
|
|
700
|
+
delete clone.cause
|
|
701
|
+
}
|
|
707
702
|
const level =
|
|
708
703
|
err instanceof ResponseError && err.status < 500 ? 'info' : 'error'
|
|
709
704
|
const logger = ctx?.logger || this.logger
|
|
710
|
-
logger[level](
|
|
705
|
+
logger[level](clone)
|
|
711
706
|
} catch (e) {
|
|
712
707
|
console.error('Could not log error', e)
|
|
713
708
|
}
|
|
@@ -18,9 +18,9 @@ export class ResponseError extends Error {
|
|
|
18
18
|
: isString(error)
|
|
19
19
|
? { message: error }
|
|
20
20
|
: error || {}
|
|
21
|
-
const { status, ...data } = { ...defaults, ...object }
|
|
21
|
+
const { status, cause, ...data } = { ...defaults, ...object }
|
|
22
22
|
const { message, code } = data
|
|
23
|
-
super(message)
|
|
23
|
+
super(message, { cause })
|
|
24
24
|
this.name = this.constructor.name
|
|
25
25
|
this.status = status
|
|
26
26
|
this.code = code
|