exisjs 0.7.12 β†’ 0.7.14

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.
Files changed (132) hide show
  1. package/README.md +195 -39
  2. package/dist/cli/commands/run.d.ts.map +1 -1
  3. package/dist/cli/commands/run.js +3 -1
  4. package/dist/cli/commands/run.js.map +1 -1
  5. package/dist/config/types.d.ts +2 -2
  6. package/dist/config/types.d.ts.map +1 -1
  7. package/dist/decorators/params.d.ts +21 -0
  8. package/dist/decorators/params.d.ts.map +1 -1
  9. package/dist/decorators/params.js +21 -1
  10. package/dist/decorators/params.js.map +1 -1
  11. package/dist/di/container.d.ts +15 -6
  12. package/dist/di/container.d.ts.map +1 -1
  13. package/dist/di/container.js +26 -3
  14. package/dist/di/container.js.map +1 -1
  15. package/dist/di/index.d.ts +1 -1
  16. package/dist/di/index.d.ts.map +1 -1
  17. package/dist/di/index.js.map +1 -1
  18. package/dist/di/inject.d.ts +2 -1
  19. package/dist/di/inject.d.ts.map +1 -1
  20. package/dist/di/inject.js +2 -1
  21. package/dist/di/inject.js.map +1 -1
  22. package/dist/docs/ARCHITECTURE.md +130 -78
  23. package/dist/docs/BENCHMARKS.md +4 -4
  24. package/dist/docs/content/README.md +43 -44
  25. package/dist/docs/content/boundaries.mdx +138 -61
  26. package/dist/docs/content/cli/commands.mdx +151 -128
  27. package/dist/docs/content/cli/overview.mdx +61 -47
  28. package/dist/docs/content/cli/usage.mdx +107 -30
  29. package/dist/docs/content/config.mdx +145 -158
  30. package/dist/docs/content/controllers.mdx +193 -464
  31. package/dist/docs/content/cron.mdx +183 -69
  32. package/dist/docs/content/decorators.mdx +449 -154
  33. package/dist/docs/content/errors.mdx +202 -305
  34. package/dist/docs/content/exisjs-mcp.mdx +59 -49
  35. package/dist/docs/content/installation.mdx +243 -157
  36. package/dist/docs/content/introduction.mdx +220 -48
  37. package/dist/docs/content/middleware.mdx +171 -497
  38. package/dist/docs/content/modules.mdx +141 -83
  39. package/dist/docs/content/providers.mdx +216 -180
  40. package/dist/docs/content/requests.mdx +168 -488
  41. package/dist/docs/content/responses.mdx +200 -533
  42. package/dist/docs/content/routing.mdx +235 -598
  43. package/dist/docs/content/security.mdx +233 -57
  44. package/dist/docs/content/structure.mdx +151 -240
  45. package/dist/docs/content/swagger.mdx +192 -91
  46. package/dist/docs/content/testing.mdx +205 -74
  47. package/dist/docs/content/validation.mdx +479 -341
  48. package/dist/docs/reference/README.md +34 -2
  49. package/dist/docs/reference/config.mdx +277 -75
  50. package/dist/docs/reference/context.mdx +197 -106
  51. package/dist/docs/reference/cron.mdx +266 -152
  52. package/dist/docs/reference/database.mdx +135 -53
  53. package/dist/docs/reference/decorators.mdx +234 -116
  54. package/dist/docs/reference/di.mdx +146 -112
  55. package/dist/docs/reference/error.mdx +155 -178
  56. package/dist/docs/reference/exis.mdx +141 -70
  57. package/dist/docs/reference/logger.mdx +110 -126
  58. package/dist/docs/reference/middleware.mdx +235 -158
  59. package/dist/docs/reference/plugin.mdx +136 -64
  60. package/dist/docs/reference/router.mdx +275 -293
  61. package/dist/docs/reference/sanitize.mdx +91 -87
  62. package/dist/docs/reference/swagger.mdx +280 -100
  63. package/dist/docs/reference/testing.mdx +223 -89
  64. package/dist/docs/reference/validator.mdx +194 -206
  65. package/dist/lib/start-server.js +22 -8
  66. package/dist/lib/start-server.js.map +1 -1
  67. package/dist/module/module.d.ts +6 -3
  68. package/dist/module/module.d.ts.map +1 -1
  69. package/dist/module/module.js +17 -3
  70. package/dist/module/module.js.map +1 -1
  71. package/dist/router/controller-registrar.d.ts.map +1 -1
  72. package/dist/router/controller-registrar.js +26 -4
  73. package/dist/router/controller-registrar.js.map +1 -1
  74. package/dist/router/scanner/fs-scanner.d.ts.map +1 -1
  75. package/dist/router/scanner/fs-scanner.js +22 -0
  76. package/dist/router/scanner/fs-scanner.js.map +1 -1
  77. package/dist/router/types.d.ts +6 -4
  78. package/dist/router/types.d.ts.map +1 -1
  79. package/dist/server/app.d.ts +3 -1
  80. package/dist/server/app.d.ts.map +1 -1
  81. package/dist/server/app.js +24 -8
  82. package/dist/server/app.js.map +1 -1
  83. package/dist/server/bootstrapper.d.ts.map +1 -1
  84. package/dist/server/bootstrapper.js +19 -0
  85. package/dist/server/bootstrapper.js.map +1 -1
  86. package/dist/server/request.d.ts +2 -0
  87. package/dist/server/request.d.ts.map +1 -1
  88. package/dist/server/request.js +11 -0
  89. package/dist/server/request.js.map +1 -1
  90. package/dist/server/response.d.ts +10 -5
  91. package/dist/server/response.d.ts.map +1 -1
  92. package/dist/server/response.js +65 -18
  93. package/dist/server/response.js.map +1 -1
  94. package/dist/swagger/generator.d.ts.map +1 -1
  95. package/dist/swagger/generator.js +130 -10
  96. package/dist/swagger/generator.js.map +1 -1
  97. package/dist/telemetry/index.d.ts +12 -0
  98. package/dist/telemetry/index.d.ts.map +1 -0
  99. package/dist/telemetry/index.js +121 -0
  100. package/dist/telemetry/index.js.map +1 -0
  101. package/dist/testing/client.d.ts +1 -0
  102. package/dist/testing/client.d.ts.map +1 -1
  103. package/dist/testing/client.js +4 -1
  104. package/dist/testing/client.js.map +1 -1
  105. package/dist/testing/index.d.ts.map +1 -1
  106. package/dist/testing/index.js +11 -4
  107. package/dist/testing/index.js.map +1 -1
  108. package/dist/validator/builder.d.ts +26 -1
  109. package/dist/validator/builder.d.ts.map +1 -1
  110. package/dist/validator/builder.js +31 -0
  111. package/dist/validator/builder.js.map +1 -1
  112. package/dist/validator/engine.d.ts +23 -0
  113. package/dist/validator/engine.d.ts.map +1 -1
  114. package/dist/validator/engine.js +228 -31
  115. package/dist/validator/engine.js.map +1 -1
  116. package/dist/validator/index.d.ts +8 -4
  117. package/dist/validator/index.d.ts.map +1 -1
  118. package/dist/validator/index.js +4 -1
  119. package/dist/validator/index.js.map +1 -1
  120. package/dist/validator/tex-types.d.ts +19 -4
  121. package/dist/validator/tex-types.d.ts.map +1 -1
  122. package/dist/validator/tex-types.js +102 -0
  123. package/dist/validator/tex-types.js.map +1 -1
  124. package/dist/validator/tex.d.ts +1 -1
  125. package/dist/validator/tex.d.ts.map +1 -1
  126. package/dist/validator/tex.js +3 -1
  127. package/dist/validator/tex.js.map +1 -1
  128. package/dist/validator/types.d.ts +1 -0
  129. package/dist/validator/types.d.ts.map +1 -1
  130. package/package.json +46 -14
  131. package/dist/docs/content/dataloader.mdx +0 -170
  132. package/dist/docs/reference/dataloader.mdx +0 -91
@@ -1 +1 @@
1
- {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../src/di/inject.ts"],"names":[],"mappings":";;AAoBA,wBAQC;AA5BD,+CAAoD;AAGpD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,MAAM,CAAI,KAAuB;IAC/C,MAAM,KAAK,GAAG,0BAAgB,CAAC,QAAQ,EAAE,CAAA;IACzC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;AAChD,CAAC"}
1
+ {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../src/di/inject.ts"],"names":[],"mappings":";;AAqBA,wBAQC;AA7BD,+CAAoD;AAGpD;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,MAAM,CAAI,KAAuB;IAC/C,MAAM,KAAK,GAAG,0BAAgB,CAAC,QAAQ,EAAE,CAAA;IACzC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;AAChD,CAAC"}
@@ -1,110 +1,162 @@
1
1
  # ExisJS Architecture Reference
2
2
 
3
- This document is the single source of truth for how the ExisJS core engine is built internally.
4
-
5
- ExisJS core is a minimal, ultra-high-performance web framework runtime: file-system routing, dependency injection, validation (`tex`), sanitization, and an HTTP request pipeline. Everything else β€” databases, external auth providers, cache stores, queues, websockets β€” is extracted into official `@exisjs/*` packages.
3
+ This document serves as the architecture specification and technical reference for the internal subsystems, lifecycle execution pipeline, and design constraints of the ExisJS framework monorepo.
6
4
 
7
5
  ---
8
6
 
9
- ## 1. File-System Routing 🟒
10
-
11
- **What it is:** Folder-based routing mapping HTTP routes to the file system (`route.ts`, `boundary.ts`, `server.ts`, `schema.ts`, `service.ts`).
12
-
13
- **How it's implemented:** At boot, `RouteScanner` walks the configured `src/http` directory (or a custom `apiDir`) and registers discovered routes into the `Router`'s matching engine powered by the Rust `NativeRadixTree`. Folder-naming conventions are translated during the scan:
14
-
15
- - `[param]` β†’ `:param` dynamic segment
16
- - `[...param]` β†’ `*param` catch-all
17
- - `(group)` β†’ ignored entirely in the resulting URL, but still traversed for nested routes
18
-
19
- In development, routes are mounted dynamically and watched by `HotReloader`. In production, `exis build` pre-generates a route manifest (`.exis/routes-manifest.js`) for instant O(1) boot.
7
+ ## 1. Monorepo Organization & Subsystems
8
+
9
+ ExisJS is architected as a modular TypeScript monorepo backed by a native Rust engine. Heavy compute tasks (path matching, memory LRU caching, rate limit buckets, and body sanitization) are handled by Rust native bindings via N-API (`@exisjs/rs`), with pure TypeScript fallbacks ensuring cross-platform stability.
10
+
11
+ ```text
12
+ packages/
13
+ β”œβ”€β”€ exisjs/ # Core TypeScript framework, HTTP pipeline, router, DI, Swagger, Telemetry
14
+ β”œβ”€β”€ rs/ # Native Rust engine (radix routing, token bucket rate limiter, fast LRU cache)
15
+ β”œβ”€β”€ fetch/ # Lightweight, zero-dependency typed HTTP/RPC client
16
+ └── create/ # Scaffolding CLI tool (create-exisjs)
17
+ ```
18
+
19
+ ### Framework Module Mapping
20
+
21
+ | Subsystem | Source Path | Key Responsibilities |
22
+ | :--- | :--- | :--- |
23
+ | **Router Engine** | `packages/exisjs/src/router/` | File-system directory scanning, `NativeRadixTree` route compilation, route grouping `(group)`, wildcard/param segments. |
24
+ | **Dependency Injection** | `packages/exisjs/src/di/` | Hierarchical IoC container, constructor injection reflection, custom providers (`useValue`, `useFactory`, `useExisting`, `useClass`), contextual `inject()`. |
25
+ | **Validation (`tex`)** | `packages/exisjs/src/validator/` | Schema definition AST (`tex.*`), discriminated unions, coercion primitives (`tex.coerce.*`), transforms, OpenAPI 3.1 duck-typing. |
26
+ | **HTTP Pipeline** | `packages/exisjs/src/server/` | `ExisRequest`, `ExisResponse`, lifecycle hooks (`onStart`, `onClose`), cookie parsing, proxy IP resolution. |
27
+ | **Folder Boundaries** | `packages/exisjs/src/router/boundary.ts` | Cascading directory configuration, CORS headers, security middleware, and directory-scoped DI providers. |
28
+ | **Decorators & OOP** | `packages/exisjs/src/decorators/` | `@Controller`, HTTP method decorators (`@Get`, `@Post`, `@RawBody`), `@Injectable`, `@Server`, `@Boundary`. |
29
+ | **Security & Middleware** | `packages/exisjs/src/middleware/` | `helmet()`, signed CSRF cookies, `hpp()`, CIDR `ipFilter()`, native `rateLimit()`, LRU `idempotency()`, streaming `upload()`. |
30
+ | **OpenAPI / Swagger** | `packages/exisjs/src/swagger/` | Interactive Swagger UI (`/docs`), OpenAPI 3.1 spec compiler from `tex` and Zod schemas. |
31
+ | **Telemetry & Observability** | `packages/exisjs/src/telemetry/` | Built-in OpenTelemetry tracing, span processors, and Prometheus metrics. |
32
+ | **Task Scheduling** | `packages/exisjs/src/cron/` | Drift-corrected background task scheduler (`cron()`, `@Cron()`). |
33
+ | **Testing Harness** | `packages/exisjs/src/testing/` | In-memory and HTTP integration test runner (`createTestApp`, `createTestContext`). |
20
34
 
21
35
  ---
22
36
 
23
- ## 2. Dual Paradigm: Functional & Class-Based (OOP) 🟒
24
-
25
- **What it is:** Two ways to define routing and handlers β€” `controller()`/`route.*()` factory functions, or `@Controller()`/`@Get()` class decorators β€” that compile down to the same internal `Route` representation.
26
-
27
- **How it's implemented:** Class decorators attach metadata to the class prototype via symbols (`Symbol.for('exisjs:...')`) without any `reflect-metadata` dependency. The router processes both paradigms through the exact same internal pipeline. Choose one paradigm per project.
37
+ ## 2. Request Lifecycle & Execution Pipeline
38
+
39
+ Every HTTP request flows through a deterministic execution pipeline:
40
+
41
+ ```text
42
+ Incoming HTTP Request (Node HTTP / uWS)
43
+ β”‚
44
+ β–Ό
45
+ 1. Core Server Hook & Request Context Initialization (AsyncLocalStorage)
46
+ β”‚
47
+ β–Ό
48
+ 2. Global Boundary & Middleware Pipeline (CORS, Helmet, Rate Limiter, IP Filter)
49
+ β”‚
50
+ β–Ό
51
+ 3. Radix Tree Route Matching (NativeRadixTree with Rust fallback)
52
+ β”‚
53
+ β–Ό
54
+ 4. Scoped Folder Boundaries (Cascading boundary.ts configurations)
55
+ β”‚
56
+ β–Ό
57
+ 5. Parameter Extraction & Schema Validation / Coercion (tex.* on Body, Query, Params)
58
+ β”‚
59
+ β–Ό
60
+ 6. Controller Handler Execution (Functional handler or OOP controller method)
61
+ β”‚
62
+ β–Ό
63
+ 7. Response Interceptors & Formatting (Fast serialization, ETag, Status Codes)
64
+ β”‚
65
+ β–Ό
66
+ 8. Post-Response Tasks (after() deferred execution callbacks)
67
+ ```
68
+
69
+ ### Context & AsyncLocalStorage
70
+
71
+ The execution pipeline utilizes `AsyncLocalStorage` via `executionContext` (`packages/exisjs/src/di/inject.ts`). This provides request isolation across concurrent async operations, powering:
72
+ - Contextual `inject(Token)` without parameter passing.
73
+ - `req.buffer()` lazy memoization for streaming webhooks.
74
+ - Deferred post-response cleanup tasks.
28
75
 
29
76
  ---
30
77
 
31
- ## 3. The Context API & `AsyncLocalStorage` 🟒
32
-
33
- **What it is:** Access to the current request's `req`/`res`/app-scoped state from anywhere in the call graph without prop-drilling, plus `after()` for deferred post-response work.
34
-
35
- **How it's implemented:** `AsyncLocalStorage` maintains an active store per request containing `{ state, afterCallbacks, req, res, app, diCache }`. `inject()`, `getContext()`, and `after()` read from this store, guaranteeing request isolation across concurrent requests.
78
+ ## 3. Dual-Paradigm Architecture
79
+
80
+ ExisJS maintains 100% feature parity between **Functional** and **Class-Based (OOP)** paradigms. An application chooses one paradigm consistently.
81
+
82
+ ```text
83
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
84
+ β”‚ Unified Pipeline β”‚
85
+ β”‚ (Validation Engine, Radix Dispatcher, OpenAPI Generator) β”‚
86
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
87
+ β–² β–²
88
+ β”‚ β”‚
89
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
90
+ β”‚ Functional β”‚ β”‚ Class-Based β”‚
91
+ β”‚ controller() β”‚ β”‚ @Controller() β”‚
92
+ β”‚ route.get() β”‚ β”‚ @Get(), @Post() β”‚
93
+ β”‚ defineBoundary() β”‚ β”‚ @Boundary() β”‚
94
+ β”‚ exis({ onStart }) β”‚ β”‚ @Server() β”‚
95
+ β”‚ inject(Token) β”‚ β”‚ @Inject(Token) β”‚
96
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
97
+ ```
98
+
99
+ Both paradigms compile down to identical internal `RouteDescriptor` structures registered in the route table.
36
100
 
37
101
  ---
38
102
 
39
- ## 4. Dependency Injection (`Container`) 🟒
40
-
41
- **What it is:** An IoC container supporting value, factory, and class providers, with singleton and request scoping.
42
-
43
- **How it's implemented:** `Container` holds provider definitions and a singleton cache. Inside request handlers, `inject(token)` resolves dependencies dynamically using the request's context store.
103
+ ## 4. The Graceful Fallback Pattern
44
104
 
45
- ---
46
-
47
- ## 5. Folder-Scoped Boundaries (`boundary.ts`) 🟒
105
+ Subsystems interfacing with `@exisjs/rs` (Radix router, LRU cache, rate limiting, and parameter validation) implement a strict fallback pattern. If N-API native binaries fail to load on non-standard architectures, the engine seamlessly activates pure TypeScript implementations:
48
106
 
49
- **What it is:** Folder-level configuration and auto-detected request pipelines that apply to a directory and all its subdirectories recursively.
107
+ ```typescript
108
+ export class NativeSubsystemService {
109
+ private nativeEngine: any
110
+ private fallbackStore = new Map()
111
+ private isFallback = false
50
112
 
51
- **How it's implemented:**
52
- 1. **Config:** Export `config = defineBoundary(...)` (functional) or `@Boundary(...)` (OOP) to define CORS, headers, exclusions, and DI providers for that directory tree.
53
- 2. **Auto-Detected Pipeline:**
54
- - Functions matching `(req, res, next)` are auto-detected as sequential chain steps.
55
- - The default export `(ctx, next)` (functional) or class method `handle(ctx, next)` (OOP) is auto-detected as an onion wrapper around all inner steps and child routes.
113
+ constructor() {
114
+ try {
115
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
116
+ const { NativeSubsystem } = require('@exisjs/rs')
117
+ this.nativeEngine = new NativeSubsystem()
118
+ } catch {
119
+ this.isFallback = true
120
+ }
121
+ }
122
+ }
123
+ ```
56
124
 
57
125
  ---
58
126
 
59
- ## 6. Native Validation Engine (`tex`) 🟒
60
-
61
- **What it is:** A dependency-free, high-performance schema validator powered by Rust (`@exisjs/rs`) with strict typing, auto-coercion, and structured error responses.
127
+ ## 5. Dependency Injection Architecture
62
128
 
63
- **How it's implemented:** `tex` provides primitives (`string`, `number`, `boolean`, `email`, `object`, `array`, `enum`) and integrates directly with `route.*()` configs and `@Body()`. Input sanitization via `exisjs/sanitize` can be chained synchronously via `.sanitize(...)` before validation occurs.
129
+ The IoC container (`packages/exisjs/src/di/`) supports multiple provider token strategies:
64
130
 
65
- ---
66
-
67
- ## 7. Production Build & Manifest Pipeline 🟒
131
+ 1. **Class Providers**: `@Injectable()` decorated classes resolved via constructor metadata (`design:paramtypes`).
132
+ 2. **Value Providers (`useValue`)**: Static configuration, database instances, or constants.
133
+ 3. **Factory Providers (`useFactory`)**: Dynamic factory functions with dependency injection (`inject: [TokenA, TokenB]`).
134
+ 4. **Alias Providers (`useExisting`)**: Token aliases mapping to an existing provider instance.
68
135
 
69
- - **esbuild Compilation:** `exis build` bundles and transpiles TypeScript rapidly using esbuild, resolving path aliases (`@/*`).
70
- - **Route Manifest Generation:** Scans routes and writes `.exis/routes-manifest.js` to enable O(1) boot in production without recursive filesystem scanning.
71
- - **Fast Serialization:** Validated route responses integrate with JIT fast serializers.
136
+ ```typescript
137
+ // Custom Provider Registration
138
+ app.provide('DATABASE_CLIENT', {
139
+ useFactory: (url: string) => createClient(url),
140
+ inject: ['DATABASE_URL'],
141
+ })
142
+ ```
72
143
 
73
144
  ---
74
145
 
75
- ## 8. Request & Response Engine 🟒
146
+ ## 6. Validation & Schema Engine (`tex`)
76
147
 
77
- - **Request:** Native JSON body parsing and cookie parsing delegated to Rust off-heap bindings in `@exisjs/rs`, busboy for multipart form data, and robust proxy trust resolution.
78
- - **Response:** Chainable status, header, and cookie APIs, automatic ETag generation (weak ETags), and JSON auto-serialization.
148
+ The validation subsystem provides a zero-dependency schema builder and parser:
79
149
 
80
- ---
81
-
82
- ## 9. Global Error Handling 🟒
83
-
84
- Structured `HttpError` hierarchy (`badRequest`, `unauthorized`, `forbidden`, `notFound`, etc.) with consistent JSON error envelopes and dev-mode formatting.
150
+ - **Type AST**: `TexType` instances represent individual property constraints (`string`, `number`, `boolean`, `date`, `object`, `array`, `enum`, `discriminatedUnion`).
151
+ - **Coercion**: String parameter conversion via `tex.coerce.*` for query and path parameters.
152
+ - **Transformations**: Output reshaping using `.transform((val) => ...)` at the field and object level.
153
+ - **OpenAPI 3.1 Extraction**: Recursive duck typing translates `tex` schemas and external validator schemas (e.g. Zod) directly into OpenAPI 3.1 JSON Schemas.
85
154
 
86
155
  ---
87
156
 
88
- ## 10. Core Middleware Suite 🟒
89
-
90
- - **Security:** `helmet()`, `csrf()`, `hpp()`, `dbSanitize()`, `timeout()`.
91
- - **Traffic & Performance:** In-memory off-heap `rateLimit()`, `idempotent()` (keyed response caching in off-heap memory), `dedupe()`, and `backpressure()`.
92
- - **Utilities:** `cors()`, `requestId()`, `requestLogger()`, `serveStatic()`.
93
-
94
- ---
157
+ ## 7. Build Pipeline & Manifest Generation
95
158
 
96
- ## 11. Core Boundary Contract
97
-
98
- | Subsystem | Location | Scope |
99
- |---|---|---|
100
- | Routing & Boundaries | `exisjs/router` | Core runtime |
101
- | Schema & Validation | `exisjs/validator` (`tex`) | Core runtime |
102
- | Data Sanitization | `exisjs/sanitize` | Core runtime |
103
- | Dependency Injection | `exisjs/di` | Core runtime |
104
- | Core Middleware | `exisjs/middleware` | Core runtime |
105
- | CLI & Scaffolding | `exisjs/cli` | Core tooling |
106
- | Database & ORM | `@exisjs/database` | Extracted package |
107
- | Cache & Redis | `@exisjs/cache` | Extracted package |
108
- | Background Queues | `@exisjs/queue` | Extracted package |
109
- | WebSockets | `@exisjs/websocket` | Extracted package |
110
- | Auth & OAuth | `@exisjs/auth` | Extracted package |
159
+ In production mode:
160
+ 1. `exisjs build` compiles TypeScript files using `esbuild`, bundling path aliases (`@/*`).
161
+ 2. `RouteScanner` crawls `src/http/*` and writes a static route manifest to `.exis/routes-manifest.js`.
162
+ 3. In production (`exisjs start`), the server loads the precompiled manifest for $O(1)$ startup without directory traversals.
@@ -18,10 +18,10 @@
18
18
 
19
19
  | Framework | Req/Sec (median) | Latency avg (ms) | Latency p50 (ms) | Latency p99 (ms) | Errors | Server backend |
20
20
  |---|---|---|---|---|---|---|
21
- | Express | 24778.91 | 3.41 | 3.00 | 5.00 | 0 | n/a |
22
- | Fastify | 41802.19 | 2.04 | 2.00 | 3.00 | 0 | n/a |
23
- | Hono | 43174.40 | 2.04 | 2.00 | 3.00 | 0 | n/a |
24
- | Exis JS | 51430.40 | 1.26 | 1.00 | 3.00 | 0 | uws |
21
+ | Express | 24742.55 | 3.42 | 3.00 | 5.00 | 0 | n/a |
22
+ | Fastify | 41237.82 | 2.06 | 2.00 | 3.00 | 0 | n/a |
23
+ | Hono | 43640.73 | 2.01 | 2.00 | 3.00 | 0 | n/a |
24
+ | Exis JS | 47436.80 | 1.48 | 1.00 | 3.00 | 0 | uws |
25
25
 
26
26
  ### Handler Parity Note
27
27
 
@@ -1,44 +1,43 @@
1
- # ExisJS Documentation Blueprint
2
-
3
- This directory contains the core documentation for ExisJS. This `README.md` acts as a **blueprint** and index to help you navigate the features and understand what each markdown file contains.
4
-
5
- ## πŸš€ Getting Started
6
- * **`introduction.mdx`**: High-level overview of ExisJS, its philosophy, and why it exists.
7
- * **`installation.mdx`**: How to create a new project using `create-exis` and basic setup.
8
- * **`structure.mdx`**: Explains the recommended folder structure (e.g., `src/http`, `src/jobs`, `src/services`).
9
- * **`cli.mdx`**: Documentation for the Exis CLI (`exis dev`, `exis build`), including Esbuild integration and Smart Port Detection.
10
- * **`config.mdx`**: How to configure the framework using `exis.config.ts`.
11
-
12
- ## 🧠 Core Routing & HTTP
13
- * **`routing.mdx`**: Covers File-System Routing, exact matches, parameters, and wildcards using the Radix Tree.
14
- * **`controllers.mdx`**: Using OOP class-based controllers (`@Controller`) and Functional controllers.
15
- * **`gateways.mdx`**: Explains Topological folder-based middleware (e.g., `_gateway.ts`) that runs before routes in a directory.
16
- * **`middleware.mdx`**: Global and route-level middleware, CORS, and `req.log` interception.
17
- * **`requests.mdx`**: How to read query params, body data, headers, and use the global `req` object.
18
- * **`responses.mdx`**: Sending JSON, streams, raw data, and manipulating HTTP status codes.
19
-
20
- ## πŸ—οΈ Architecture & DI
21
- * **`modules.mdx`**: Grouping controllers and providers into modular chunks.
22
- * **`providers.mdx`**: Dependency Injection (DI) system, singletons, and injecting services.
23
- * **`decorators.mdx`**: Overview of all decorators available for OOP paradigms (e.g., `@Get`, `@Inject`).
24
-
25
- ## πŸ›‘οΈ Data & Validation
26
- * **`validation.mdx`**: The Zod-like type-safe validation engine (`v`), strict parsing, and the standalone `sanitize` utilities.
27
- * **`dataloader.mdx`**: Solving the N+1 database problem automatically using integrated data loaders.
28
- * **`cache.mdx`**: Application-level caching, response caching, and invalidation strategies.
29
-
30
- ## ⚑ Advanced Capabilities
31
- * **`websockets.mdx`**: Real-time bidirectional communication using the native uWebSockets integration.
32
- * **`sse.mdx`**: Server-Sent Events for one-way streaming (useful for AI text generation).
33
- * **`queues.mdx`**: Background job processing, workers, and Redis-backed queues.
34
- * **`cron.mdx`**: Scheduling recurring tasks effortlessly using `cron` syntax.
35
- * **`rpc.mdx`**: End-to-end type safety connecting the ExisJS backend with an `@exisjs/client` frontend.
36
-
37
- ## πŸ”’ Security & Reliability
38
- * **`security.mdx`**: Helmet integration, Rate Limiting, CORS configuration, and best practices.
39
- * **`errors.mdx`**: Global error handling, custom `HttpException` classes, and safe error masking in production.
40
- * **`circuit-breaker.mdx`**: Preventing cascading failures when external APIs or databases go down.
41
- * **`testing.mdx`**: Using the integrated, native `node:test` runner to test your endpoints without Jest.
42
-
43
- ## πŸ”Œ Ecosystem
44
- * **`adapters.mdx`**: How to run ExisJS inside serverless environments or mount it seamlessly alongside Next.js.
1
+ # ExisJS Documentation Content Directory
2
+
3
+ This directory contains the user guides, conceptual explanations, and how-to manuals for ExisJS.
4
+
5
+ Documentation follows the [DiΓ‘taxis Framework](https://diataxis.fr/), separating conceptual overviews, procedural how-to guides, and reference materials.
6
+
7
+ ---
8
+
9
+ ## Content Index
10
+
11
+ ### 1. Getting Started & Architecture
12
+ - [`introduction.mdx`](./introduction.mdx): Overview of framework architecture, design decisions, and supported paradigms.
13
+ - [`installation.mdx`](./installation.mdx): Prerequisites, project scaffolding (`npm create exisjs@latest`), and manual setup.
14
+ - [`structure.mdx`](./structure.mdx): Standardized directory layout (`src/http/`, `src/database/`, `src/common/`, `src/config/`, `src/cron/`).
15
+
16
+ ### 2. HTTP Routing & Request Pipeline
17
+ - [`routing.mdx`](./routing.mdx): File-system routing conventions (`route.ts`), path parameters, route groups, and handlers.
18
+ - [`controllers.mdx`](./controllers.mdx): Class-based routing, `@Controller` decorators, and parameter mappings.
19
+ - [`decorators.mdx`](./decorators.mdx): Reference guide for all decorators across routing, parameters, pipes, middlewares, security, and lifecycle.
20
+ - [`requests.mdx`](./requests.mdx): Request anatomy (`ExisRequest`), query strings, headers, cookies, and context augmentation.
21
+ - [`responses.mdx`](./responses.mdx): Response helpers, JSON output, HTTP status codes, SSE, and stream handling.
22
+ - [`boundaries.mdx`](./boundaries.mdx): Directory-scoped middleware cascading, hierarchical CORS inheritance, and boundary isolation.
23
+
24
+ ### 3. Validation, Dependency Injection & Data
25
+ - [`validation.mdx`](./validation.mdx): Schema validation engine (`tex.*`), parameter coercion, custom validators, and sanitization.
26
+ - [`providers.mdx`](./providers.mdx): Dependency injection, constructor injection, `@Injectable()`, `@Inject()`, and `forwardRef()`.
27
+ - [`modules.mdx`](./modules.mdx): Module encapsulation, `@Module()`, dynamic module registration, and `@Global()` scopes.
28
+
29
+ ### 4. Middleware, Security & Operations
30
+ - [`middleware.mdx`](./middleware.mdx): Global, boundary, and route-level middlewares, Express bridge, and execution order.
31
+ - [`security.mdx`](./security.mdx): Security headers (Helmet), CSRF tokens, CIDR IP filtering, parameter pollution, and probe blocking.
32
+ - [`errors.mdx`](./errors.mdx): HTTP exception classes, JSON error payloads, and custom error boundaries.
33
+ - [`cron.mdx`](./cron.mdx): Background task scheduling (`cron()` and `@Cron()`) with drift correction and overlap protection.
34
+ - [`swagger.mdx`](./swagger.mdx): Automatic OpenAPI 3.1 schema extraction, Swagger UI (`/docs`), and JSON documentation endpoints.
35
+ - [`testing.mdx`](./testing.mdx): Test harness (`createTestContext`, `createTestApp`), mocking utilities (`ex`), and CLI test runner.
36
+ - [`config.mdx`](./config.mdx): Global configuration options in `exis.config.ts`, lifecycle phases, clustering, and file watcher settings.
37
+ - [`exisjs-mcp.mdx`](./exisjs-mcp.mdx): Model Context Protocol (MCP) server integration for IDE AI assistants.
38
+
39
+ ### 5. CLI Tooling (`cli/`)
40
+ - [`cli/overview.mdx`](./cli/overview.mdx): CLI architecture and runtime execution.
41
+ - [`cli/usage.mdx`](./cli/usage.mdx): Basic usage and script execution.
42
+ - [`cli/commands.mdx`](./cli/commands.mdx): Reference for all CLI commands (`dev`, `build`, `start`, `routes`, `test`, `doctor`, `init`).
43
+