4.0.0-next.5 • Published 7 months ago

@fastify-decorators/typedi v4.0.0-next.5

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

npm version npm License: MIT

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

  1. Install @fastify-decorators/typedi and typedi
  2. 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,
    });
  3. 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