@rym-lib/inversify-bundler
v0.0.1
Published
Bundle `ContainerModule` for [inversify](https://github.com/inversify/InversifyJS)
Downloads
33
Readme
@rym-lib/inversify-bundler
Bundle ContainerModule
for inversify
installation
npm i -D @rym-lib/inversify-bundler
Usage
Module creation
interface ExamplePort {}
@injectable()
class Example implements ExamplePort {
constructor(
@inject(DBIdentifier)
private db: DBPort,
) {}
}
const { identifier: ExampleIdentifier, bundler: ExampleModule } =
createModule<ExamplePort>('Example', Example, [DBModule])
export { ExampleIdentifier, ExampleModule }
export type { ExamplePort }
Bundling modules
import { ExampleModule, ExamplePort, ExampleIdentifier } from './example'
const container = new Container()
container.load(...ExampleModule.resolve())
const example = container.get<ExamplePort>(ExampleIdentifier)