mlcl_di is a dependency injection module mainly created for the Molecuel application framework but can be used with any Node project. It's highly inspired by the Spring java framework. The development is focused on simple usage and good code readability.
We also developed an option to define and reuse Singleton instances in your code. We are using the latest features from Typescript, ECMAScript and Reflect Metadata.
import {di, injectable, singleton, component} from 'mlcl_di';
@injectable
class InnerClass {
constructor() {
}
}
@injectable
class SomeClass {
inside: InnerClass;
constructor(inj: InnerClass) {
this.inside = inj;
}
someMethod(){
console.log('did something.');
}
}
@singleton
class MySingletonClass {
prop: any;
constructor(inj: SomeClass) {
this.prop = inj || false;
}
}
@component
class MyComponent {
prop: any;
constructor(inj: SomeClass) {
this.prop = inj || false;
}
}
@component
@singleton
class MySingletonComponent {
prop: any;
constructor(inj: SomeClass) {
this.prop = inj || false;
}
}
// automatically initializes all components and it's dependencies
di.bootstrap();
The current API Documentation can be found on https://molecuel.github.io/mlcl_di/
http://molecuel.org/en/module/di/
We are using npm to build the entire module. During development we use the tsc compiler defined in the task.json for visual studio code cause the incremental compilation is very fast. To start the build and watch process in Visual Studio Code just press CTRL+SHIFT+B. The build console should come up and show you the results of the build process. Any other editor can be used or just use tsc -w -p . on the commandline.
All available npm options:
Executes the linter for the typescript files in the src folder
Executes the linter for the typescript files in the test folder
Runs the Typescript compiler for all files in the src directory
Runs the Typescript compiler for all files in the test directory
Executes thes linter for the files in the src folder and runs the typescript compiler for the files in the src folder.
Executes thes linter for the files in the test folder and runs the typescript compiler for the files in the test folder.
Executes thes linter for the files in the src and test folder and runs the typescript compiler for the files in the src and test folder.
Just executes the local mocha command which relies in the local node_modules directory.
Executes the compilation of the test files and runs the mocha test.
Runs the istanbuld code coverage test and remaps the results to the typescript sources
Remaps the code coverage report to typescript
Remaps the html output of istanbul to the typescript sources
Remaps the lcov reports to the typescript sources
Runs the code coverage reports, the remaps and send the results to the coveralls.io service
Creates the HTML for the API documentation in the docs folder. The docs folder is in .gitignore and not part of the master branch.
Publishes the API documentation to the gh-pages branch.
Shortcut for createdocs and publishdocs
Checks it the package version in package.json is higher than the registered one in npm registry and published the package if the version is higher.