/node-beans

Primary LanguageJavaScript

!!! Deprecated

Module Registry

npm package npm downloads Build Status

Getting Started

npm i module-registry

Usage

import { Module } from 'module-registry'

@Module({
    name: 'SomeModule',
})
export default class SomeModule {
    public hello() {
        return 'hello';
    }
}

@Module({
    dependencies: [ SomeModule ],
    name: 'TestController',
    marker: 'Http',
    method: 'get',
    path: '/hello'
})
export default class TestControllerModule {
    constructor(
        public readonly somes: SomeModule) {
    }
    public work() {
        return this.somes.hello();
    }
}
import ModuleRegistry from 'module-registry'

const registry = new ModuleRegistry('./modules', path => path.match(/\.Module.(ts|js)/));
registry.initialize();

const someModule = registry.lookup<TestControllerModule>('TestController');
console.log(someModule.hello())

License

MIT