Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
ngfelixl committed Sep 15, 2018
1 parent 6896c73 commit 5d2589a
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# NodeJS dependency injection in Angular style

NodeJS dependency injection module on top of [inversify](http://inversify.io/) for using
backend DI in a way similar to Angulars DI. E.g. you can use the following snippet throughout
your complete application

```typescript
@FlModule({
imports: [ AuthModule, Http2Module ],
declarations: [ AppComponent ],
providers: [ AuthService ],
exports: [ ]
})
export class AppModule
```

The other two decorators are

```typescript
@Component()
export class AppComponent {}
```

which treats the decorator as an inversify `@injectable` and directly creates an instance when the
parent module gets instanciated. The other one is the `@Injectable()` decorator

```typescript
@Injectable()
export class AuthService {}
```

which returns an inversify `@injectable` decorator, but does not directly creates an instance but
instanciates itself when an `@Inject(serviceIdentifier)` is used as a constructor parameter in the
same or a childs containers class.

The DI system is hierarchical.

## Installation

Add the package to your project

```bash
npm i --save fl-node-di
# or
yarn add fl-node-di
```

Import the decorators with

```typescript
import { FlModule, Component, Injectable, Inject } from 'fl-node-di'
```

## Dependencies

- [inversify](http://inversify.io/)

0 comments on commit 5d2589a

Please sign in to comment.