@compas/server
Advanced tools
Comparing version 0.0.196 to 0.0.197
{ | ||
"name": "@compas/server", | ||
"version": "0.0.196", | ||
"version": "0.0.197", | ||
"description": "Koa server and common middleware", | ||
@@ -18,4 +18,4 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@compas/stdlib": "0.0.196", | ||
"@types/formidable": "2.0.4", | ||
"@compas/stdlib": "0.0.197", | ||
"@types/formidable": "2.0.5", | ||
"@types/koa": "2.13.4", | ||
@@ -27,8 +27,9 @@ "co-body": "6.1.0", | ||
}, | ||
"maintainers": [ | ||
"author": { | ||
"name": "Dirk de Visser", | ||
"email": "npm@dirkdevisser.nl", | ||
"url": "https://dirkdevisser.com" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Dirk de Visser", | ||
"email": "dirkdev98@gmail.com" | ||
}, | ||
{ | ||
"name": "Daniël Hansen", | ||
@@ -35,0 +36,0 @@ "email": "hi@danielhansen.nl" |
@@ -26,3 +26,3 @@ # @compas/server | ||
- Node.js >= 16 | ||
- Yarn 1.x.x | ||
- Yarn 1.x.x / NPM | ||
@@ -29,0 +29,0 @@ ## Why |
@@ -29,4 +29,2 @@ /** | ||
* logic is applied. | ||
* @property {boolean|undefined} [leakError] Adds the stacktrace and error cause to the | ||
* response. Useful on development and staging environments. | ||
*/ | ||
@@ -112,7 +110,2 @@ /** | ||
onError?: ((ctx: Koa.Context, err: Error) => boolean) | undefined; | ||
/** | ||
* Adds the stacktrace and error cause to the | ||
* response. Useful on development and staging environments. | ||
*/ | ||
leakError?: boolean | undefined; | ||
}; | ||
@@ -119,0 +112,0 @@ export type HeaderOptions = { |
@@ -41,4 +41,2 @@ import { isProduction } from "@compas/stdlib"; | ||
* logic is applied. | ||
* @property {boolean|undefined} [leakError] Adds the stacktrace and error cause to the | ||
* response. Useful on development and staging environments. | ||
*/ | ||
@@ -45,0 +43,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { AppError, isStaging } from "@compas/stdlib"; | ||
import { AppError } from "@compas/stdlib"; | ||
@@ -13,3 +13,3 @@ /** | ||
*/ | ||
const defaultOnAppError = (ctx, key, info) => ({ key, message: key, info }); | ||
const defaultOnAppError = () => ({}); | ||
@@ -25,4 +25,2 @@ /** | ||
const onError = opts.onError ?? defaultOnError; | ||
const leakError = | ||
opts.leakError === true || (opts.leakError === undefined && isStaging()); | ||
@@ -49,5 +47,10 @@ return async (ctx, next) => { | ||
formatted.type = "api_error"; | ||
formatted.requestId = ctx.requestId; | ||
log(formatted); | ||
if (leakError && onAppError === defaultOnAppError) { | ||
if (onAppError === defaultOnAppError) { | ||
delete formatted.stack; | ||
delete formatted.cause; | ||
ctx.body = formatted; | ||
@@ -54,0 +57,0 @@ } else { |
@@ -100,6 +100,8 @@ import { Transform } from "stream"; | ||
const startTime = process.hrtime.bigint(); | ||
const requestId = uuid(); | ||
ctx.requestId = requestId; | ||
ctx.log = newLogger({ | ||
ctx: { | ||
type: "http", | ||
requestId: uuid(), | ||
requestId, | ||
}, | ||
@@ -106,0 +108,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
1
46405
1190
+ Added@compas/stdlib@0.0.197(transitive)
+ Added@types/formidable@2.0.5(transitive)
+ Added@types/node@17.0.31(transitive)
+ Addedpino@7.11.0(transitive)
- Removed@compas/stdlib@0.0.196(transitive)
- Removed@types/formidable@2.0.4(transitive)
- Removed@types/node@17.0.25(transitive)
- Removedpino@7.10.0(transitive)
Updated@compas/stdlib@0.0.197
Updated@types/formidable@2.0.5