Any good tutorial showing you which library to use for dependency injection in a project?

This page summarizes the projects mentioned and recommended in the original post on /r/node

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • `AccountEventHandlerTag` is a Symbol, acts as an ID reference for the DI Container to provide the correct dependency. AccountEventsController is not really coupled to any dependency (however it does rely on interfaces form another module), you can see here how such controller can be tested, where you manually create the dependency tree with fakes and stubs as you like https://gitlab.com/legited/di-express/-/blob/master/tests/web-server/controllers/accounts.controller.test.ts . This approach removes the need for module mocking from libraries like Jest and Rewire

  • InversifyJS

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

    The DI library you are looking for is InversifyJS https://github.com/inversify/InversifyJS. Its mature and mirrors API of other popular DI libraries.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

  • nestjs-commander

    A module for using NestJS to build up CLI applications

    There's also packages like nest-commander (disclaimer: that one is also mine) for making CLI applications instead of HTTP servers.

  • Nest

    A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀

    Hi there, I'm one of the core members of the NestJS framework

  • testing-nestjs

    A repository to show off to the community methods of testing NestJS including Unit Tests, Integration Tests, E2E Tests, pipes, filters, interceptors, GraphQL, Mongo, TypeORM, and more!

    Then there's also a @nestjs/testing package that can be used for overriding these injections during tests to make for super easy unit testing (in my opinion) and a large repo of examples here.

  • opentelemetry-js

    OpenTelemetry JavaScript Client

    I would work on getting Open Telemetry pointed at an “all-in-one” Jaegar instance and move on from there: https://www.jaegertracing.io/docs/1.25/getting-started/ https://github.com/open-telemetry/opentelemetry-js Various cloud providers may have a way to collect/view traces as well, but, Jaegar and the Open Telemetry Collector are the open source way to do that. The projects are in the process of converging in some ways — everything is in flux.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts