Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 4 min read

Xeno.JS: A .NET-Inspired TypeScript Framework Without Decorators or reflect-metadata

Xeno.JS: A .NET-Inspired TypeScript Framework Without Decorators or reflect-metadata I've been building and maintaining an open-source TypeScript application framework called Xeno.JS (with @xeno-js/core stable at v5.1.

Xeno.JS: A .NET-Inspired TypeScript Framework Without Decorators or reflect-metadata

I've been building and maintaining an open-source TypeScript application framework called Xeno.JS (with @xeno-js/core stable at v5.1.1 on npm).

Xeno.JS β€” Explicit application architecture without decorators or reflect-metadata.

It is a TypeScript application architecture framework inspired by .NET patterns (explicit DI container, service lifetimes, composition root, CQRS/Mediator, and execution pipelines), designed as an alternative to decorator-heavy frameworks like NestJS.

The project started from a practical question:

Can we get structured DI, lifetimes, CQRS pipelines, and clean layer boundaries in TypeScriptβ€”without relying on reflect-metadata, experimental decorators, or coupling the application to a single HTTP framework?

Here is what Xeno.JS currently provides and what is new in v5.1.1.

What Xeno.JS provides

1. Explicit Dependency Injection (No Decorators, No reflect-metadata)

Instead of inferring constructor dependencies through decorators or runtime reflection, Xeno.JS uses a typed XenoRegistry contract and explicit factory registrations inside XenoAppBuilder.

import { XenoAppBuilder } from '@xeno-js/core'
import type { XenoRegistry } from '@xeno-js/core'

interface AppRegistry extends XenoRegistry {
  USER_REPOSITORY: UserRepository
  USER_SERVICE: UserService
}

const builder = new XenoAppBuilder<AppRegistry>()
  .addServices((services) => {
    services.addScoped('USER_REPOSITORY', () => new UserRepository())
    services.addScoped('USER_SERVICE', (scope) => {
      return new UserService(scope.resolve('USER_REPOSITORY'))
    })
  })

const app = await builder.build()

await app.runInScope(async (services) => {
  const user = await services.USER_SERVICE.findById('42')
  console.log(user)
})

The container supports Singleton, Scoped, and Transient lifetimes, with runtime checks for missing registrations, duplicate tokens, circular dependencies, and singleton-to-scoped captive dependencies. On Node.js, request context and scopes propagate via AsyncLocalStorage (while the Vue integration @xeno-js/vue uses a Pinia-backed context).

2. Application-Centered CQRS & Composable Pipelines

Business use cases are modeled as Commands and Queries dispatched through a Mediator, rather than living inside HTTP controllers.

import { BaseHandler, Command } from '@xeno-js/core'
import { Result, type ResultType } from '@xeno-js/shared'

export class CreateUserCommand extends Command<User> {
  constructor(
    public readonly email: string,
    public readonly name: string,
  ) {
    super('CreateUserCommand')
  }
}

export class CreateUserHandler extends BaseHandler<CreateUserCommand, User> {
  protected async executeAsync(
    request: CreateUserCommand,
  ): Promise<ResultType<User>> {
    return Result.ok({
      id: crypto.randomUUID(),
      email: request.email,
      name: request.name,
    })
  }
}

Cross-cutting concerns plug into addPipeline() instead of being repeated across handlers:

  • Validation (@xeno-js/zod via withZodValidation or custom strategies)
  • Query caching & Command cache invalidation (withQueryCaching, in-memory or @xeno-js/redis)
  • Command idempotency & concurrency retries (withIdempotency, withConcurrency)
  • Exception handling, logging, identity enrichment, and performance tracking

Operations return explicit ResultType<T> values paired with structured AppError instances.

3. Transport-Agnostic by Design

HTTP is treated as an adapter around the application layer, not the architecture itself. The same use cases and XenoAppBuilder composition can run behind:

  • Node.js native HTTP (@xeno-js/node with withNodeHttpServer())
  • Fastify (@xeno-js/fastify with withFastify())
  • Vercel Functions (@xeno-js/vercel with XenoVercel.handle())
  • Console / CLI / background workers via app.runInScope()

Switching from @xeno-js/node to @xeno-js/fastify happens at the composition root without rewriting commands, queries, or handlers.

What's new in v5.1.1

1. Official CLI (@xeno-js/cli)

Explicit DI and CQRS add real wiring: registries, modules, commands, handlers, schemas, and routes. v5.1.1 introduces @xeno-js/cli (stable at v1.1.0) to scaffold projects and generate architecture-aligned boilerplate while keeping everything explicit and editable.

You can scaffold a feature, its CQRS operations, and expose them over HTTP in a few commands:

xeno-js g feature Products
xeno-js g command CreateProduct --feature Products
xeno-js g query GetProducts --feature Products
xeno-js g http

For a Core project, this generates the feature module and wires it into src/registry.ts, src/bootstrap.ts, and src/routes.ts using tracked managed sections in xeno.json:

src/
β”œβ”€β”€ bootstrap.ts
β”œβ”€β”€ registry.ts
└── features/
    └── products/
        β”œβ”€β”€ products.module.ts
        β”œβ”€β”€ application/
        β”‚   β”œβ”€β”€ commands/
        β”‚   β”‚   └── create-product.command.ts
        β”‚   β”œβ”€β”€ queries/
        β”‚   β”‚   └── get-products.query.ts
        β”‚   └── handlers/
        β”‚       β”œβ”€β”€ create-product.handler.ts
        β”‚       └── get-products.handler.ts
        └── infrastructure/
            └── schemas/
                β”œβ”€β”€ create-product.schema.ts
                └── get-products.schema.ts

The CLI supports both --core (Console, Node, Fastify, Vercel) and --vue projects, with optional integrations for PostgreSQL/SQLite (Drizzle), Zod, Redis, Supabase Auth, Axios, Cockatiel, Pino, and Sentry.

2. Dedicated SKILL.md for AI Coding Assistants

One recurring issue with structured frameworks is that AI coding assistants default to NestJS conventionsβ€”inventing @Injectable() decorators, bypassing the composition root, or putting business logic directly in controllers.

Xeno.JS now ships with a dedicated SKILL.md (github.com/xeno-js/skills) that documents Xeno.JS's architectural boundaries, XenoAppBuilder lifecycle, lifetime rules (including captive-dependency constraints), and exact package APIs so AI agents generate idiomatic Xeno.JS code instead of hallucinating decorator-based patterns.

Getting started

Requires Node.js 20+.

Scaffold a new project with npx:

npx @xeno-js/cli new my-api --core
cd my-api
npm run start

Or install the CLI globally:

npm install -g @xeno-js/cli
xeno-js new my-api --core

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

npm install @xeno-js/core

If you want to see a full project layout before trying it, there is a complete e-commerce example repository and a public benchmarks repository.

Trade-offs & looking for technical feedback

I want to be upfront about the trade-offs: explicit DI, a typed registry, and CQRS add more files and wiring than a minimal Express or Hono setup. If you are building a small CRUD script, Xeno.JS is probably overkill. It is aimed at TypeScript codebases where explicit boundaries, service lifetimes, and transport independence pay off over time.

I'm sharing this release because I'd love honest technical feedback from TypeScript and .NET developers:

πŸ“° 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.