🚀 DAY 4 OF LAUNCH WEEK:Introducing Socket Scanning for OpenVSX Extensions.Learn more →
Socket
Book a DemoInstallSign in
Socket

@restorecommerce/koa-req-res-logger

Package Overview
Dependencies
Maintainers
0
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@restorecommerce/koa-req-res-logger

Koa 2 middleware which logs incoming requests and outgoing responses

latest
Source
npmnpm
Version
1.1.11
Version published
Weekly downloads
82
-17.17%
Maintainers
0
Weekly downloads
 
Created
Source

koa-req-res-logger

Build StatusDependenciesCoverage Status

A GraphQL aware request/ response logger for Koa 2.

The logger accepts an option logger which must be a winston compatible logger. If not provided, winston is used.

The generated log data has the following structure:

// **Request** log structure
interface Request {
  method: string;           // HTTP request method
  url: string;              // requested URL
  header: object;           // HTTP request headers
  graphql?: {               // If request is a GraphQL request and is enabled in options
    operationName?: string; // GraphQL operation name if exists
    query?: string;         // GraphQL query if exists
    variables?: object;     // GraphQL variables if exist and is enabled in options
  }
}

// **Response** log structure
interface Response {
  procTime: number;         // processing time for of the middleware stack
  status: number;           // HTTP status code
  header: object;           // HTTP headers
  graphql?: {               // If request is a GraphQL request and is enabled in options
    operationName?: string; // GraphQL operation name if exists
    query?: string;         // GraphQL query if exists
    variables?: object;     // GraphQL variables if exist and is enabled in options
  }
}

GraphQL Logging

The GraphQL request data will be only included in one of the logs. Logging GraphQL data requires that the body of this request has been read. If the body has not been read when it reaches the request log, it will be logged in the response.

Usage

see test.js.

Options

  • logger Winston compatible logger like Restore Logger.
  • logResBody [false] Whether the response body should be logged or not.
  • logGraphQL [false] Whether graphql-specific data should be logged or not.
  • logGraphQLVariables [false] Whether graphql request variables should be logged or not.

Keywords

restore

FAQs

Package last updated on 02 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts