@ditojs/server 1.14.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/server",
3
- "version": "1.14.1",
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",
@@ -95,5 +95,5 @@
95
95
  "typescript": "^4.9.3"
96
96
  },
97
97
  "types": "types",
98
- "gitHead": "f519c24320a1cf04aa81c6476b602a590b5c2930"
98
+ "gitHead": "3165af9ce8e5c8143fd5940ff9d2ae7c3fa45d8e"
99
99
  }
@@ -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, formatJson } from '../utils/index.js'
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 text = this.formatError(err)
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](text)
705
+ logger[level](clone)
711
706
  } catch (e) {
712
707
  console.error('Could not log error', e)
713
708
  }