
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
flex-injector
Advanced tools
A simple dependency injection library for TypeScript. Uses class decorators to inject dependencies, detects circular dependencies, and manages dependencies.
English | 한국어
Flex-Injector is a library that makes dependency injection easy. This library utilizes TypeScript's decorator feature to manage dependencies in a simple and clear way.
Using createInjector
, you can create multiple injectors and inject dependencies through different containers. This is particularly useful in a monorepo
environment. Each package or module can use an independent injector, making dependency management more efficient and clear.
npm install flex-injector
npm install reflect-metadata
{
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
./service
├── todo.service.ts
├── user.service.ts
└── injector.ts
// ./service/injector.ts
import { createInjector } from 'flex-injector';
const { InjectAble, inject } = createInjector();
export { InjectAble, inject };
// ./service/todo.service.ts
import { InjectAble } from './injector';
@InjectAble
export class TodoService {
async getTodo(userId:string) {
return ...;
}
}
// ./service/user.service.ts
import { InjectAble } from './injector';
@InjectAble
export class UserService {
constructor(private todoService: TodoService) {}
async getTodo(userId:string) {
return this.todoService.getTodo(userId);
}
async find(userId:string) {
return ...;
}
}
// express server example
const userService = inject(UserService);
app.get('/todo', async (req, res) => {
const todoList = await userService.getTodo(req.session.userId);
res.json(todoList);
});
// Beware of circular reference errors. Below is a bad example where circular references occur.
const { inject, InjectAble } = createInjector();
@InjectAble
class A {
constructor(private b: B) {}
}
@InjectAble
class B {
constructor(private a: A) {}
}
const a = inject(A); // Throw Circular dependency detected
FAQs
A simple dependency injection library for TypeScript. Uses class decorators to inject dependencies, detects circular dependencies, and manages dependencies.
The npm package flex-injector receives a total of 0 weekly downloads. As such, flex-injector popularity was classified as not popular.
We found that flex-injector demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.