exisjs 0.7.11 → 0.7.13

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 (150) hide show
  1. package/README.md +195 -39
  2. package/dist/cli/commands/dev.d.ts +4 -0
  3. package/dist/cli/commands/dev.d.ts.map +1 -1
  4. package/dist/cli/commands/dev.js +136 -32
  5. package/dist/cli/commands/dev.js.map +1 -1
  6. package/dist/cli/commands/run.d.ts +7 -0
  7. package/dist/cli/commands/run.d.ts.map +1 -0
  8. package/dist/cli/commands/run.js +99 -0
  9. package/dist/cli/commands/run.js.map +1 -0
  10. package/dist/cli/index.js +29 -13
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/cli/manifest.d.ts.map +1 -1
  13. package/dist/cli/manifest.js +18 -3
  14. package/dist/cli/manifest.js.map +1 -1
  15. package/dist/cli/routes.d.ts +6 -0
  16. package/dist/cli/routes.d.ts.map +1 -1
  17. package/dist/cli/routes.js +224 -135
  18. package/dist/cli/routes.js.map +1 -1
  19. package/dist/config/config.d.ts +2 -1
  20. package/dist/config/config.d.ts.map +1 -1
  21. package/dist/config/config.js.map +1 -1
  22. package/dist/config/types.d.ts +30 -9
  23. package/dist/config/types.d.ts.map +1 -1
  24. package/dist/database/lifecycle.d.ts +6 -1
  25. package/dist/database/lifecycle.d.ts.map +1 -1
  26. package/dist/database/lifecycle.js +15 -4
  27. package/dist/database/lifecycle.js.map +1 -1
  28. package/dist/decorators/params.d.ts +21 -0
  29. package/dist/decorators/params.d.ts.map +1 -1
  30. package/dist/decorators/params.js +21 -1
  31. package/dist/decorators/params.js.map +1 -1
  32. package/dist/di/container.d.ts +15 -6
  33. package/dist/di/container.d.ts.map +1 -1
  34. package/dist/di/container.js +26 -3
  35. package/dist/di/container.js.map +1 -1
  36. package/dist/di/index.d.ts +1 -1
  37. package/dist/di/index.d.ts.map +1 -1
  38. package/dist/di/index.js.map +1 -1
  39. package/dist/di/inject.d.ts +2 -1
  40. package/dist/di/inject.d.ts.map +1 -1
  41. package/dist/di/inject.js +2 -1
  42. package/dist/di/inject.js.map +1 -1
  43. package/dist/docs/BENCHMARKS.md +4 -4
  44. package/dist/docs/content/README.md +43 -44
  45. package/dist/docs/content/boundaries.mdx +141 -48
  46. package/dist/docs/content/cli/commands.mdx +161 -107
  47. package/dist/docs/content/cli/overview.mdx +61 -46
  48. package/dist/docs/content/cli/usage.mdx +107 -30
  49. package/dist/docs/content/config.mdx +145 -147
  50. package/dist/docs/content/controllers.mdx +193 -464
  51. package/dist/docs/content/cron.mdx +183 -69
  52. package/dist/docs/content/decorators.mdx +449 -154
  53. package/dist/docs/content/errors.mdx +202 -305
  54. package/dist/docs/content/exisjs-mcp.mdx +59 -49
  55. package/dist/docs/content/installation.mdx +243 -157
  56. package/dist/docs/content/introduction.mdx +220 -48
  57. package/dist/docs/content/middleware.mdx +171 -497
  58. package/dist/docs/content/modules.mdx +141 -83
  59. package/dist/docs/content/providers.mdx +216 -180
  60. package/dist/docs/content/requests.mdx +168 -488
  61. package/dist/docs/content/responses.mdx +200 -533
  62. package/dist/docs/content/routing.mdx +239 -558
  63. package/dist/docs/content/security.mdx +233 -57
  64. package/dist/docs/content/structure.mdx +151 -240
  65. package/dist/docs/content/swagger.mdx +192 -91
  66. package/dist/docs/content/testing.mdx +205 -74
  67. package/dist/docs/content/validation.mdx +479 -341
  68. package/dist/docs/reference/README.md +34 -2
  69. package/dist/docs/reference/config.mdx +277 -73
  70. package/dist/docs/reference/context.mdx +197 -106
  71. package/dist/docs/reference/cron.mdx +266 -152
  72. package/dist/docs/reference/database.mdx +135 -53
  73. package/dist/docs/reference/decorators.mdx +234 -116
  74. package/dist/docs/reference/di.mdx +146 -112
  75. package/dist/docs/reference/error.mdx +155 -178
  76. package/dist/docs/reference/exis.mdx +141 -70
  77. package/dist/docs/reference/logger.mdx +110 -126
  78. package/dist/docs/reference/middleware.mdx +235 -158
  79. package/dist/docs/reference/plugin.mdx +136 -64
  80. package/dist/docs/reference/router.mdx +277 -251
  81. package/dist/docs/reference/sanitize.mdx +91 -87
  82. package/dist/docs/reference/swagger.mdx +280 -100
  83. package/dist/docs/reference/testing.mdx +223 -89
  84. package/dist/docs/reference/validator.mdx +194 -206
  85. package/dist/lib/inspect-routes.d.ts +2 -0
  86. package/dist/lib/inspect-routes.d.ts.map +1 -0
  87. package/dist/lib/inspect-routes.js +148 -0
  88. package/dist/lib/inspect-routes.js.map +1 -0
  89. package/dist/lib/start-server.js +13 -8
  90. package/dist/lib/start-server.js.map +1 -1
  91. package/dist/module/module.d.ts +6 -3
  92. package/dist/module/module.d.ts.map +1 -1
  93. package/dist/module/module.js +17 -3
  94. package/dist/module/module.js.map +1 -1
  95. package/dist/router/controller-registrar.d.ts.map +1 -1
  96. package/dist/router/controller-registrar.js +26 -4
  97. package/dist/router/controller-registrar.js.map +1 -1
  98. package/dist/router/scanner/cron-mounter.d.ts.map +1 -1
  99. package/dist/router/scanner/cron-mounter.js +9 -2
  100. package/dist/router/scanner/cron-mounter.js.map +1 -1
  101. package/dist/server/app.d.ts +3 -1
  102. package/dist/server/app.d.ts.map +1 -1
  103. package/dist/server/app.js +29 -8
  104. package/dist/server/app.js.map +1 -1
  105. package/dist/server/define.d.ts.map +1 -1
  106. package/dist/server/define.js +5 -0
  107. package/dist/server/define.js.map +1 -1
  108. package/dist/server/request.d.ts +2 -0
  109. package/dist/server/request.d.ts.map +1 -1
  110. package/dist/server/request.js +11 -0
  111. package/dist/server/request.js.map +1 -1
  112. package/dist/swagger/generator.d.ts.map +1 -1
  113. package/dist/swagger/generator.js +130 -10
  114. package/dist/swagger/generator.js.map +1 -1
  115. package/dist/telemetry/index.d.ts +12 -0
  116. package/dist/telemetry/index.d.ts.map +1 -0
  117. package/dist/telemetry/index.js +121 -0
  118. package/dist/telemetry/index.js.map +1 -0
  119. package/dist/testing/client.d.ts +1 -0
  120. package/dist/testing/client.d.ts.map +1 -1
  121. package/dist/testing/client.js +4 -1
  122. package/dist/testing/client.js.map +1 -1
  123. package/dist/testing/index.d.ts.map +1 -1
  124. package/dist/testing/index.js +20 -4
  125. package/dist/testing/index.js.map +1 -1
  126. package/dist/validator/builder.d.ts +26 -1
  127. package/dist/validator/builder.d.ts.map +1 -1
  128. package/dist/validator/builder.js +31 -0
  129. package/dist/validator/builder.js.map +1 -1
  130. package/dist/validator/engine.d.ts +23 -0
  131. package/dist/validator/engine.d.ts.map +1 -1
  132. package/dist/validator/engine.js +228 -31
  133. package/dist/validator/engine.js.map +1 -1
  134. package/dist/validator/index.d.ts +8 -4
  135. package/dist/validator/index.d.ts.map +1 -1
  136. package/dist/validator/index.js +4 -1
  137. package/dist/validator/index.js.map +1 -1
  138. package/dist/validator/tex-types.d.ts +15 -0
  139. package/dist/validator/tex-types.d.ts.map +1 -1
  140. package/dist/validator/tex-types.js +102 -0
  141. package/dist/validator/tex-types.js.map +1 -1
  142. package/dist/validator/tex.d.ts +1 -1
  143. package/dist/validator/tex.d.ts.map +1 -1
  144. package/dist/validator/tex.js +3 -1
  145. package/dist/validator/tex.js.map +1 -1
  146. package/dist/validator/types.d.ts +1 -0
  147. package/dist/validator/types.d.ts.map +1 -1
  148. package/package.json +47 -14
  149. package/dist/docs/content/dataloader.mdx +0 -170
  150. package/dist/docs/reference/dataloader.mdx +0 -91
@@ -1,3 +1,35 @@
1
- # Reference
1
+ # ExisJS API Reference Catalog
2
2
 
3
- This folder contains detailed API references, configuration options (`exis.config.ts`), and advanced framework capabilities for Exis JS.
3
+ This directory contains complete, information-dense API references, TypeScript interfaces, and method signatures for all public packages and subpath exports in the ExisJS framework.
4
+
5
+ ---
6
+
7
+ ## Reference Index
8
+
9
+ | Module / Entrypoint | Document | Description |
10
+ | :------------------ | :------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------- |
11
+ | `exisjs` | [`exis.mdx`](file:///z:/projects/framework/exisjs/docs/reference/exis.mdx) | Root application builder (`exis` / `defineApp`), `App` instance methods, and process resolvers. |
12
+ | `exisjs/config` | [`config.mdx`](file:///z:/projects/framework/exisjs/docs/reference/config.mdx) | Configuration schema (`ExisConfig`, `WatchConfig`, `DevConfig`), environment parsing, and phases. |
13
+ | `exisjs/router` | [`router.mdx`](file:///z:/projects/framework/exisjs/docs/reference/router.mdx) | Functional route builder (`route.*`, `controller`), `Router` engine, and request/response types. |
14
+ | `exisjs/decorators` | [`decorators.mdx`](file:///z:/projects/framework/exisjs/docs/reference/decorators.mdx) | Class, method, and parameter decorators for OOP architecture (`@Controller`, `@Get`, `@Body`). |
15
+ | `exisjs/validator` | [`validator.mdx`](file:///z:/projects/framework/exisjs/docs/reference/validator.mdx) | `TexEngine` validator suite (`tex.*`), schema modifiers (`.optional()`, `.default()`), and pipes. |
16
+ | `exisjs/database` | [`database.mdx`](file:///z:/projects/framework/exisjs/docs/reference/database.mdx) | Database lifecycle coordinator (`registerDatabase`, `DatabaseManager`), and transactions. |
17
+ | `exisjs/logger` | [`logger.mdx`](file:///z:/projects/framework/exisjs/docs/reference/logger.mdx) | Structured Pino logger interface, log levels, sensitive credential redaction, and formatters. |
18
+ | `exisjs/di` | [`di.mdx`](file:///z:/projects/framework/exisjs/docs/reference/di.mdx) | Inversion of Control `Container`, dependency injection tokens, `inject()`, and `forwardRef()`. |
19
+ | `exisjs/error` | [`error.mdx`](file:///z:/projects/framework/exisjs/docs/reference/error.mdx) | HTTP exception hierarchy (`HttpError`, `BadRequestException`), error codes, and JSON envelopes. |
20
+ | `exisjs/middleware` | [`middleware.mdx`](file:///z:/projects/framework/exisjs/docs/reference/middleware.mdx) | Built-in middleware suite: Helmet, CORS, CSRF, rate limiting, IP filtering, and multipart uploads. |
21
+ | `exisjs/context` | [`context.mdx`](file:///z:/projects/framework/exisjs/docs/reference/context.mdx) | `AsyncLocalStorage` request context API (`getRequest`, `getResponse`, `getContext`, `after`). |
22
+ | `exisjs/cron` | [`cron.mdx`](file:///z:/projects/framework/exisjs/docs/reference/cron.mdx) | Task scheduler (`cron()`, `@Cron()`), interval timers, presets, and `CronManager` runtime controls. |
23
+ | `exisjs/sanitize` | [`sanitize.mdx`](file:///z:/projects/framework/exisjs/docs/reference/sanitize.mdx) | Rust-accelerated security cleaners (`escapeHtml`, `preventSql`) and data transform utilities. |
24
+ | `exisjs/swagger` | [`swagger.mdx`](file:///z:/projects/framework/exisjs/docs/reference/swagger.mdx) | OpenAPI 3.1 specification generation, Swagger UI / Scalar interactive rendering, and decorators. |
25
+ | `exisjs/testing` | [`testing.mdx`](file:///z:/projects/framework/exisjs/docs/reference/testing.mdx) | Test runner (`node:test`), synthetic HTTP client (`createTestApp`), `expect` matchers, and `ex` mocks. |
26
+ | `exisjs/plugin` | [`plugin.mdx`](file:///z:/projects/framework/exisjs/docs/reference/plugin.mdx) | Modular plugin development (`definePlugin`), lifecycle hooks, and dependency encapsulation. |
27
+
28
+ ---
29
+
30
+ ## Diátaxis Alignment
31
+
32
+ The reference documents in this directory are structured strictly for **lookup and precision** according to the Diátaxis framework:
33
+
34
+ - **Information-Dense**: Method signatures, return types, and default option tables.
35
+ - **Accurate & Tested**: 100% verified against monorepo source files under `packages/exisjs/src/*`.
@@ -1,129 +1,333 @@
1
1
  ---
2
- title: 'Configuration'
3
- description: 'API Reference for the global exis.config.ts file (`exisjs/config`).'
2
+ title: "exisjs/config"
3
+ description: "API Reference for ExisJS global configuration (exis.config.ts), defineConfig helper, configuration phases, and environment loader utilities."
4
+ nextUrl: "/docs/reference/router"
5
+ nextTitle: "Router Reference"
4
6
  ---
5
7
 
6
- # Configuration (`exisjs/config`)
8
+ # `exisjs/config`
7
9
 
8
- ExisJS is designed to be highly zero-config out of the box. However, for advanced tuning, security, and clustering, you can define an `exis.config.ts` file in the root of your project.
10
+ The `exisjs/config` module exposes configuration types, Phase constants, the `defineConfig()` helper, and environment-loading utilities used by `exis.config.ts` and runtime server initializers.
9
11
 
10
- This configuration file deeply integrates with the framework's core, managing everything from global middleware (like CORS and Helmet) to underlying Server backends and Worker Threads.
12
+ ---
13
+
14
+ ## Module Exports
15
+
16
+ ```typescript
17
+ import {
18
+ defineConfig,
19
+ mergeConfig,
20
+ loadConfig,
21
+ defaultConfig,
22
+ loadEnv,
23
+ processEnv,
24
+ resetEnv,
25
+ parseEnv,
26
+ PHASE_DEVELOPMENT_SERVER,
27
+ PHASE_PRODUCTION_BUILD,
28
+ PHASE_PRODUCTION_SERVER,
29
+ PHASE_TEST,
30
+ } from 'exisjs/config'
31
+
32
+ import type {
33
+ ExisConfig,
34
+ ResolvedConfig,
35
+ CorsConfig,
36
+ LoggerConfig,
37
+ HelmetConfig,
38
+ KeepAliveConfig,
39
+ TelemetryConfig,
40
+ MetricsConfig,
41
+ HealthCheckConfig,
42
+ SwaggerConfig,
43
+ WatchConfig,
44
+ DevConfig,
45
+ } from 'exisjs/config'
46
+ ```
11
47
 
12
48
  ---
13
49
 
14
- ## 1. Standard Configuration
50
+ ## `defineConfig(config)`
15
51
 
16
- For most applications, you can simply export a static configuration object typed with `ExisConfig`.
52
+ A type-helper function that returns the passed `ExisConfig` object without modifications, providing TypeScript autocompletion and validation in IDEs.
53
+
54
+ ```typescript
55
+ function defineConfig(config: ExisConfig): ExisConfig
56
+ ```
57
+
58
+ ### Static Configuration Example
17
59
 
18
60
  ```typescript filename="exis.config.ts"
19
- import type { ExisConfig } from 'exisjs/config'
61
+ import { defineConfig } from 'exisjs/config'
20
62
 
21
- const config: ExisConfig = {
22
- port: Number(process.env.PORT) || 4000,
63
+ export default defineConfig({
64
+ port: 4000,
23
65
  host: '0.0.0.0',
24
-
25
66
  cors: {
26
- origin: process.env.CORS_ORIGIN || '*',
67
+ origin: ['https://example.com', 'https://admin.example.com'],
27
68
  credentials: true,
69
+ methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
70
+ },
71
+ helmet: {
72
+ enabled: true,
73
+ contentSecurityPolicy: true,
74
+ xFrameOptions: 'SAMEORIGIN',
28
75
  },
29
-
30
76
  logger: {
31
- level: 'debug',
32
- pretty: process.env.NODE_ENV !== 'production',
77
+ level: 'info',
78
+ pretty: false,
79
+ redact: ['req.headers.authorization', 'req.headers.cookie'],
33
80
  },
34
-
35
- queue: {
36
- driver: 'memory',
81
+ cluster: {
82
+ workers: 'safe',
37
83
  },
38
-
39
- helmet: { enabled: true },
40
- compression: true,
41
-
42
- test: {
43
- include: ['tests/**/*.test.ts'],
84
+ telemetry: {
85
+ enabled: true,
86
+ serviceName: 'order-service',
87
+ exporter: 'otlp',
44
88
  },
45
- }
46
-
47
- export default config
89
+ healthcheck: {
90
+ enabled: true,
91
+ path: '/healthz',
92
+ },
93
+ docs: {
94
+ enabled: true,
95
+ path: '/api/docs',
96
+ title: 'Order Service API',
97
+ version: '1.0.0',
98
+ },
99
+ })
48
100
  ```
49
101
 
50
102
  ---
51
103
 
52
- ## 2. Advanced Configuration (Phases)
104
+ ## Dynamic Phase-Based Configuration
53
105
 
54
- If you need dynamic configuration (such as spawning worker threads only in production or altering middleware depending on the environment), you can use `defineConfig()` and Phase execution.
106
+ You can export an asynchronous function from `exis.config.ts`. ExisJS passes the active phase string as the first argument, allowing you to alter settings depending on whether the application is running in development, building for production, running in production, or executing tests.
55
107
 
56
108
  ```typescript filename="exis.config.ts"
57
- import { defineConfig, PHASE_DEVELOPMENT_SERVER } from 'exisjs/config'
58
-
59
- export default async (phase: string, { defaultConfig }) => {
109
+ import {
110
+ defineConfig,
111
+ PHASE_DEVELOPMENT_SERVER,
112
+ PHASE_PRODUCTION_BUILD,
113
+ PHASE_PRODUCTION_SERVER,
114
+ PHASE_TEST,
115
+ } from 'exisjs/config'
116
+
117
+ export default async function (phase: string, { defaultConfig }: { defaultConfig: any }) {
60
118
  const isDev = phase === PHASE_DEVELOPMENT_SERVER
119
+ const isTest = phase === PHASE_TEST
61
120
 
62
121
  return defineConfig({
63
- port: Number(process.env.PORT) || 4000,
122
+ port: isTest ? 0 : Number(process.env.PORT) || 4000,
123
+ host: '0.0.0.0',
64
124
 
65
- // Auto-spawn Worker threads based on CPU cores!
66
- workers: isDev ? 1 : 'safe',
125
+ // Spawn 1 worker in dev, safe CPU count in production
126
+ cluster: {
127
+ workers: isDev || isTest ? 1 : 'safe',
128
+ },
67
129
 
68
- // Globally configure native middleware
130
+ // Permissive CORS in local development, strict origins in production
69
131
  cors: {
70
- origin: isDev ? '*' : 'https://myapp.com',
132
+ origin: isDev ? '*' : ['https://app.example.com'],
71
133
  credentials: true,
72
134
  },
73
- helmet: { enabled: true },
74
- logger: isDev ? { level: 'debug', pretty: true } : false,
75
135
 
76
- // Native plugin registration
77
- plugins: [
78
- // ... your plugins here
79
- ],
136
+ // Human-readable logs in development, JSON structured logs in production
137
+ logger: isDev
138
+ ? { level: 'debug', pretty: true }
139
+ : isTest
140
+ ? false
141
+ : { level: 'info', pretty: false },
142
+
143
+ // Enable API documentation in development only
144
+ docs: {
145
+ enabled: isDev,
146
+ path: '/docs',
147
+ },
80
148
  })
81
149
  }
82
150
  ```
83
151
 
152
+ ### Phase Constants
153
+
154
+ | Constant | Value | Triggered When |
155
+ | :--- | :--- | :--- |
156
+ | `PHASE_DEVELOPMENT_SERVER` | `'phase-development-server'` | Executing `npx exisjs dev` |
157
+ | `PHASE_PRODUCTION_BUILD` | `'phase-production-build'` | Executing `npx exisjs build` |
158
+ | `PHASE_PRODUCTION_SERVER` | `'phase-production-server'` | Executing `npx exisjs start` |
159
+ | `PHASE_TEST` | `'phase-test'` | Executing `npx exisjs test` |
160
+
84
161
  ---
85
162
 
86
- ## Configuration Phases
163
+ ## `ExisConfig` Interface Reference
164
+
165
+ The root configuration schema accepted by `exis.config.ts`:
166
+
167
+ ### Network & Core Server Options
168
+
169
+ | Property | Type | Default | Description |
170
+ | :--- | :--- | :--- | :--- |
171
+ | `port` | `number` | `4000` | Port for the HTTP server to listen on. Can be overridden via CLI `-p`. |
172
+ | `host` | `string` | `'0.0.0.0'` | Network interface binding. |
173
+ | `server` | `'auto' \| 'node' \| 'bun' \| 'uws'` | `'auto'` | HTTP server backend. Automatically selects Bun or Node when detected. |
174
+ | `cluster` | `{ workers?: number \| 'auto' \| 'safe' \| 'max' }` | `{ workers: 1 }` | Multi-process worker clustering. `'safe'` uses available CPU cores minus 1; `'max'` uses all available cores. |
175
+ | `trustProxy` | `boolean \| number` | `false` | Enables reverse-proxy IP headers (`X-Forwarded-For`, `CF-Connecting-IP`, `True-Client-IP`). |
176
+ | `bodyLimit` | `number` | `10485760` (10MB) | Maximum payload size in bytes for JSON and URL-encoded request bodies. |
177
+ | `compression` | `boolean` | `false` | Enables gzip and Brotli response compression. |
178
+ | `etag` | `boolean` | `false` | Enables ETag computation for dynamic responses. |
179
+ | `debugRouting` | `boolean` | `false` | Logs the matched file-system route file and applied boundaries for every request. |
180
+ | `asyncContext` | `boolean` | `false` | Enables `AsyncLocalStorage` context tracking (`getContext()`). |
181
+ | `transformResponse` | `boolean \| ((data: any, req: any, res: any) => any)` | `false` | Global transformation function to wrap route responses in a standardized envelope. |
182
+
183
+ ### Security & Middlewares
184
+
185
+ | Property | Type | Default | Description |
186
+ | :--- | :--- | :--- | :--- |
187
+ | `cors` | `boolean \| CorsConfig` | `{ origin: '*', methods: ['GET', 'POST', ...] }` | Cross-Origin Resource Sharing settings. Set to `false` to disable. |
188
+ | `helmet` | `boolean \| HelmetConfig` | `{ enabled: true }` | Strict security response headers (CSP, X-Frame-Options, X-Content-Type-Options). |
189
+ | `logger` | `boolean \| LoggerConfig` | `false` | Pino structured logger configuration with automatic credential redaction. |
190
+ | `blockSuspiciousProbes` | `boolean \| BlockProbesOptions` | `false` | Automatically drops requests targeting known exploit paths (`.env`, `.git`, `wp-admin`). |
191
+ | `keepAlive` | `boolean \| KeepAliveConfig` | `false` | HTTP keep-alive timeout and connection socket limits. |
192
+
193
+ ### Observability & Diagnostics
194
+
195
+ | Property | Type | Default | Description |
196
+ | :--- | :--- | :--- | :--- |
197
+ | `telemetry` | `boolean \| TelemetryConfig` | `{ enabled: false, exporter: 'console' }` | OpenTelemetry tracing and span reporting (`'otlp'` or `'console'`). |
198
+ | `metrics` | `boolean \| MetricsConfig` | `{ enabled: false, path: '/metrics' }` | Prometheus-compatible metrics endpoint. |
199
+ | `healthcheck` | `boolean \| HealthCheckConfig` | `{ enabled: false, path: '/_health' }` | Liveness and readiness health probe route. |
200
+ | `docs` | `boolean \| SwaggerConfig` | `{ enabled: false, path: '/docs' }` | Interactive OpenAPI / Swagger UI documentation generation. |
87
201
 
88
- If you export a function from `exis.config.ts`, ExisJS will inject the current "Phase" string as the first argument, allowing you to dynamically adjust settings based on whether you are running a dev server, running tests, or building for production.
202
+ ### Development & File Watching
89
203
 
90
- - `PHASE_DEVELOPMENT_SERVER`: Emitted during `exis dev`
91
- - `PHASE_PRODUCTION_BUILD`: Emitted during `exis build`
92
- - `PHASE_PRODUCTION_SERVER`: Emitted during `exis start`
93
- - `PHASE_TEST`: Emitted during test runs
204
+ | Property | Type | Default | Description |
205
+ | :--- | :--- | :--- | :--- |
206
+ | `watch` | `WatchConfig` | `{ debounceMs: 250 }` | File watching paths, patterns, and debounce timings. |
207
+ | `dev` | `DevConfig` | `{ usePolling: true }` | Development server settings, including chokidar polling interval for Windows environments. |
208
+ | `plugins` | `ExisPlugin[]` | `[]` | Array of framework plugins to initialize during application bootstrap. |
209
+ | `test` | `TestConfig` | `{ include: ['tests/**/*.test.ts'] }` | Test file matching patterns and setup file scripts. |
94
210
 
95
211
  ---
96
212
 
97
- ## Configuration Options
213
+ ## Sub-Configuration Interfaces
98
214
 
99
- Here is the full list of options supported natively by the ExisJS configuration engine:
215
+ ### `CorsConfig`
100
216
 
101
- ### Server & Network
217
+ ```typescript
218
+ export interface CorsConfig {
219
+ origin?: boolean | string | RegExp | (string | RegExp)[] | CorsOriginFn
220
+ methods?: string[]
221
+ allowedHeaders?: string[]
222
+ exposedHeaders?: string[]
223
+ credentials?: boolean
224
+ maxAge?: number
225
+ preflightContinue?: boolean
226
+ }
227
+ ```
102
228
 
103
- - **`port`** _(number)_: The port the server listens on (default: `4000`).
104
- - **`host`** _(string)_: The host interface to bind to (default: `'0.0.0.0'`).
105
- - **`server`** _(`'node' | 'uws' | 'auto'`)_: ExisJS supports running on standard Node `http`, or incredibly fast C++ `uWebSockets.js` (`uws`). Default is `'auto'` (uses `uws` if installed, falls back to `node`).
106
- - **`workers`** _(number | `'safe'` | `'max'`)_: Number of Node.js Cluster workers to spawn. `'max'` uses all CPU cores. `'safe'` uses all cores minus 1 (to leave room for the OS).
107
- - **`trustProxy`** _(boolean | number)_: Enable if running behind reverse proxies or CDNs (Cloudflare, AWS ALB, NGINX, Render) to evaluate `CF-Connecting-IP`, `True-Client-IP`, `X-Real-IP`, and `X-Forwarded-For`. (Can also be enabled via `TRUST_PROXY=true`).
229
+ ### `LoggerConfig`
108
230
 
109
- ### Security & Middlewares
231
+ ```typescript
232
+ export interface LoggerConfig {
233
+ level?: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'
234
+ pretty?: boolean
235
+ redact?: string[]
236
+ }
237
+ ```
238
+
239
+ ### `HelmetConfig`
240
+
241
+ ```typescript
242
+ export interface HelmetConfig {
243
+ enabled?: boolean
244
+ contentSecurityPolicy?: boolean
245
+ xFrameOptions?: 'DENY' | 'SAMEORIGIN'
246
+ }
247
+ ```
248
+
249
+ ### `TelemetryConfig`
250
+
251
+ ```typescript
252
+ export interface TelemetryConfig {
253
+ enabled: boolean
254
+ serviceName?: string
255
+ exporter?: 'otlp' | 'console'
256
+ endpoint?: string
257
+ }
258
+ ```
259
+
260
+ ### `HealthCheckConfig`
261
+
262
+ ```typescript
263
+ export interface HealthCheckConfig {
264
+ enabled: boolean
265
+ path?: string
266
+ checks?: (() => Promise<boolean>)[]
267
+ }
268
+ ```
269
+
270
+ ### `SwaggerConfig`
271
+
272
+ ```typescript
273
+ export interface SwaggerConfig {
274
+ enabled?: boolean
275
+ path?: string
276
+ specPath?: string
277
+ title?: string
278
+ version?: string
279
+ description?: string
280
+ scalar?: boolean
281
+ }
282
+ ```
110
283
 
111
- - **`cors`** _(boolean | object)_: Enable and configure Cross-Origin Resource Sharing globally.
112
- - **`helmet`** _(boolean | object)_: Enable strict security headers. Enabled by default.
113
- - **`logger`** _(boolean | object)_: Configure the efficient Pino request logger.
114
- - **`compression`** _(boolean | object)_: Enable gzip/brotli response compression.
115
- - **`etag`** _(boolean)_: Automatic ETag generation for HTTP conditional requests (default: `false` for dynamic API routes).
116
- - **`bodyLimit`** _(number)_: Maximum JSON/URL-encoded payload size in bytes (default: `10MB`).
284
+ ### `WatchConfig` & `DevConfig`
117
285
 
118
- ### Development Server & File Watcher (`dev`)
286
+ ```typescript
287
+ export interface WatchConfig {
288
+ paths?: string[]
289
+ ignore?: (string | RegExp)[]
290
+ extensions?: string[]
291
+ debounceMs?: number
292
+ }
293
+
294
+ export interface DevConfig {
295
+ watch?: string[]
296
+ ignored?: (string | RegExp)[]
297
+ usePolling?: boolean
298
+ interval?: number
299
+ binaryInterval?: number
300
+ extensions?: string[]
301
+ debounceMs?: number
302
+ }
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Environment Utility Functions
308
+
309
+ The `exisjs/config` module also exports low-level environment-loading helpers used internally by the CLI:
119
310
 
120
- - **`dev.watch`** _(string[])_: Custom directories or files to watch during development (default: `[cwd]`).
121
- - **`dev.ignored`** _((string | RegExp)[])_: Additional files, extensions, or regex patterns to ignore during hot reload.
122
- - **`dev.usePolling`** _(boolean)_: Enables chokidar polling fallback (default: `true` on Windows).
123
- - **`dev.interval`** _(number)_: Polling file system interval in milliseconds (default: `100`).
311
+ ### `loadEnv(cwd?, mode?, override?)`
124
312
 
125
- ### Extended Integrations
313
+ Loads cascading `.env` files from `cwd` based on the specified execution mode (`development`, `production`, `test`).
314
+
315
+ ```typescript
316
+ import { loadEnv } from 'exisjs/config'
317
+
318
+ const envMap = loadEnv(process.cwd(), 'production')
319
+ ```
320
+
321
+ ### `parseEnv(source)`
322
+
323
+ Parses raw `.env` string contents into a key-value record without mutating `process.env`.
324
+
325
+ ```typescript
326
+ import { parseEnv } from 'exisjs/config'
327
+
328
+ const parsed = parseEnv(`
329
+ PORT=5000
330
+ DATABASE_URL=postgres://user:pass@localhost:5432/db
331
+ `)
332
+ ```
126
333
 
127
- - **`queue`**: Define your background queue driver (`memory` or `redis`) and configure `maxConcurrent` processing limits.
128
- - **`plugins`**: An array of `ExisPlugin` instances to register natively into the framework.
129
- - **`test`**: Configure testing environments (`include`, `exclude`, `setupFiles`, `coverage`).