lakutata
An IoC-based application framework for Node.js and TypeScript, with one programming model for web services, CLI tools, desktop (Electron, NW.js) applications and embedded devices. An application is a tree of objects (components, providers, controllers) that a container creates. DTOs validate their options and inputs, and transports expose the controllers: HTTP (Express, Fastify), CLI (Commander), service RPC (HTTP, Socket.IO, JSON-RPC 2.0, gRPC, NATS, Electron IPC, NW.js, React Native), schedules and message queues. One controller method can serve all of them at the same time.
This package is the framework itself: it re-exports the @lakutata/* packages under the subpaths listed below and presets two components in every application, log and entrypoint. Each subpath's typings document every declaration with examples, and each @lakutata/* package has its own README.
Installation
npx @lakutata/cli create --name my-app # a new project from a template (web, service, CLI, Electron, NW.js…)
npm install lakutata # or the framework in an existing projectThe framework requires Node.js 18.10 or later (>=18.10.0); a few features require a newer version (see Getting Started). Projects use ES modules ("type": "module"), as the templates do; the package also ships CommonJS builds. The TypeScript options that the framework requires are published as lakutata/tsconfig.json:
{
"extends": "lakutata/tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
},
"include": ["src"]
}Keep include: the published options also compile JavaScript files (allowJs), so without it the build fails on a configuration file in the project root (eslint.config.js, vite.config.ts).
Transports and integrations rely on optional peer dependencies, which you install only when you use them: express or fastify, commander, socket.io, ws, database drivers (pg, mysql2, better-sqlite3…) and cache stores (redis…). Each package's README lists its own.
Usage
import {Application, DTO, type ILogger} from 'lakutata'
import {buildEntrypoints, Controller} from 'lakutata/com/entrypoint'
import {GET, ServiceAction} from 'lakutata/decorator/ctrl'
import {Expect} from 'lakutata/decorator/dto'
import {expressHTTPEntrypoint} from 'lakutata/adapter/express'
class GreetDTO extends DTO {
@Expect(DTO.String().optional().default('world'))
public name: string
}
class GreetController extends Controller {
//GET /greet?name=you, and the service action {cmd: 'greet', name: 'you'}
@GET('/greet', GreetDTO)
@ServiceAction({cmd: 'greet'}, GreetDTO)
public async greet(input: GreetDTO): Promise<{ message: string }> {
return {message: `Hello, ${input.name}!`}
}
}
Application
.run(() => ({
id: 'com.example.greeter',
name: 'Greeter',
components: {
entrypoint: buildEntrypoints({
controllers: [GreetController],
http: expressHTTPEntrypoint({port: 8080})
})
},
bootstrap: ['entrypoint']
}))
.onLaunched((app: Application, log: ILogger): void => log.info('%s started', app.appName))API
| Subpath | Package | What it provides |
|---|---|---|
lakutata | @lakutata/core | Application, Component, Provider, BaseObject, Container, DTO, Exception, Time, isPackaged, resourcesPath, validation schemas and messages |
lakutata/decorator/di | @lakutata/core | @Inject, @Configurable, @Autoload, @Lifetime, @Singleton, @Scoped, @Transient |
lakutata/decorator/dto | @lakutata/core | @Expect, @Accept, @Return, @IndexSignature |
lakutata/decorator/asst | @lakutata/core | @Before, @After |
lakutata/dtos | @lakutata/core | PaginationSearchDTO, PaginationResultDTO, paginator, FlexibleDTO, JSON Schema conversion |
lakutata/com/entrypoint | @lakutata/entrypoint | Entrypoint, buildEntrypoints, Controller, contexts, results, access control, middlewares, httpServiceEntrypoint, scheduleEntrypoint |
lakutata/decorator/ctrl | @lakutata/entrypoint | @HTTPAction, @GET…@OPTIONS, @CLIAction, @ServiceAction, @Schedule, @Prefix, @UseMiddlewares |
lakutata/adapter/express, lakutata/adapter/fastify | @lakutata/entrypoint | The HTTP adapters, staticUI (Express only) |
lakutata/adapter/commander | @lakutata/entrypoint | The CLI adapter |
lakutata/adapter/socket.io, lakutata/adapter/jsonrpc, lakutata/adapter/electron, lakutata/adapter/nwjs, lakutata/adapter/react-native | @lakutata/entrypoint | The service adapters |
lakutata/com/logger | @lakutata/logger | The Logger component, preset as log (pino-compatible JSON lines) |
lakutata/orm, lakutata/decorator/orm | @lakutata/orm | TypeORM and its decorators |
lakutata/com/database, lakutata/provider/database | @lakutata/orm | The Database component and provider, migration commands |
lakutata/com/cacher | @lakutata/cache | The Cacher component: memory, file, Redis, Memcached, MongoDB, SQLite, PostgreSQL, MySQL stores |
lakutata/com/mutex | @lakutata/mutex | The Mutex component, @Synchronized |
lakutata/com/queue | @lakutata/queue | The Queue component, @QueueAction, queueEntrypoint: message queues in memory, Redis (BullMQ), NATS JetStream, RabbitMQ or Kafka |
lakutata/com/i18n | @lakutata/i18n | The I18n component, the Translator, the language middleware |
lakutata/com/docker | @lakutata/docker | The Docker component |
lakutata/com/containerd | @lakutata/containerd | The Containerd component (containerd without Docker, BuildKit builds) |
lakutata/com/monitor | @lakutata/monitor | CPU, memory, event loop and HTTP monitors |
lakutata/security, lakutata/provider/passwordHash | @lakutata/security | Hashing, ciphers, signatures, the PasswordHash provider |
lakutata/utils | @lakutata/utils | The helpers (strings, objects, arrays, time, files, globs, encodings, guards) |
lakutata/tsconfig.json | The compiler options for applications |
Not part of this package: @lakutata/cli (the lakutata command for projects, bundles, executables, installers and migrations), @lakutata/grpc (a gRPC client, server and service adapter), @lakutata/nats (a NATS component and service adapter), @lakutata/dbus (D-Bus) and @lakutata/mcp (the Model Context Protocol).
Errors
The framework's exceptions extend Exception (from lakutata). Each one has an errno (E_…), a message, the application's ID and name, and a statusCode that the HTTP adapters use as the response status: 500 by default, 400 for invalid input, 403 when access is denied, 404 for a missing route or action, 409 when a lock is not acquired, and so on. Each package's README lists its exceptions.
See also
- The website, lakutata.com: the guides, the examples and the API reference, in English and in Chinese.
- The guides, in
doc/en(English) anddoc/zh(Chinese) in this package:Overview.md,GettingStarted.md,Concepts.md,ProjectStructure.md,ApplicationDesign.md,UpgradingFrom2.md,UpgradingFrom1.md,Application.md,Objects.md,Injection.md,Modules.md,DTOValidation.md,Exceptions.md,Logger.md,Decorator.md,Time.md,HelperFunctions.md,Controllers.md,Entrypoint.md,Middlewares.md,HTTP.md,CLI.md,ServiceCalls.md,GRPC.md,NATS.md,Schedules.md,Queue.md,Database.md,DatabaseDrivers.md,MongoEmbedded.md,Entities.md,Migrations.md,Cache.md,Mutex.md,I18n.md,DockerIntegration.md,ContainerdIntegration.md,Monitor.md,Security.md,DBus.md,MCP.md,WebRTC.md,FFI.md,Barcode.md,Thermal.md,LDAP.md,Math.md,Netif.md,Serial.md,LDAPEngine.md,Command.md,Workspaces.md,NativeAddons.md,Packaging.md,Installers.md; and the examples, indoc/en/examplesanddoc/zh/examples: whole applications built from the templates. @lakutata/cli: creating, building and packaging applications.- The official Agent Skill for AI coding assistants that work on Lakutata projects: lakutata.com/skill.
License
Lakutata is MIT licensed.