Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

Build a Tiny Dependency Injection Container in TypeScript

DEV Community·Gabriel Anhaia·30 days ago
#dYNDBA6e
#when#typescript#node#logger#container#const
Reading 0:00
15s threshold

Book: TypeScript Essentials Also by me: The TypeScript Library — the 5-book collection My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub You hit fifty services. Your main.ts is now a wall of new . Forty-seven lines of construction, half of them passing the same logger and config into the next thing. A PR swaps the Postgres pool for a read replica in three places, misses the fourth, and a queue worker keeps writing to the primary until someone notices. The instinct, watching that code review burn down, is to reach for a container. Pull in tsyringe or inversify , mark every class @injectable() , let the framework wire it. Tag the bootstrap as solved. The instinct names a real problem and overshoots the fix. The wall of new is real. The decorator container is overkill for almost every TypeScript service shipped today.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More