@tagna/udiot
v0.11.0
Published
An AI-native TypeScript framework for composable applications and web delivery
Downloads
763
Maintainers
Readme
@tagna/udiot
AI-native TypeScript framework for middleware pipelines, dependency injection, state management, typed web apps, and Express-compatible server helpers.
@tagna/udiot provides:
- Typed middleware pipelines
- Decorator-based dependency injection
- Caching and telemetry primitives
- State management utilities
- A typed web application layer under
@tagna/udiot/web - Express-oriented server helpers under
@tagna/udiot/server - A performance-focused database layer under
@tagna/udiot/database
Installation
Requirements:
- Node.js
>=20 - npm
>=9
npm install @tagna/udiotEntry Points
@tagna/udiotfor the main framework APIs@tagna/udiot/browserfor browser-oriented state and UI usage@tagna/udiot/databasefor MikroORM, DbContext-style patterns, and DI-friendly repositories@tagna/udiot/database/browserfor Supabase and Firebase client helpers@tagna/udiot/nodefor Node-specific utilities@tagna/udiot/devfor development tooling@tagna/udiot/ssgfor static generation@tagna/udiot/webfor typed app/page contracts, web building, server bootstrap, and diagnostics@tagna/udiot/serverfor Express, sessions, uploads, CSRF, request-scoped DI, and controller adapters
Middleware Pipeline
import { MiddlewarePipeline } from '@tagna/udiot';
interface AppContext {
request: { path: string };
response?: { message: string };
}
const pipeline = new MiddlewarePipeline<AppContext>();
pipeline.use(async (ctx, next) => {
await next();
});
pipeline.use(async (ctx, next) => {
ctx.response = { message: 'Hello from UDIOT' };
await next();
});
const ctx: AppContext = { request: { path: '/hello' } };
await pipeline.execute(ctx);Dependency Injection
Import reflect-metadata once before using decorators.
import 'reflect-metadata';
import { Container, Injectable } from '@tagna/udiot';
@Injectable()
class UserService {
findById(id: string) {
return { id, name: 'Alice' };
}
}
const container = new Container();
container.register(UserService);
const userService = container.resolve<UserService>(UserService);
console.log(userService.findById('123'));Express Server Helpers
import 'reflect-metadata';
import express from 'express';
import { Container, Controller, Get, Param } from '@tagna/udiot';
import {
createRequestScopeMiddleware,
createSessionMiddleware,
toExpressRouter,
} from '@tagna/udiot/server';
@Controller('/posts')
class PostsController {
@Get('/:id')
show(@Param('id') id: string) {
return { id };
}
}
const app = express();
const container = new Container();
container.register(PostsController);
app.use(express.json());
app.use(createSessionMiddleware({ secret: 'change-me' }));
app.use(createRequestScopeMiddleware({ container }));
app.use(toExpressRouter(PostsController, { container }));The server module also exports:
createNunjucksEngine()csrfMiddleware()flashMiddleware()createUploadMiddleware()expressCacheMiddleware()param()
Database
@tagna/udiot/database adds a DI-friendly database surface built around MikroORM. It keeps SQL access outside the framework core, but integrates cleanly with request-scoped containers and repository injection.
import 'reflect-metadata';
import { Injectable, ServiceScope } from '@tagna/udiot';
import {
Entity,
MikroORM,
PrimaryKey,
Property,
InjectRepository,
registerMikroOrm,
type EntityRepository,
} from '@tagna/udiot/database';
@Entity()
class User {
@PrimaryKey()
id!: number;
@Property()
email!: string;
}
@Injectable({ scope: ServiceScope.SCOPED })
class UserService {
constructor(
@InjectRepository(User) private readonly users: EntityRepository<User>,
) {}
list(): Promise<User[]> {
return this.users.findAll();
}
}CLI
The package ships with a udiot binary:
npx udiot --helpDocumentation
- Documentation index
- Installation guide
- Web application overview
- Server module overview
- Database module overview
- Dependency injection docs
- Migration from Express
License
MIT
