Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@compas/server

Package Overview
Dependencies
Maintainers
1
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@compas/server - npm Package Compare versions

Comparing version 0.0.196 to 0.0.197

17

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc