140 words
1 minutes
Mastering Dependency Injection in TypeScript with TypeDI: A Comprehensive Guide
Table of Contents
- Understanding Dependency Injection
- Benefit of Dependency Injection
- Why TypeDI?
- Prerequisites
- Setup our project
Understanding Dependency Injection
Dependency injection is a software design pattern that ensures classes and properties are cached and reused effectively to avoid multiple instantiations.
Benefit of Dependency Injection
Why TypeDI?
TypeDI is an essential tool that allows us to use dependency in our NodeJS application.
Prerequisites
This article is not an introduction to NodeJS or TypeScript, basic knowledge of these technologies is required to understand this article, nevertheless. You need to have the latest version 18 of NodeJS binary installed.
Setup our project
Create a new folder in your desired directory called test-app. This is where we would be writing our nodeJS codes. Open the folder in your terminal then run:
npm init -y
The command above allows us to scaffold a new NodeJS project with our package.json ready to be used.