balda 0.0.41 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "balda",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "type": "module",
5
5
  "main": "./lib/index.cjs",
6
6
  "module": "./lib/index.js",
@@ -83,6 +83,7 @@
83
83
  "handlebars": "^4.7.8",
84
84
  "husky": "^9.1.7",
85
85
  "ioredis": "^5.8.2",
86
+ "json-schema-to-ts": "^3.1.1",
86
87
  "mqtt": "^5.14.1",
87
88
  "mustache": "^4.2.0",
88
89
  "node-cron": "^4.2.1",
package/CLAUDE.md DELETED
@@ -1,109 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- Balda is a **cross-runtime backend framework** that runs on Node.js, Bun, and Deno. It uses a decorator-based API similar to FastAPI/NestJS and provides native runtime server implementations (`Bun.serve`, `Deno.serve`, Node `http`/`https`).
8
-
9
- **Version 0.x - APIs may change. Do not use in production.**
10
-
11
- ## Common Commands
12
-
13
- ### Development
14
- - `yarn dev` - Start dev server with hot reload (Node.js)
15
- - `yarn dev:bun` - Start dev server on Bun
16
- - `yarn dev:deno` - Start dev server on Deno
17
-
18
- ### Build
19
- - `yarn build` - Build ESM + CJS output via tsup (through Docker)
20
- - `yarn build:prod` - Build with minification
21
- - `yarn build:test` - Build and cleanup (for CI)
22
-
23
- ### Testing
24
- Tests run through Docker containers for all runtimes:
25
- - `yarn test` - Run Vitest tests (Node.js)
26
- - `yarn test:bun` - Run tests on Bun
27
- - `yarn test:deno` - Run tests on Deno
28
- - `yarn test:all` - Run tests across all runtimes
29
- - `yarn test:watch` - Watch mode for Node tests
30
-
31
- Note: All test commands require `docker compose up` first.
32
-
33
- ### Benchmarks
34
- - `yarn benchmark` - Quick benchmark suite
35
- - `yarn benchmark:all` - Full benchmark comparison
36
- - `yarn benchmark:runtime` - Compare runtime performance
37
-
38
- ### Code Quality
39
- - `yarn lint` - Run ESLint
40
- - `yarn lint:fix` - Auto-fix linting issues
41
- - `yarn format` - Run Prettier
42
-
43
- ### Docker Environment
44
- The project uses Docker Compose for cross-runtime development. Services include:
45
- - `node`, `bun`, `deno` - Runtime containers
46
- - `redis`, `postgres`, `sqs` (ElasticMQ), `localstack` (S3), `mqtt` (Mosquitto), `azurite` - Infrastructure services
47
-
48
- Commands prefixed with `docker compose exec -T node` run inside the Node container.
49
-
50
- ## Architecture
51
-
52
- ### Core Design Principle: Runtime Abstraction
53
- The framework abstracts runtime differences through:
54
- - `src/runtime/native_*.ts` - Runtime-specific implementations (server, fs, crypto, os, etc.)
55
- - `src/runtime/runtime.ts` - Runtime detection singleton
56
- - `src/runtime/native_server/` - Unified server interface with per-runtime connectors
57
-
58
- ### Directory Structure
59
-
60
- ```
61
- src/
62
- ├── decorators/ # @controller, @get, @post, @validate, @middleware, @cron
63
- ├── server/ # Core Server class, router, Request/Response types
64
- ├── runtime/ # Cross-runtime abstraction layer
65
- ├── plugins/ # Middleware (bodyParser, cors, rateLimiter, etc.)
66
- ├── validator/ # Zod/Ajv integration with fast-json-stringify caching
67
- ├── queue/ # BullMQ, pg-boss, SQS, in-memory queues
68
- ├── storage/ # S3, Azure Blob, local file storage
69
- ├── mailer/ # Email with EJS/Handlebars/Mustache/Edge templates
70
- ├── cron/ # Scheduled job decorator and execution
71
- ├── mqtt/ # MQTT client wrapper
72
- ├── graphql/ # Apollo Server integration
73
- ├── logger/ # Pino-based structured logging
74
- └── cli.ts # Command-line interface
75
- ```
76
-
77
- ### Key Patterns
78
-
79
- **Decorator-Based Routing**: Controllers use class decorators with method-level route handlers. Routes register to a singleton `router` which is consumed by `ServerConnector` at `listen()` time.
80
-
81
- **Plugin System**: Plugins are middleware functions conforming to `ServerRouteMiddleware`. The `Server.applyPlugins()` method maps plugin config options to middleware, applied before global middlewares in the request chain.
82
-
83
- **Provider Pattern**: Queue and storage implementations share a common interface (`BaseQueue`, `StorageInterface`) with runtime-specific providers (BullMQ, SQS, pg-boss for queues; S3, Azure, local for storage).
84
-
85
- **Policy System**: `@policy()` decorator attaches authorization rules to routes. `PolicyManager` evaluates rules before route handlers execute.
86
-
87
- ### Entry Points
88
- - `src/index.ts` - Main library exports
89
- - `src/cli.ts` - CLI entry point (bin: `balda`)
90
- - `src/server/server.ts` - Core `Server` class
91
-
92
- ### Important Implementation Notes
93
-
94
- **Build Output**: tsup produces both ESM (`.js`) and CJS (`.cjs`) outputs with TypeScript declarations (`.d.ts`). Many dependencies are marked as `external` to remain peer dependencies.
95
-
96
- **Controller Auto-Import**: Using `controllerPatterns` in Server options, the framework uses `glob` to dynamically import controller files. This happens during `bootstrap()` before `listen()`.
97
-
98
- **Validation Caching**: Ajv schemas are compiled and cached with fast-json-stringify for serialization performance. The `AjvStateManager` manages a global Ajv instance.
99
-
100
- **Express Compatibility**: While using native runtime servers, Balda can mount Express routers via `createExpressAdapter()` and `expressMiddleware()` for migration scenarios.
101
-
102
- **Error Handling**: Custom error hierarchy extends `BaldaError`. `errorFactory()` standardizes error responses. The server auto-registers 404/405 handlers for unmatched routes.
103
-
104
- ## Testing Strategy
105
-
106
- - Unit tests use Vitest with `test/**/*.test.ts` pattern
107
- - Mock server available via `server.getMockServer()` for testing without network
108
- - Benchmark suite uses autocannon for performance regression testing
109
- - Cross-runtime testing validates behavior parity across Node/Bun/Deno