Socket
Book a DemoInstallSign in
Socket

@donutteam/koa-log-requests

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@donutteam/koa-log-requests

A class for creating Koa middlewares that log when requests start and end.

unpublished
latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Koa Log Requests

A class for creating Koa middlewares that log when requests start and end.

Installation

Install the package with NPM:

npm install @donutteam/koa-log-requests

Usage

To use this class, simply instantiate an instance and add it to your Koa stack:

import Koa from "koa";

import { LogRequestsMiddleware } from "@donutteam/koa-log-requests";

const app = new Koa();

const logRequestsMiddleware = new LogRequestsMiddleware();

// Be sure to add the execute function on the instance
// and NOT the instance itself
app.use(logRequestsMiddleware.execute);

Options

An object containing various options can be passed to the middleware's constructor.

These options can also be manually modified on the instance afterwards, if you need to do so for some reason.

ipNames

An object whose keys are IP addresses and whose values are names for those IP addresses.

// Name requests coming from your own machine
const logRequestsMiddleware = new LogRequestsMiddleware(
	{
		ipNames:
		{
			"::ffff:127.0.0.1": "This Machine",
		},
	});

This is useful if your application is communicated with from machines you know the identity of and you want to be named in the logs.

logStart

Whether or not to log the start of requests. Optional, defaults to true.

// Disable request start logging
const logRequestsMiddleware = new LogRequestsMiddleware(
	{
		logStart: false,
	});

License

MIT

Keywords

koa

FAQs

Package last updated on 07 Jun 2023

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