
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@discordx/koa
Advanced tools
I am deprecating this package because it will not receive long-term maintenance. If you are using this package, I highly recommend migrating to NestJS, which is the best alternative. Thank you for your understanding.
Best regards, Vijay Meena
This module is an extension of koa, so the internal behavior (methods, properties, ...) is the same
This library allows you to use TypeScript decorators on koa, it simplifies your code and improves the readability!
Version 16.6.0 or newer of Node.js is required
npm install koa @koa/router @discordx/koa
yarn add koa @koa/router @discordx/koa
Install required types
npm install --save-dev @types/koa__router
yarn add --dev @types/koa__router
@Router
to create a router on classDecorators for all koa methods, @Get @Post @All @Delete @Head @Link @Unlink @Options
KOA instance available at the end of each handler's arguments
@Router()
class Example {
@Get("/")
handle(ctx: RouterContext, next: Next, koa: Koa): Promise<Next> {
ctx.body = "Hello world!";
return next();
}
}
If you add middleware to a class, it will be executed on each route within it.
function Log(ctx: RouterContext, next: Next) {
console.log(`request: ${ctx.URL}`);
return next();
}
function Authenticated(ctx: RouterContext, next: Next) {
ctx.body = "unauthorized required";
// we are not returning next, to avoid further execution
return;
}
@Router()
@Middleware(Log) // will execute for all sub routes
class Example {
@Get("/")
hello(ctx: RouterContext, next: Next): Promise<Next> {
ctx.body = "Hello world!";
return next();
}
@Get("/auth")
@Middleware(Authenticated)
auth(ctx: RouterContext, next: Next): Promise<Next> {
ctx.body = "Hello world!";
return next();
}
}
FAQs
Use decorators with Koa with IOC
The npm package @discordx/koa receives a total of 12 weekly downloads. As such, @discordx/koa popularity was classified as not popular.
We found that @discordx/koa 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.