@fastify-decorators/typedi
v4.0.0-next.5
Published
fastify-decorators plugin to work with Sequelize
Downloads
3,234
Readme
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