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
196
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.166 to 0.0.167

4

package.json
{
"name": "@compas/server",
"version": "0.0.166",
"version": "0.0.167",
"description": "Koa server and common middleware",

@@ -18,3 +18,3 @@ "main": "./index.js",

"dependencies": {
"@compas/stdlib": "0.0.166",
"@compas/stdlib": "0.0.167",
"@types/formidable": "1.2.4",

@@ -21,0 +21,0 @@ "@types/koa": "2.13.4",

@@ -85,3 +85,3 @@ import { isProduction } from "@compas/stdlib";

app.use(logMiddleware(opts.logOptions ?? {}));
app.use(logMiddleware(app, opts.logOptions ?? {}));
app.use(errorHandler(opts.errorOptions ?? {}));

@@ -88,0 +88,0 @@ app.use(notFoundHandler());

/**
* Log basic request and response information
*
* @param {import("koa")} app
* @param {{ disableRootEvent?: boolean }} options
*/
export function logMiddleware(options: {
export function logMiddleware(app: import("koa"), options: {
disableRootEvent?: boolean;
}): (ctx: any, next: any) => Promise<void>;
//# sourceMappingURL=log.d.ts.map
import { Transform } from "stream";
import {
AppError,
eventStart,

@@ -14,5 +15,6 @@ eventStop,

*
* @param {import("koa")} app
* @param {{ disableRootEvent?: boolean }} options
*/
export function logMiddleware(options) {
export function logMiddleware(app, options) {
/**

@@ -50,2 +52,17 @@ * Real log function

// Log stream errors after the headers are sent
const logger = newLogger({
ctx: {
type: "http-error",
},
});
app.on("error", (error, ctx) => {
(ctx?.log ?? logger).info({
type: "http-error",
headerSent: error.headerSent,
syscall: error.syscall,
error: AppError.format(error),
});
});
return async (ctx, next) => {

@@ -52,0 +69,0 @@ const startTime = process.hrtime.bigint();

@@ -64,2 +64,3 @@ import { isNil } from "@compas/stdlib";

if (isNil(start) || start > file.contentLength) {
// '-500' results in the last 500 bytes send
start = file.contentLength - end;

@@ -66,0 +67,0 @@ end = file.contentLength - 1;

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