4.0.0-next.5 • Published 7 months ago
@fastify-decorators/typedi v4.0.0-next.5
Dependency injection
Dependency injection (DI) is widely used mechanism to autowire controller/service dependency. In fastify-decorators DI only available for controllers.
This plugin provides support for integration with TypeDI
Getting started
- Install
@fastify-decorators/typedi
andtypedi
Use TypeDI container in the app
import { useContainer } from '@fastify-decorators/typedi'; import { fastify } from 'fastify'; import { bootstrap } from 'fastify-decorators'; import { Container } from 'typedi'; useContainer(Container); export const app = fastify(); app.register(bootstrap, { directory: import.meta.url, });
Write services, annotate them with
@Service
and inject into controllers using@Inject
from TypeDI
Examples
4.0.0-next.5
7 months ago
4.0.0-next.4
2 years ago
4.0.0-next.2
2 years ago
4.0.0-next.1
3 years ago
4.0.0-next.0
3 years ago