InversifyJS README

The project's README from github.com/inversify/InversifyJS. As one markdown file: README.md.

[!NOTE]
InversifyJS will be moving to the monorepo. Please, consider creating issues and pull requests there.

Next releases will be published in the monorepo, so consider starring it to be notified.

NPM version NPM Downloads Docs Codecov

GitHub stars Discord Server

InversifyJS

A powerful and lightweight inversion of control container for JavaScript & Node.js apps powered by TypeScript.

📕 Documentation

Documentation is available at https://inversify.io

About

InversifyJS is a lightweight inversion of control (IoC) container for TypeScript and JavaScript apps. An IoC container uses a class constructor to identify and inject its dependencies. InversifyJS has a friendly API and encourages the usage of the best OOP and IoC practices.

Motivation

JavaScript now supports object oriented (OO) programming with class based inheritance. These features are great but the truth is that they are also dangerous.

We need a good OO design (SOLID, Composite Reuse, etc.) to protect ourselves from these threats. The problem is that OO design is difficult and that is exactly why we created InversifyJS.

InversifyJS is a tool that helps JavaScript developers write code with good OO design.

Philosophy

InversifyJS has been developed with 4 main goals:

  1. Allow JavaScript developers to write code that adheres to the SOLID principles.

  2. Facilitate and encourage the adherence to the best OOP and IoC practices.

  3. Add as little runtime overhead as possible.

  4. Provide a state of the art development experience.

Testimonies

Nate Kohari - Author of Ninject

"Nice work! I've taken a couple shots at creating DI frameworks for JavaScript and TypeScript, but the lack of RTTI really hinders things. The ES7 metadata gets us part of the way there (as you've discovered). Keep up the great work!"

Michel Weststrate - Author of MobX

Dependency injection like InversifyJS works nicely

Some companies using InversifyJS

Acknowledgements

Thanks a lot to all the contributors, all the developers out there using InversifyJS and all those that help us to spread the word by sharing content about InversifyJS online. Without your feedback and support this project would not be possible.

License

License under the MIT License (MIT)

Copyright © 2015-2017 Remo H. Jansen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

InversifyJS (inversify/InversifyJS)

Searching Database…

What is this?InversifyJS is a lightweight inversion of control (IoC) container for TypeScript and JavaScript apps — a library that decides how your classes receive the objects they depend on.
What does an IoC container actually do in practice?It uses a class constructor to identify and inject a class's dependencies, so classes are handed the objects they need instead of creating them internally. The API is built to encourage the best OOP and IoC practices.
How do I add it to my project?Install the inversify package from npm, then follow the documentation site linked in the README to declare your bindings and resolve classes. The project ships both CommonJS and ESM builds.
Do I need TypeScript to use it, or does plain JavaScript work?It targets JavaScript and Node.js apps and is powered by TypeScript, so plain JavaScript works but TypeScript gives you the most. It is an in-app library — there is no server or extra runtime to deploy.
Anything I should know about this repo before diving in?Yes — the project is moving to the inversify monorepo: new issues, pull requests and releases are published there, so watch github.com/inversify/monorepo instead of this one.
Is this aimed at framework builders or everyday app developers?Everyday JavaScript developers: the README positions it as a tool that helps them write code with good OO design, with a friendly API and little runtime overhead.
Can I use it for free, including commercially?Yes. It is MIT licensed — free of charge to use, copy, modify, merge, publish and sublicense, with no paid tiers.
Why build a DI container instead of just instantiating classes where you need them?Because class-based OO in JavaScript is easy to get wrong: the README argues these features are dangerous without good OO design (SOLID, Composite Reuse), and since OO design is difficult, the authors created InversifyJS to help.
What did the authors optimize the library for?Four goals: help developers write code that adheres to the SOLID principles, encourage the best OOP and IoC practices, add as little runtime overhead as possible, and provide a state of the art development experience.
Is it battle-tested, or a hobby project?It has been around since 2015 (copyright 2015-2017 by creator Remo H. Jansen), has about 12,000 GitHub stars, and the README lists companies using it in production, though their names appear only as logos.
What do other framework authors say about it?Nate Kohari, author of the Ninject DI framework, praised how its ES7 metadata approach works around JavaScript's lack of RTTI, and MobX creator Michel Weststrate wrote that dependency injection like InversifyJS works nicely.
Creator
inversify
Size
3.4 MB
Stars
12.1K
Age
11y
Commits · 90 Days