Skip to content

Backend application for the Racket O Meter platform for Node.js

Notifications You must be signed in to change notification settings

racketometer/backend-application

Repository files navigation

backend-application

Build Status Coverage Status dependencies Status devDependencies Status

Apollo Server application using MongoDB

IoC

Using the inversify library we get dependency injection capabilities. For a class to be injectable add the @injectable() decorator to it and register it in the ioc.config.ts and ioc.types.ts files

// myNeed.ts
import { injectable } from 'inversify';

@injectable()
class MyNeed { }

// ioc.types.ts
const TYPES = {
  MyNeed: Sumbol("MyNeed"),
};

// ioc.config.ts
import { MyNeed } from './myNeed';

...

container.bind<MyNeed>(TYPES.MyNeed).to(MyNeed);

When in need of an injectable entity use the @inject(<TYPE>) decorator in the constructor as below.

import { inject } from 'inversify';
import { TYPES } from './ioc.types';

class InNeed {
  constructor(@inject(TYPES.MyNeed) myNeed: MyNeed) { }
}

About

Backend application for the Racket O Meter platform for Node.js

Resources

Stars

Watchers

Forks

Packages

No packages published