Releases: divmgl/nwire
1.1.2
Release notes
1.0.4 had a lot of bugs and things that weren't working. This version is a big rework of internal systems while keeping the API mostly the same. There are some breaking changes so I've bumped the version to 1.1.
- Added a
base
method which allows you to set a base - Added an override argument to
context
so callers can provide an object of registrations that will always be favored over theContainer
. Useful for situations where you need to guarantee that a static property is never clobbered (such as passingreq
andres
through theService
. shallow
is now deprecated and its functionality has been merged intocontext
.build
is now deprecated (usenew
)instance
is now deprecated (usesingleton
)- Fixed an issue where a circular reference could cause the process to hang when enumerated
- Fixed an issue where references would only be partially resolved
- Fixed an issue where dependencies would not receive the full context
1.0.4
Introducing nwire
nwire
allows you to use dependency injection easily in your projects. Create a Container
, register dependencies, generate a Context
and you now have a fully wired system that resolves dependencies when needed.
import { Container, Injected } from "nwire"
type MyTypedContext = {
banner: string
my: MyService
}
export class MyService extends Injected<MyTypedContext> {
helloWorld() {
return this.context.banner
}
}
const context = Container.register("banner", () => "Hello world!")
.instance("my", MyService)
.context()
console.log(context.my.helloWorld()) // => console output: "Hello world!"
More information on the README.md!
nwire no longer needs a callback
// config.js
module.exports = {
"consumer": { needs: ["provider"], fn: function(imports) { return imports.provider; } },
"provider": { needs: [], fn: function() { return 123; } }
}
// app.js
var app = require('nwire')(require('./config'));
console.log(app.consumer); // => 123
- Callbacks are no longer needed to return a container
- The
provider
package is declared after theconsumer
package. With older versions ofnwire
, this configuration would not have worked because the packages were resolved in sequential order. This has now been solved using ES5 getters.
The downside to this is that nwire no longer takes care of circular dependencies gracefully. Circular dependency detection may be added in a future release.
Nested objects
nwire
now supports nested objects.
0.2.1
Lazy-loading
- Packages are now lazy-loaded to avoid memory issues
- Circular dependencies no longer throw errors and will only wire one layer
Node.js system modules
nwire.js
now supports Node.js system modules. It also will not crash if packages require dependencies that have not been registered.
Initial release
Initial release containing all functionality needed to begin using dependency injection in Node.js.