1.5.7 • Published 5 months ago

deps-injector v1.5.7

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Dependencies Injector (deps-injector)

Both factory and inject methods receives a consumer/dependent class and the second argument is as an array of its dependencies classes/instances. After it then instantiates the consumer/dependent class (if necessary) injecting the classes passed as dependencies. All the dependencies must be classes or instances of classes. The method factory is good for quick use while inject is good for testing and more flexible stuff.

Method: factory

import { UserRepository } from './user.repository'
import { AuthenticateService } from './authenticate.service'

import { inject } from 'deps-injector'

const authService = factory(AuthenticateService, UserRepository)

Method: inject

import { UserRepository } from './user.repository'
import { AuthenticateService } from './authenticate.service'

import { inject } from 'deps-injector'

const [ authService, [userRepo] ] = inject(AuthenticateService, UserRepository)

const user = authService.execute({ name: 'john', email: 'john@gmail.com'})
await userRepo.deleteById(user.id)
1.5.5

5 months ago

1.5.4

5 months ago

1.5.3

10 months ago

1.5.7

5 months ago

1.5.6

5 months ago

1.5.2

12 months ago

1.5.1

12 months ago

1.5.0

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago