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 reddit.com/r/node

Our great sponsors
  • Appwrite - The Open Source Firebase alternative introduces iOS support
  • Scout APM - Less time debugging, more time building
  • JetBrains - Developer Ecosystem Survey 2022
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
  • `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.

  • Appwrite

    Appwrite - The Open Source Firebase alternative introduces iOS support . Appwrite is an open source backend server that helps you build native iOS applications much faster with realtime APIs for authentication, databases, files storage, cloud functions and much more!

  • 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 on top of TypeScript & JavaScript (ES6, ES7, ES8) 🚀

    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