惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

PCI Perspectives
PCI Perspectives
Apple Machine Learning Research
Apple Machine Learning Research
Recent Announcements
Recent Announcements
量子位
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
Recorded Future
Recorded Future
P
Privacy International News Feed
Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
C
Check Point Blog
O
OpenAI News
N
Netflix TechBlog - Medium
U
Unit 42
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
F
Full Disclosure
Know Your Adversary
Know Your Adversary
GbyAI
GbyAI
W
WeLiveSecurity
Engineering at Meta
Engineering at Meta
Scott Helme
Scott Helme
云风的 BLOG
云风的 BLOG
I
InfoQ
D
Docker
N
News | PayPal Newsroom
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
T
Tor Project blog
The GitHub Blog
The GitHub Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
ThreatConnect
人人都是产品经理
人人都是产品经理
S
Securelist
G
Google Developers Blog
Martin Fowler
Martin Fowler
雷峰网
雷峰网
Stack Overflow Blog
Stack Overflow Blog
P
Privacy & Cybersecurity Law Blog
L
Lohrmann on Cybersecurity
博客园 - 【当耐特】
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog

DEV Community

I built a local voice AI that can change to 9 different personalities! UXRay: I Built an AI That Roasts Your UI Like a Senior Designer Would The contract is the interface: agent-driven Steampipe Stave in one command Gemma 4's Hidden Superpower: Why Built-in Thinking Tokens Change Everything for Evaluation Tasks ⚡ WordPress Performance: The Real Truth They Don't Tell You A Mobile App Usually Needs an Admin System First Customer Portals Should Remove Repeated Admin Work Episode 4: The Time Loop (Layers & Caching) I Built ContextForge with Gemma 4: A Project Memory Generator for Developers and AI Coding Agents Why shadow DOM beat iframe for inline tooltips HOW TO CREATE USER AND ASSIGN ROLES IN AZURE WITH ENTRA ID When AI Blackmail Goes Viral Episode 3: The Secret Scroll (The Dockerfile) Monte Carlo Simulation for Engineers: Turning Uncertainty Into Numbers The tokens-per-byte trap: character-level 'compression' adds tokens Nobody Reads Your Code Anymore Why I built a collection of 5 free, zero-signup career finance tools for solo builders 🚀 New React Challenge: Instant UI with useOptimistic Resolvendo a Alucinação da IA na Arquitetura de Software com Code Property Graphs e .NET 9 S1 — Clean Backtrace Crashes: How to Diagnose and Fix Them Cómo solucionar el bucle infinito en useEffect con objetos y arrays The Brutal Reality of Running Gemma 4 Locally I made Claude Code refuse to write code unless the ticket scores 80/100 I Fed React's Entire Hooks Transition History to Gemma 4. Here's What It Found That We Missed. Building a Private RAG System: Lessons from a Local-First AI Journal CodePulse AI — Reviving an AI-Powered Repository Intelligence Platform How to Split Video into Segments with FFmpeg (CLI + API) I've audited dozens of estate agency websites. The same 5 problems show up every single time. Part 1: Taming Asynchronous JavaScript: How to Build a "Mailbox" Queue Building My AI-Powered VS Code Extension 🚀 Google Login in Express with PassportJS & JWT Great example of Gemma 4 moving beyond chatbots into real-world decision support. Using AI to guide everyday actions like recycling shows how impactful applied LLMs can be when designed for usability, not just capability. #Gemma4 #AI #Sustainability Building a Production AI Chatbot for an Educational Institute: Architecture, Lessons & Full Stack Deep-Dive Google Login in Express with PassportJS & JWT How I reclaimed 47GB on my MacBook by cleaning developer project junk Operators Are Not Oracles: How We Learned to Stop Worrying and Love the Configuration I Built 6 Free Developer Tools for AI APIs, Cron, Docker, and Self-Hosting How I Built a Real-Time Precious Metals Price Feed for 30,000 Concurrent Users in Laravel How to Use a SERP API to Validate Whether a Project Idea Is Worth Building Gemma 4 discussions often focus on capability, but real-world impact depends on deployment context. For offline education, especially in low-connectivity regions, latency, cost, and local inference matter as much as model strength. Local Mind Explores it Space Complexity + Ω and Θ Notations Google I/O 2026 Just Confirmed the Shift From AI Chatbots to AI Agents How to Add API Monitoring to an Express App in 5 Minutes (2026) Designing an In-Game Inflation Tracking Algorithm for Web Utility Apps Google AI Studio Just Changed the Shape of App Development If you struggle to learn then this is for you. Best AI Agent Security & Guardrails Tools in 2026: LLM Guard vs NeMo vs Guardrails AI Building Dynamic RBAC in React 19: From Permission Strings to Component-Level Access Control How to Build a Self-Hosted AI Code Review Tool in Python Why We Switched from React to HTMX in Production: A 200-Site Case Study Gemma-Loom: The Intent-Based Virtual Machine (IVM) for Edge Sovereignty Java实习海投攻略:3天300个沟通,我是怎么拿到面试的 I Deployed Netflix's Web Server in 30 Seconds (And So Can You) - Docker Project 1 Debugging Android 14 WebRTC Disconnects on a coturn Relay Path 1/30 Days System Design Question Testing FastAPI + SQLAlchemy with Real PostgreSQL Fixtures: No More Mocking Misery FAQ Schema Markup Generators: What They Actually Do (and What They Don't Tell You) How a pure-TypeScript flex layout engine closed the last WASM-Yoga gap Spot instances as GitHub Actions runners Agents Need Receipts, Not Just Better Prompts readmegen — Generate beautiful README.md in seconds (12 templates, open source) When AI Reads Blueprints: The Hidden Attack Surface of Multimodal Engineering Intelligence Simplicity scales — complexity kills side projects AI does exactly what you ask — that's the problem How a model upgrade silently broke our extraction prompt (and how we caught it) The Best Form Backend for Static Sites in 2026 # ⛽ I Built a Cross-Platform Fuel Finder with React & Supabase: The Indie Dev Journey The 11 Major Cloud Service Providers in 2025 Membangun Karya Visual: Mengintip Fasilitas Multimedia dan Studio Kreatif Amikom What Is IOPS? Visualizing Database Design: From Interactive Canvas to Drizzle, Prisma, and SQL in Real-time A tool to make your GitHub README impossible to ignore 🚀 Zero-Downtime Blue-Green and IP-Based Canary Deployments on ECS Fargate I reproduced a Claude Code RCE. The bug pattern is everywhere. We Replaced Our RAG Pipeline With Persistent KV Cache. Here's What We Found. Jenkins CI/CD Pipeline for a Dockerized Node.js Application: Manual Trigger vs Automatic Trigger Using GitHub Webhooks How to Stream Live Forex Rates to Google Sheets API: A Complete Guide Small Models Will Beat Giant Models (And Most People Haven’t Realized Why Yet) How I Built 5 Linux Automation Scripts on AWS EC2 I built TokenPatch to measure AI coding cost per applied patch I built a Chrome extension to stop squinting at the web Producer audit clean, six tests red Conversa — A Multi-Agent AI Platform Powered by Gemma 4 Build a Real Agent in 15 Minutes with Gemini's New Managed Agents API What I Actually Build: AI Systems That Ship, Not Demos That Impress The Box Ticked While You Read This: LinkedIn, AI Training, and the Switch You Did Not Flip Investasi Masa Depan: Mengintip Fasilitas Laboratorium Komputer Kelas Dunia di Yogyakarta I Cancelled My $20 Claude Cowork Plan After a Week With OpenWork Stop Reviewing Every Line of AI Code - Build the Trust Stack Instead How To Build an Image Cropper in Browser (Simple Steps) I built a macOS disk cleaner for developers and just launched it would love feedback Membangun Kompetensi dan Relasi: Mengapa Ekosistem Kampus Itu Penting I Built an AI That Decides Which AI to Talk To — Running 24/7 From My Living Room Codex Team Usage SOP How to Actually Become a Programmer: The Hard Part Nobody Wants to Explain Building a Production-Style Multi-Tool AI Agent with Python, Flask, React & Gemini AI The Caretaker Sandbox: An Offline-First Visual Playground & Template Engine powered by Gemma 4 # Building Instagram OSINT Projects with HikerAPI Your AI can read. Gemma 4 can see The Battle of the Senior Dev: Why AI Gives You Wings But Only If You're Ready to Pilot
Wyrly DI: Type-safe Dependency Injection for Modern TypeScript
Valid Lab · 2026-05-23 · via DEV Community

Valid Lab

We have released Wyrly DI, a dependency injection toolkit for TypeScript.

Wyrly DI is designed for modern TypeScript applications that want dependency
injection without relying on reflect-metadata, emitDecoratorMetadata, legacy
decorators, or parameter decorators.

It focuses on:

  • standard decorators
  • type-safe tokens
  • explicit dependency definitions
  • request scopes for web applications
  • inspectable and validatable dependency graphs

In this article, "standard decorators" means TC39 decorators supported by
TypeScript 5.0 and later. This is different from the older
experimentalDecorators model that many existing DI libraries were built
around.

Links

Why another DI toolkit?

Many TypeScript DI libraries use runtime metadata to infer constructor
dependencies.

That can be convenient, but it also means important dependency information can
become hidden behind runtime metadata and decorator behavior.

Wyrly DI takes a more explicit approach.

import { Injectable, token } from "@wyrly/core";

type User = {
  id: string;
  name: string;
};

interface UserRepository {
  findById(id: string): Promise<User | null>;
}

const UserRepositoryToken = token<UserRepository>("UserRepository");

@Injectable({
  deps: [UserRepositoryToken],
  lifetime: "scoped",
})
class GetUserUseCase {
  constructor(private readonly users: UserRepository) {}

  execute(id: string) {
    return this.users.findById(id);
  }
}

Enter fullscreen mode Exit fullscreen mode

By declaring deps, dependencies remain visible to code review, static
analysis, CI, and AI-assisted development tools.

With standard decorators, Wyrly DI does not try to read constructor parameter
types from reflect-metadata. You can still use normal constructor injection,
such as constructor(private readonly users: UserRepository), but the
dependency mapping is declared explicitly with deps.

In the example above, UserRepositoryToken is used because TypeScript
interfaces do not exist at runtime. When the dependency is a class, the class
itself can also be used as a token. In other words, you can use typed tokens for
interfaces and class tokens for classes.

Type-safe tokens

TypeScript interfaces disappear at runtime, so interface-based dependencies need
a runtime token.

Wyrly DI provides typed tokens for that purpose.

const UserRepositoryToken = token<UserRepository>("UserRepository");

const users = scope.resolve(UserRepositoryToken);
// users: UserRepository

Enter fullscreen mode Exit fullscreen mode

The resolved value is inferred as UserRepository, so interface-based
dependencies can still be used in a type-safe way.

Request scopes

Web applications often need dependencies that are different for each request.

For example:

  • current user
  • request
  • response
  • unit of work
  • DataLoader
  • request-scoped cache

Wyrly DI's web adapters are built around this model:

1 HTTP request = 1 DI scope
1 GraphQL request = 1 DI scope

Enter fullscreen mode Exit fullscreen mode

Request scope is not the only supported lifetime. The core package supports
singleton, scoped, and transient, so you can model application-wide
dependencies, per-request dependencies, and dependencies that should be created
on every resolution.

For example, the Hono adapter creates a scope per request in middleware, then
lets handlers resolve dependencies from that scope.

import { Hono } from "hono";
import { createContainer } from "@wyrly/core";
import { di, getDI, type HonoDIVariables } from "@wyrly/hono";

const app = new Hono<{ Variables: HonoDIVariables }>();
const container = createContainer();

app.use(di(container));

app.get("/users/:id", async (c) => {
  const scope = getDI(c);
  const usecase = scope.resolve(GetUserUseCase);

  return c.json(await usecase.execute(c.req.param("id")));
});

Enter fullscreen mode Exit fullscreen mode

Inspecting and validating the dependency graph

Wyrly DI can inspect and validate the dependency graph.

const graph = container.inspect();

const result = container.validate();

Enter fullscreen mode Exit fullscreen mode

For example, validation can detect dangerous lifetime relationships, such as a
singleton depending on a scoped dependency.

singleton -> scoped dependency

Enter fullscreen mode Exit fullscreen mode

That kind of relationship can cause subtle bugs, such as request-specific data
being held by a singleton.

You can also put graph validation in a test and fail CI when the composition
root becomes invalid.

import { assertEquals } from "@std/assert";

Deno.test("DI graph is valid", () => {
  const result = container.validate();

  assertEquals(
    result.ok,
    true,
    result.issues.map((issue) => issue.message).join("\n"),
  );
});

Enter fullscreen mode Exit fullscreen mode

This may be unnecessary for very small applications.

But in applications that care about boundaries, such as DDD or Clean
Architecture style codebases, dependency problems become more expensive to fix
when they are discovered late.

For example:

  • a singleton service accidentally depends on a request-scoped CurrentUser
  • an application use case becomes too coupled to infrastructure details
  • a composition root grows without anyone noticing an invalid dependency relationship

Validating the graph in CI helps catch those structural problems before they
become normal parts of the codebase.

Published packages

The following packages are available:

@wyrly/core
@wyrly/next
@wyrly/express
@wyrly/hono
@wyrly/fresh
@wyrly/graphql

Enter fullscreen mode Exit fullscreen mode

Use JSR for Deno:

deno add jsr:@wyrly/core

Enter fullscreen mode Exit fullscreen mode

Use npm for Node.js and Bun:

npm install @wyrly/core

Enter fullscreen mode Exit fullscreen mode

Install adapters as needed:

npm install @wyrly/hono
npm install @wyrly/next
npm install @wyrly/graphql

Enter fullscreen mode Exit fullscreen mode

When Wyrly DI may be a good fit

Wyrly DI may fit your project if you want to:

  • avoid reflect-metadata
  • use DI with TypeScript standard decorators
  • make a composition root explicit in DDD or Clean Architecture
  • use request scopes with Next.js, Hono, Express, or GraphQL
  • make the dependency graph visible in review and CI

When another tool may be a better fit

Another tool may be a better fit if you want:

  • a full-stack framework with controllers, modules, authentication, and configuration management
  • automatic scanning and registration as the primary workflow
  • parameter decorator-based injection
  • compatibility with an existing app that deeply depends on reflect-metadata

Wyrly DI intentionally separates a small explicit DI core from framework
adapters.

Examples

The repository includes runnable examples for:

  • DDD composition root
  • Hono API
  • Express API
  • Next.js App Router
  • GraphQL request scope
  • DataLoader pattern
  • dependency graph validation

See the examples here:

github.com/valid-lab/wyrly/tree/main/examples

Closing

Wyrly DI is a toolkit for making TypeScript dependency injection explicit,
analyzable, and practical for request-scoped web applications.

The design principles are:

  • explicit dependency definitions over implicit auto-resolution
  • inspectable structure over hidden behavior
  • standard decorators over legacy decorators
  • type-safe tokens over string-only tokens
  • composition roots over automatic scanning

If that sounds useful for your project, start with @wyrly/core and the example
closest to your framework.