Skip to content

Releases: divmgl/nwire

1.1.2

30 Oct 15:23
e093594
Compare
Choose a tag to compare

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 the Container. Useful for situations where you need to guarantee that a static property is never clobbered (such as passing req and res through the Service.
  • shallow is now deprecated and its functionality has been merged into context.
  • build is now deprecated (use new)
  • instance is now deprecated (use singleton)
  • 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

26 Oct 18:22
84b1070
Compare
Choose a tag to compare

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

07 Feb 22:50
Compare
Choose a tag to compare
// 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 the consumer package. With older versions of nwire, 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

07 Feb 03:32
Compare
Choose a tag to compare

nwire now supports nested objects.

0.2.1

08 Dec 06:04
Compare
Choose a tag to compare
Release v0.2

Lazy-loading

07 Oct 03:53
Compare
Choose a tag to compare
  • 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

21 Aug 19:13
Compare
Choose a tag to compare

nwire.js now supports Node.js system modules. It also will not crash if packages require dependencies that have not been registered.

Initial release

14 May 19:14
Compare
Choose a tag to compare
Initial release Pre-release
Pre-release

Initial release containing all functionality needed to begin using dependency injection in Node.js.