
Research
/Security News
DuckDB npm Account Compromised in Continuing Supply Chain Attack
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
@newstudios/koa2-middleware-ua
Advanced tools
A middleware that set ua object for every incoming HTTP request in Koa2.
A middleware that generates ua object for every incoming HTTP request in Koa2.
Using VSCode
as deafult for debugger
# Using NPM
npm run example
# Using Yarn
yarn example
# Using NPM
$ npm install --save @xpc/koa2-middleware-ua
# Using Yarn
$ yarn add @xpc/koa2-middleware-ua
Use @xpc/koa2-middleware-ua
as a middleware for a koa app. By default, it generates a unique uuid (v4) and exposes it on the response via the X-Request-ID
header. The id is also saved as part of the ctx.req.id、ctx.request.id、ctx.id.
In the following example, the generated uuid is manually exposed on the body for debugging purposes:
const Koa = require('koa');
const { userAgent } = require('@xpc/koa2-middleware-ua');
const app = new Koa();
app.use(userAgent);
app.use(async ctx => {
ctx.body = ctx.ua;
});
app.listen(3000);
打开浏览器访问 http://localhost:3000
{"_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36"}
{
_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36"
isIOS: false
isMobile: false
isVmovierApp: false
isWeixin: false
isXpcApp: false
xpcAppVersion: null
}
Provided under the terms of the MIT License
Copyright © 2020, xinpianchang.
FAQs
A middleware that set ua object for every incoming HTTP request in Koa2.
We found that @newstudios/koa2-middleware-ua demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.