
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@donutteam/koa-log-requests
Advanced tools
A class for creating Koa middlewares that log when requests start and end.
A class for creating Koa middlewares that log when requests start and end.
Install the package with NPM:
npm install @donutteam/koa-log-requests
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);
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.
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.
Whether or not to log the start of requests. Optional, defaults to true.
// Disable request start logging
const logRequestsMiddleware = new LogRequestsMiddleware(
{
logStart: false,
});
FAQs
A class for creating Koa middlewares that log when requests start and end.
We found that @donutteam/koa-log-requests demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.