Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

I Built Avi.js — A Lightweight TypeScript Framework Inspired by NestJS

I Built Avi.js — A Lightweight TypeScript Framework Inspired by NestJS I've been working on an open-source project called Avi.js, and I recently released v0.1.2! 🚀 Avi.js — Structure without the overhead. It's a ligh

I Built Avi.js — A Lightweight TypeScript Framework Inspired by NestJS

I've been working on an open-source project called Avi.js, and I recently released v0.1.2! 🚀

Avi.js — Structure without the overhead.

It's a lightweight, TypeScript-first backend framework for Node.js, inspired by the structured development experience of NestJS.

The idea started with a question:

Can we build a structured TypeScript backend framework with modules, controllers, and dependency injection—without requiring reflect-metadata?

That's what I've been exploring with Avi.js.

What I've built so far

Before getting into the latest update, here's a look at what Avi.js currently supports.

1. Modules, controllers, and dependency injection

Avi.js supports a modular architecture with explicit dependency declarations rather than relying on runtime reflection.

It includes singleton, transient, and request-scoped providers, along with startup checks for missing dependencies and circular references.

The goal is to keep dependencies visible in code while providing a familiar way to organize backend applications.

2. Two API styles, one engine

Avi.js supports two ways of defining controllers:

  • Decorator-based API: Class-based controllers and modules using standard TC39 decorators.
  • Explicit API: Plain TypeScript objects and functions without decorators.

Both approaches use the same router, dependency injection container, and request pipeline.

This gives developers the flexibility to choose the style that fits their project.

3. Dependency injection without reflect-metadata

Instead of inferring constructor dependencies through emitted runtime metadata, Avi.js uses explicit declarations such as static inject.

For example:

@Controller('/users')
class UsersController {
  static inject = [UsersService] as const;

  constructor(private readonly users: UsersService) {}
}

This approach doesn't require reflect-metadata, emitDecoratorMetadata, or legacy experimental decorators.

It's a design choice focused on making dependency wiring explicit and understandable.

4. Native Node.js HTTP

Avi.js runs on Node.js's native node:http module without requiring Express or Fastify underneath.

It supports:

  • HTTP routing and route parameters
  • Middleware and guards
  • Request and response hooks
  • JSON, text, and streaming responses
  • Graceful shutdown

5. Validation, security, and developer tooling

Avi.js also includes several features for building and maintaining backend applications:

  • Schema validation using Standard Schema-compatible libraries
  • CORS and security headers
  • OpenAPI 3.1 document generation
  • Testing utilities with provider overrides
  • CLI scaffolding and code generation
  • Startup checks for dependency and route configuration errors

These features are already available in the current early-development releases.

What's new in v0.1.2?

One feature I'm particularly excited about is resource generation.

You can now generate an entire CRUD resource using one command:

npx avi g resource posts

For a modular project, the CLI generates:

src/
└── modules/
    └── posts/
        ├── posts.module.ts
        ├── posts.controller.ts
        └── posts.service.ts

The CLI also registers the resource in your application automatically.

The generated resource includes working GET, POST, PATCH, and DELETE routes backed by an in-memory store, which you can later replace with your own database integration.

For minimal projects, Avi.js generates services and routes without requiring modules.

The goal is to reduce repetitive setup while keeping the generated code understandable and editable.

Getting started

You can try Avi.js with Node.js 22.12 or newer.

Create a new project:

npm create avi@latest my-api
cd my-api
npm install
npm run dev

Avi.js currently provides two official project templates:

  • Modular (default): A feature-first structure with modules, controllers, and services.
  • Minimal: A smaller, functional structure using explicit routes and services.

Both templates run on the same framework engine, so you can start small and introduce more structure as your application grows.

You can also install the core package directly into an existing project:

npm install @avijs/core

Why am I sharing this?

Avi.js is still in pre-alpha development (0.x), and its APIs may change before 1.0.

I'm not trying to claim it's faster or better than established frameworks. It's an experiment in building a structured backend framework with explicit dependencies and fewer runtime abstractions.

I'm sharing it because I'd love to get feedback from developers who enjoy working with Node.js and TypeScript.

If you're curious, feel free to try it, open an issue, or contribute.

Official website: https://chrischase011.github.io/avi-js/

GitHub: https://github.com/chrischase011/avi-js

Latest release: https://github.com/chrischase011/avi-js/releases/tag/v0.1.2

Thanks for checking it out! 🚀

#typescript #nodejs #opensource #webdev

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.