JSPM

typescript-rest-ioc

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 632
  • Score
    100M100P100Q103502F
  • License MIT

A Lightweight annotation-based dependency injection container for typescript.

Package Exports

  • typescript-rest-ioc

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (typescript-rest-ioc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm version Master Workflow Coverage Status

Typescript-Rest with IoC

After install Typescript-Rest, install the IoC container and the serviceFactory for the IoC Container

npm install typescript-rest --save
npm install typescript-ioc --save
npm install typescript-rest-ioc --save

Then add a rest.config file in the root of your project:

{
  "serviceFactory": "typescript-rest-ioc"
}

And you can use Injections, Request scopes and all the features of the IoC Container. It is possible to use it with any other IoC Container, like Inversify.

Example:

class HelloService {
  sayHello(name: string) {
    return "Hello " + name;
  }
}

@Path("/hello")
class HelloRestService {
  @Inject
  private helloService: HelloService;

  @Path(":name")
  @GET
  sayHello( @PathParam('name') name: string): string {
    return this.helloService.sayHello(name);
  }
}