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/zodviawithZodValidationor 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/nodewithwithNodeHttpServer()) -
Fastify (
@xeno-js/fastifywithwithFastify()) -
Vercel Functions (
@xeno-js/vercelwithXenoVercel.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:
- How do you feel about factory-based explicit DI vs. TC39/legacy decorators?
- Does the CLI + managed-sections approach feel ergonomic or too opinionated?
- What would stop you from trying this on a real backend?
- Official website & docs: https://www.xeno-js.it/
- GitHub: https://github.com/xeno-js
-
npm (
@xeno-js/corev5.1.1): https://www.npmjs.com/package/@xeno-js/core?activeTab=readme -
AI Agent Skill (
SKILL.md): https://github.com/xeno-js/skills - E-commerce example: https://github.com/xeno-js/ecommerce-example
- Benchmarks: https://github.com/xeno-js/benchmarks
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.