Registry / devops / typescript-rest-ioc

typescript-rest-ioc

JSON →
library1.0.1jsnpmunverified

Service factory to integrate typescript-rest with typescript-ioc for dependency injection in REST services. Current stable version: 1.0.1. It enables IoC features like @Inject, request scopes, and DI in typescript-rest routes. This package acts as a bridge; you must install typescript-rest and typescript-ioc separately. Differentiator: seamless integration with typescript-ioc's container, allowing constructor injection and scoped services. Maintenance mode: last release was in 2020, no recent updates.

npm install typescript-rest-ioc
INSTALL
IMPORT
SIG · TYPESCRIPT-REST-IO
T
typescript-rest-ioc
devopsjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import serviceFactory from 'typescript-rest-ioc' (not a typical user import; set in config)
import { serviceFactory } from 'typescript-rest-ioc'
This package is not directly imported in user code. It is referenced via the rest.config file's serviceFactory field. No named export exists.
typescript-rest/Server
import { Server } from 'typescript-rest'
import { Server } from 'typescript-rest-ioc'
Server comes from typescript-rest, not this package.
typescript-ioc/Container
import { Container } from 'typescript-ioc'
import { Container } from 'typescript-rest-ioc'
Container comes from typescript-ioc, not this package.

Shows how to configure typescript-rest-ioc via rest.config.json and use @Inject from typescript-ioc in a REST service.

// rest.config.json { "serviceFactory": "typescript-rest-ioc" } // install dependencies // npm install typescript-rest typescript-ioc typescript-rest-ioc // service.ts import { Inject } from 'typescript-ioc'; import { Path, GET, PathParam } from 'typescript-rest'; class HelloService { sayHello(name: string): 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); } } export default HelloRestService;
Debug
Known issues
deprecatedThe package has not been updated since v1.0.1 (2020). It may not work with newer versions of typescript-rest or typescript-ioc.
fix
Consider alternatives like inversify or tsyringe with manual integration.
affects: >=1.0.1
gotchaDo not import anything from typescript-rest-ioc directly. The package is only used as a string in the serviceFactory config.
fix
Set serviceFactory in rest.config.json to 'typescript-rest-ioc'.
affects: *
breakingThe package requires both peer dependencies (typescript-ioc and typescript-rest) to be installed separately. Missing them causes errors at runtime.
fix
Run npm install typescript-rest typescript-ioc typescript-rest-ioc.
affects: *
gotchaTypeScript strict mode may require definite assignment assertion (!) on injected properties.
fix
Use `private helloService!: HelloService;` to avoid TS2564 error.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'typescript-rest-ioc'
Package not installed.
fix
npm install typescript-rest-ioc --save
TypeError: Cannot read property 'get' of undefined
Service factory is not properly configured or missing rest.config.json.
fix
Create rest.config.json with {"serviceFactory": "typescript-rest-ioc"}
TS2564: Property 'helloService' has no initializer and is not definitely assigned in the constructor.
TypeScript strict property initialization.
fix
Add ! after property name: @Inject private helloService!: HelloService;
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
typescript-iocrequiredPeer dependency: provides the IoC container used by the service factory
typescript-restrequiredPeer dependency: the REST framework that the factory integrates with
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
typescript-rest-ioc — npm install typescript-rest-ioc · libregistry