Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@yveskaufmann/inversify-koa-utils
Advanced tools
Use Inversify in your koa based applications, this modules is based on inversify-express-utils.
You can install @yveskaufmann/inversify-koa-utils
using npm:
npm install inversify @yveskaufmann/inversify-koa-utils --save
To use a class as a "controller" for your restify app, simply add the @Controller
decorator to the class. Similarly, decorate methods of the class to serve as request handlers.
The following example will declare a controller that responds to `GET /foo'.
import { inject } from 'inversify';
import { HttpController } from '@yveskaufmann/inversify-koa-utils';
@HttpController('/users')
class UserController {
@inject('logService')
private logService: LogService;
@Get('/:id')
getUserById(@HttpParam(PARAMETER_TYPE.PARAMS, 'Id') id: string) {
this.logService.info(`Found user with userId=${id}`);
return {
id,
name: `${user}-id`,
};
}
}
Configure the inversify container in your composition root as usual.
Then, pass the container to the InversifyKoaServer constructor. This will allow it to register all controllers and their dependencies from your container and attach them to the koa app. Then just call server.build() to prepare your app.
In order for the InversifyKoaServer to find your controllers, you must import them along the InversifyKoaServer.
import { Container } from 'inversify';
import { interfaces, InversifyKoaServer, TYPE } from '@yveskaufmann/inversify-koa-utils';
// set up container
let container = new Container();
container.bind<LogService>('logService').to(LogService);
// create server
let server = new InversifyRestifyServer(container);
// start listening on port 3000
let app = server.build();
app.listen(3000);
FAQs
Use inversify in your koa based applications
The npm package @yveskaufmann/inversify-koa-utils receives a total of 0 weekly downloads. As such, @yveskaufmann/inversify-koa-utils popularity was classified as not popular.
We found that @yveskaufmann/inversify-koa-utils 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.