@lenne.tech/nest-server 11.21.3 → 11.22.1

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 (57) hide show
  1. package/.claude/rules/architecture.md +79 -0
  2. package/.claude/rules/better-auth.md +262 -0
  3. package/.claude/rules/configurable-features.md +308 -0
  4. package/.claude/rules/core-modules.md +205 -0
  5. package/.claude/rules/framework-compatibility.md +79 -0
  6. package/.claude/rules/migration-guides.md +149 -0
  7. package/.claude/rules/module-deprecation.md +214 -0
  8. package/.claude/rules/module-inheritance.md +97 -0
  9. package/.claude/rules/package-management.md +112 -0
  10. package/.claude/rules/role-system.md +146 -0
  11. package/.claude/rules/testing.md +120 -0
  12. package/.claude/rules/versioning.md +53 -0
  13. package/CLAUDE.md +174 -0
  14. package/FRAMEWORK-API.md +231 -0
  15. package/dist/core/common/interfaces/server-options.interface.d.ts +10 -0
  16. package/dist/core/modules/error-code/error-code.module.js.map +1 -1
  17. package/dist/core.module.d.ts +3 -3
  18. package/dist/core.module.js +17 -4
  19. package/dist/core.module.js.map +1 -1
  20. package/dist/server/modules/file/file-info.model.d.ts +1 -5
  21. package/dist/server/modules/user/user.model.d.ts +1 -5
  22. package/dist/server/server.module.js +6 -6
  23. package/dist/server/server.module.js.map +1 -1
  24. package/dist/tsconfig.build.tsbuildinfo +1 -1
  25. package/docs/REQUEST-LIFECYCLE.md +1256 -0
  26. package/docs/error-codes.md +446 -0
  27. package/migration-guides/11.10.x-to-11.11.x.md +266 -0
  28. package/migration-guides/11.11.x-to-11.12.x.md +323 -0
  29. package/migration-guides/11.12.x-to-11.13.0.md +612 -0
  30. package/migration-guides/11.13.x-to-11.14.0.md +348 -0
  31. package/migration-guides/11.14.x-to-11.15.0.md +262 -0
  32. package/migration-guides/11.15.0-to-11.15.3.md +118 -0
  33. package/migration-guides/11.15.x-to-11.16.0.md +497 -0
  34. package/migration-guides/11.16.x-to-11.17.0.md +130 -0
  35. package/migration-guides/11.17.x-to-11.18.0.md +393 -0
  36. package/migration-guides/11.18.x-to-11.19.0.md +151 -0
  37. package/migration-guides/11.19.x-to-11.20.0.md +170 -0
  38. package/migration-guides/11.20.x-to-11.21.0.md +216 -0
  39. package/migration-guides/11.21.0-to-11.21.1.md +194 -0
  40. package/migration-guides/11.21.1-to-11.21.2.md +114 -0
  41. package/migration-guides/11.21.2-to-11.21.3.md +175 -0
  42. package/migration-guides/11.21.x-to-11.22.0.md +224 -0
  43. package/migration-guides/11.22.0-to-11.22.1.md +105 -0
  44. package/migration-guides/11.3.x-to-11.4.x.md +233 -0
  45. package/migration-guides/11.6.x-to-11.7.x.md +394 -0
  46. package/migration-guides/11.7.x-to-11.8.x.md +318 -0
  47. package/migration-guides/11.8.x-to-11.9.x.md +322 -0
  48. package/migration-guides/11.9.x-to-11.10.x.md +571 -0
  49. package/migration-guides/TEMPLATE.md +113 -0
  50. package/package.json +25 -18
  51. package/src/core/common/interfaces/server-options.interface.ts +83 -16
  52. package/src/core/modules/better-auth/CUSTOMIZATION.md +24 -17
  53. package/src/core/modules/better-auth/INTEGRATION-CHECKLIST.md +5 -5
  54. package/src/core/modules/error-code/INTEGRATION-CHECKLIST.md +42 -12
  55. package/src/core/modules/error-code/error-code.module.ts +4 -9
  56. package/src/core.module.ts +52 -10
  57. package/src/server/server.module.ts +7 -9
@@ -0,0 +1,348 @@
1
+ # Migration Guide: 11.13.x → 11.14.0
2
+
3
+ ## Overview
4
+
5
+ | Category | Details |
6
+ |----------|---------|
7
+ | **Breaking Changes** | None |
8
+ | **New Features** | CoreSystemSetupModule (11.13.5), `disableSignUp` (11.13.4), BetterAuth performance optimizations (11.13.3), BetterAuthRolesGuard DI fix (11.13.2), API middleware 404 fallback (11.14.0) |
9
+ | **Internal Changes** | Switch from ESLint/Prettier to oxlint/oxfmt, remove legacy Jest references, tsconfig target es2020 → es2022 |
10
+ | **Dependency Updates** | `nodemailer` 7→8, `ejs` 3→4, `mongoose` 9.1.5→9.1.6, `better-auth` 1.4.17→1.4.18, NestJS 11.1.12→11.1.13 |
11
+ | **Migration Effort** | Minimal (~2 minutes) - update package and verify build |
12
+
13
+ ---
14
+
15
+ ## Quick Migration
16
+
17
+ ```bash
18
+ # Update package
19
+ npm install @lenne.tech/nest-server@11.14.0
20
+
21
+ # If package.json dependencies changed
22
+ npm run update
23
+
24
+ # Verify build
25
+ npm run build
26
+
27
+ # Run tests
28
+ npm test
29
+ ```
30
+
31
+ ---
32
+
33
+ ## What's New in 11.13.1 – 11.14.0
34
+
35
+ ### 1. CoreSystemSetupModule – Initial Admin Creation (11.13.5)
36
+
37
+ New module for creating the first admin user on fresh deployments, especially useful when `disableSignUp` is enabled.
38
+
39
+ **Enabled by default** when BetterAuth is active. No configuration needed.
40
+
41
+ **REST Endpoints:**
42
+
43
+ | Method | Endpoint | Description |
44
+ |--------|----------|-------------|
45
+ | GET | `/api/system-setup/status` | Check if system needs setup |
46
+ | POST | `/api/system-setup/init` | Create initial admin user |
47
+
48
+ **Auto-creation for Docker/CI deployments:**
49
+
50
+ ```bash
51
+ # .env or Docker environment
52
+ NSC__systemSetup__initialAdmin__email=admin@example.com
53
+ NSC__systemSetup__initialAdmin__password=YourSecurePassword123!
54
+ NSC__systemSetup__initialAdmin__name=Admin # optional
55
+ ```
56
+
57
+ Or in `config.env.ts`:
58
+
59
+ ```typescript
60
+ systemSetup: {
61
+ initialAdmin: {
62
+ email: process.env.INITIAL_ADMIN_EMAIL,
63
+ password: process.env.INITIAL_ADMIN_PASSWORD,
64
+ },
65
+ },
66
+ ```
67
+
68
+ **Security:** Init only works when zero users exist. Once any user is created, the endpoint is permanently locked (403).
69
+
70
+ **To disable:**
71
+ ```typescript
72
+ systemSetup: { enabled: false },
73
+ ```
74
+
75
+ **Documentation:** [SystemSetup README](../src/core/modules/system-setup/README.md) | [Integration Checklist](../src/core/modules/system-setup/INTEGRATION-CHECKLIST.md)
76
+
77
+ ### 2. Disable Sign-Up for Invite-Only Apps (11.13.4)
78
+
79
+ New configuration option to disable email/password sign-up while keeping sign-in for existing users:
80
+
81
+ ```typescript
82
+ // config.env.ts
83
+ betterAuth: {
84
+ emailAndPassword: {
85
+ disableSignUp: true,
86
+ },
87
+ },
88
+ ```
89
+
90
+ When enabled:
91
+ - REST `POST /iam/sign-up/email` returns error `LTNS_0026`
92
+ - GraphQL `betterAuthSignUp` mutation returns error `LTNS_0026`
93
+ - Sign-in for existing users continues to work normally
94
+ - System Setup endpoints bypass this restriction (for initial admin creation)
95
+
96
+ **Defense in Depth:** Custom `ensureSignUpEnabled()` check fires before BetterAuth API calls (structured error), native `disableSignUp` flag acts as safety net for direct API access.
97
+
98
+ ### 3. BetterAuth Sign-In Performance Optimization (11.13.3)
99
+
100
+ - **Native scrypt** implementation replaces JS-based hashing for faster password verification
101
+ - **Migration fast-path** skips unnecessary operations for already-migrated users
102
+ - **Bounded in-memory stores** prevent unbounded memory growth in rate limiters and caches
103
+
104
+ No configuration changes needed. Performance improvements are automatic.
105
+
106
+ ### 4. BetterAuthRolesGuard – DI Fix for autoRegister:false (11.13.2)
107
+
108
+ Fixes dependency injection issues when using `betterAuth: { autoRegister: false }` (Pattern 3). The new `BetterAuthRolesGuard` has no constructor dependencies, avoiding the mixin DI conflict with `AuthGuard(JWT)`.
109
+
110
+ **Impact:** If you use Pattern 3 (`autoRegister: false`) and experienced `Reflector not available` errors, this is now fixed automatically.
111
+
112
+ ### 5. Middleware Token Priority Fix (11.13.1)
113
+
114
+ Fixes a bug where an invalid Authorization header could prevent cookie-based authentication fallback. The middleware now correctly falls back to session cookies when the Authorization header token is invalid.
115
+
116
+ ### 6. API Middleware 404 Fallback (11.14.0)
117
+
118
+ The BetterAuth API middleware now calls `next()` when BetterAuth returns a 404 response, allowing NestJS controllers to handle custom `/iam/*` endpoints. Previously, custom controller endpoints under the `/iam/` path would get intercepted and return 404.
119
+
120
+ **Impact:** Projects with custom BetterAuth controller endpoints that previously returned 404 should now work correctly.
121
+
122
+ ### 7. Internal Tooling: Switch to oxlint and oxfmt (11.14.0)
123
+
124
+ nest-server internally switched from ESLint/Prettier to [oxlint](https://oxc.rs/docs/guide/usage/linter) and [oxfmt](https://oxc.rs/docs/guide/usage/formatter) for linting and formatting.
125
+
126
+ **Impact on consuming projects:** None. This is an internal tooling change. Consuming projects can continue using ESLint/Prettier or any other linting setup.
127
+
128
+ **What was removed from nest-server:**
129
+ - `eslint`, `eslint-config-prettier`, `eslint-plugin-unused-imports`, `@typescript-eslint/*`
130
+ - `prettier`, `pretty-quick`
131
+ - `ts-jest`, `@lenne.tech/eslint-config-ts`
132
+ - `jest-e2e.json`, Jest config in `package.json`
133
+ - `eslint.config.mjs`, `.prettierrc`, `.prettierignore`
134
+
135
+ **What was added:**
136
+ - `oxlint` (linter)
137
+ - `oxfmt` (formatter)
138
+ - `.oxlintrc.json`, `.oxfmtrc.jsonc`, `.oxlintignore`
139
+
140
+ ### 8. Dependency Updates (11.14.0)
141
+
142
+ | Package | From | To | Notes |
143
+ |---------|------|----|-------|
144
+ | `nodemailer` | 7.0.13 | 8.0.1 | Major version bump (internal dependency) |
145
+ | `ejs` | 3.1.10 | 4.0.1 | Major version bump (internal dependency) |
146
+ | `mongoose` | 9.1.5 | 9.1.6 | Patch update |
147
+ | `better-auth` | 1.4.17 | 1.4.18 | Patch update |
148
+ | `@better-auth/passkey` | 1.4.17 | 1.4.18 | Patch update |
149
+ | `@nestjs/common` | 11.1.12 | 11.1.13 | Patch update |
150
+ | `@nestjs/core` | 11.1.12 | 11.1.13 | Patch update |
151
+ | `@nestjs/apollo` | 13.2.3 | 13.2.4 | Patch update |
152
+ | `@nestjs/graphql` | 13.2.3 | 13.2.4 | Patch update |
153
+ | `@nestjs/swagger` | 11.2.5 | 11.2.6 | Patch update |
154
+ | `dotenv` | 17.2.3 | 17.2.4 | Patch update |
155
+
156
+ These are **nest-server's own dependencies**, not peer dependencies. Consuming projects are not directly affected unless they also depend on these packages at conflicting versions.
157
+
158
+ ---
159
+
160
+ ## Breaking Changes
161
+
162
+ None. This release is fully backward compatible.
163
+
164
+ **Note:** The email verification URL `console.log` is now restricted to `local`, `development`, and `test` environments (`NODE_ENV`). In production, the URL is no longer logged to the console. This is a security improvement — verification URLs should never appear in production logs.
165
+
166
+ ---
167
+
168
+ ## Detailed Migration Steps
169
+
170
+ ### Step 1: Update Package
171
+
172
+ ```bash
173
+ npm install @lenne.tech/nest-server@11.14.0
174
+ ```
175
+
176
+ ### Step 2: Adopt New Features (Optional)
177
+
178
+ #### Enable disableSignUp (Invite-Only)
179
+
180
+ ```typescript
181
+ // config.env.ts
182
+ betterAuth: {
183
+ emailAndPassword: {
184
+ disableSignUp: true,
185
+ },
186
+ },
187
+ ```
188
+
189
+ #### Configure System Setup Auto-Creation
190
+
191
+ ```bash
192
+ # .env
193
+ NSC__systemSetup__initialAdmin__email=admin@example.com
194
+ NSC__systemSetup__initialAdmin__password=YourSecurePassword123!
195
+ ```
196
+
197
+ ### Step 4: Build and Test
198
+
199
+ ```bash
200
+ npm run build
201
+ npm test
202
+ ```
203
+
204
+ ---
205
+
206
+ ## Compatibility Notes
207
+
208
+ ### Consuming Project Tooling
209
+
210
+ nest-server's switch to oxlint/oxfmt does **not** affect consuming projects. Your project can continue using ESLint, Prettier, or any other tooling independently.
211
+
212
+ ### TypeScript Target
213
+
214
+ nest-server's internal `tsconfig.json` target changed from `es2020` to `es2022`. This only affects nest-server's own compilation output. Consuming projects are not affected since they use the compiled `dist/` output.
215
+
216
+ ### nodemailer and ejs Major Bumps
217
+
218
+ `nodemailer` (7→8) and `ejs` (3→4) are nest-server's internal dependencies. They are not exposed as peer dependencies. If your project independently depends on these packages at different major versions, npm should resolve them separately.
219
+
220
+ ### Existing Custom BetterAuth Endpoints
221
+
222
+ If you have custom controller endpoints under the `/iam/` path that previously returned 404, they should now work correctly thanks to the API middleware 404 fallback fix.
223
+
224
+ ### Projects Without BetterAuth
225
+
226
+ If your project does not use BetterAuth, the SystemSetup module and disableSignUp feature have no impact. The tooling switch and dependency updates apply universally but require no action.
227
+
228
+ ---
229
+
230
+ ## Bugfixes Included (11.13.1 – 11.14.0)
231
+
232
+ ### Promise Constructor Antipattern Fix (11.14.0)
233
+
234
+ `CrudService.updateMany()` previously wrapped async operations in unnecessary `new Promise()` constructors. This has been cleaned up to use direct promise returns, which is both simpler and avoids the async executor antipattern.
235
+
236
+ No action needed — this is a purely internal cleanup.
237
+
238
+ ### Code Formatting Normalization (11.14.0)
239
+
240
+ oxfmt applies slightly different formatting than Prettier:
241
+ - Arrow function parameters always have parentheses: `key =>` → `(key) =>`
242
+ - Operators at end of line instead of start: `&&\n` instead of `\n&&`
243
+ - Redundant spread removal: `...(obj ?? {})` → `...obj`
244
+ - Double negation removal: `!!parameter` → `parameter`
245
+
246
+ These are code style changes only and do not affect behavior.
247
+
248
+ ### Regex Escape Fix in isEmail() (11.14.0)
249
+
250
+ The `isEmail()` helper function had unnecessary escape characters in a character class (`[\.-]` → `[.-]`). This was a linting warning fix with no behavioral change.
251
+
252
+ ---
253
+
254
+ ## Troubleshooting
255
+
256
+ ### Tests Fail Capturing Email Verification URL
257
+
258
+ **Cause:** The `console.log` for verification URLs now only runs when `NODE_ENV` is `local`, `development`, or `test`. If your test environment uses a different `NODE_ENV`, the log won't appear.
259
+
260
+ **Solution:** Ensure your test environment sets `NODE_ENV=local` or `NODE_ENV=test`.
261
+
262
+ ### Custom `/iam/*` Controller Endpoints Now Return Different Responses
263
+
264
+ **Cause:** The API middleware 404 fallback now passes unhandled paths to NestJS controllers.
265
+
266
+ **Solution:** This is the intended fix. If you had workarounds for the previous 404 behavior, you may need to remove them.
267
+
268
+ ### `Reflector not available` Error with autoRegister:false
269
+
270
+ **Cause:** Fixed in 11.13.2 with BetterAuthRolesGuard.
271
+
272
+ **Solution:** Update to 11.14.0. No code changes needed.
273
+
274
+ ### Sign-Up Suddenly Fails with LTNS_0026
275
+
276
+ **Cause:** `disableSignUp` may be set to `true` in config.
277
+
278
+ **Solution:** Check `betterAuth.emailAndPassword.disableSignUp` in `config.env.ts`. Set to `false` or remove to re-enable sign-up.
279
+
280
+ ### System Setup Endpoint Returns 403
281
+
282
+ **Cause:** Users already exist in the database, OR BetterAuth is not enabled.
283
+
284
+ **Solution:** System setup init only works on an empty database. Check `GET /api/system-setup/status` for diagnostics.
285
+
286
+ ---
287
+
288
+ ## New Exports
289
+
290
+ The following are newly exported from `@lenne.tech/nest-server` (since 11.13.0):
291
+
292
+ ```typescript
293
+ // System Setup Module (11.13.5)
294
+ export { CoreSystemSetupController, SystemSetupInitDto } from './core/modules/system-setup/core-system-setup.controller';
295
+ export { CoreSystemSetupModule } from './core/modules/system-setup/core-system-setup.module';
296
+ export { CoreSystemSetupService, SystemSetupInitInput, SystemSetupInitResult, SystemSetupStatus } from './core/modules/system-setup/core-system-setup.service';
297
+
298
+ // Configuration Interfaces (11.13.5)
299
+ export { ISystemSetup, ISystemSetupInitialAdmin } from './core/common/interfaces/server-options.interface';
300
+ ```
301
+
302
+ ---
303
+
304
+ ## Module Documentation
305
+
306
+ ### System Setup Module (New)
307
+
308
+ - **README:** [src/core/modules/system-setup/README.md](../src/core/modules/system-setup/README.md)
309
+ - **Integration Checklist:** [src/core/modules/system-setup/INTEGRATION-CHECKLIST.md](../src/core/modules/system-setup/INTEGRATION-CHECKLIST.md)
310
+ - **Key Files:**
311
+ - `core-system-setup.controller.ts` – REST endpoints (status + init)
312
+ - `core-system-setup.service.ts` – Admin creation logic with zero-user guard
313
+ - `core-system-setup.module.ts` – Conditionally imported in CoreModule
314
+
315
+ ### Better-Auth Module (Updated)
316
+
317
+ - **README:** [src/core/modules/better-auth/README.md](../src/core/modules/better-auth/README.md)
318
+ - **Integration Checklist:** [src/core/modules/better-auth/INTEGRATION-CHECKLIST.md](../src/core/modules/better-auth/INTEGRATION-CHECKLIST.md)
319
+ - **Customization Guide:** [src/core/modules/better-auth/CUSTOMIZATION.md](../src/core/modules/better-auth/CUSTOMIZATION.md)
320
+ - **Key Changes:**
321
+ - `emailAndPassword.disableSignUp` configuration option (11.13.4)
322
+ - BetterAuthRolesGuard for DI fix in Pattern 3 (11.13.2)
323
+ - API middleware 404 fallback for custom endpoints (11.14.0)
324
+ - Native scrypt performance optimization (11.13.3)
325
+
326
+ ---
327
+
328
+ ## Version History (11.13.0 → 11.14.0)
329
+
330
+ | Version | Type | Summary |
331
+ |---------|------|---------|
332
+ | 11.13.1 | Bugfix | BetterAuth middleware token priority fix, RolesGuard REST support |
333
+ | 11.13.2 | Bugfix | BetterAuthRolesGuard for DI issues with autoRegister:false |
334
+ | 11.13.3 | Performance | Native scrypt, migration fast-path, bounded in-memory stores |
335
+ | 11.13.4 | Feature | `emailAndPassword.disableSignUp` for invite-only apps |
336
+ | 11.13.5 | Feature | CoreSystemSetupModule for initial admin creation |
337
+ | 11.14.0 | Breaking | Switch to oxlint/oxfmt, remove ESLint/Prettier/Jest legacy, dependency updates |
338
+
339
+ ---
340
+
341
+ ## References
342
+
343
+ - [SystemSetup Module](../src/core/modules/system-setup/) – New module for initial admin creation
344
+ - [Better-Auth Module](../src/core/modules/better-auth/) – Core auth module
345
+ - [nest-server-starter](https://github.com/lenneTech/nest-server-starter) – Reference implementation
346
+ - [oxlint Documentation](https://oxc.rs/docs/guide/usage/linter) – New linter
347
+ - [oxfmt Documentation](https://oxc.rs/docs/guide/usage/formatter) – New formatter
348
+ - [Configurable Features Pattern](../.claude/rules/configurable-features.md) – Configuration patterns used
@@ -0,0 +1,262 @@
1
+ # Migration Guide: 11.14.x → 11.15.0
2
+
3
+ ## Overview
4
+
5
+ | Category | Details |
6
+ |----------|---------|
7
+ | **Breaking Changes** | `IServerOptions.graphQl` type changed from `object \| undefined` to `false \| object \| undefined` (TypeScript only — runtime is backward compatible) |
8
+ | **New Features** | Disable GraphQL entirely via `graphQl: false`, test artifact cleanup script |
9
+ | **Bugfixes** | None |
10
+ | **Migration Effort** | Minimal (~1 minute) — update package and verify build |
11
+
12
+ ---
13
+
14
+ ## Quick Migration
15
+
16
+ ```bash
17
+ # Update package
18
+ npm install @lenne.tech/nest-server@11.15.0
19
+
20
+ # Verify build
21
+ npm run build
22
+
23
+ # Run tests
24
+ npm test
25
+ ```
26
+
27
+ ---
28
+
29
+ ## What's New in 11.15.0
30
+
31
+ ### 1. Disable GraphQL (`graphQl: false`)
32
+
33
+ Projects that only need REST endpoints (e.g. pure API backends, microservices) can now completely disable GraphQL by setting `graphQl: false` in the configuration.
34
+
35
+ **What gets disabled:**
36
+ - `GraphQLModule` is not imported (no `/graphql` endpoint)
37
+ - `ComplexityPlugin` is not registered
38
+ - `graphqlUploadExpress()` middleware is not applied
39
+ - No Apollo Server startup overhead
40
+
41
+ **What stays active:**
42
+ - MongoDB / Mongoose
43
+ - All REST controllers and middleware
44
+ - BetterAuth (if configured)
45
+ - Email, Template, Config services
46
+ - All other core modules (File, HealthCheck, SystemSetup, etc.)
47
+
48
+ **Usage:**
49
+
50
+ ```typescript
51
+ // config.env.ts
52
+ const config: Partial<IServerOptions> = {
53
+ // ... other config
54
+
55
+ // Disable GraphQL entirely
56
+ graphQl: false,
57
+ };
58
+ ```
59
+
60
+ **Works with all CoreModule.forRoot signatures:**
61
+
62
+ ```typescript
63
+ // 1-param (IAM-only)
64
+ CoreModule.forRoot({ ...config, graphQl: false })
65
+
66
+ // 3-param (Legacy + IAM)
67
+ CoreModule.forRoot(CoreAuthService, AuthModule.forRoot(jwt), { ...config, graphQl: false })
68
+ ```
69
+
70
+ **Default behavior (no change needed):**
71
+
72
+ ```typescript
73
+ // GraphQL is enabled by default — these are equivalent:
74
+ CoreModule.forRoot(config) // graphQl: undefined → enabled
75
+ CoreModule.forRoot({ ...config, graphQl: {} }) // explicit empty config → enabled
76
+ CoreModule.forRoot({ ...config, graphQl: { ... } }) // with options → enabled
77
+ ```
78
+
79
+ ### 2. Test Artifact Cleanup Script
80
+
81
+ New npm script to remove leftover `.txt` and `.bin` files from the `tests/` directory that can remain after failed file upload or TUS upload tests:
82
+
83
+ ```bash
84
+ npm run test:cleanup
85
+ ```
86
+
87
+ **Affected files:**
88
+ - `tests/*.txt` — file upload test artifacts
89
+ - `tests/stories/*.txt` — TUS upload test text files
90
+ - `tests/stories/*.bin` — TUS upload test binary files
91
+
92
+ This script is safe — it only deletes `.txt` and `.bin` files within the `tests/` directory tree and preserves `.gitkeep` files.
93
+
94
+ ### 3. `.gitignore` Updated
95
+
96
+ Added `tests/**/*.bin` to `.gitignore` to prevent accidental commits of binary test artifacts (e.g. the 100KB `test-tus-upload-large.bin` from TUS tests).
97
+
98
+ ---
99
+
100
+ ## Breaking Changes
101
+
102
+ ### TypeScript Interface Change: `IServerOptions.graphQl`
103
+
104
+ The `graphQl` property type in `IServerOptions` changed from:
105
+
106
+ ```typescript
107
+ // Before (11.14.x)
108
+ graphQl?: {
109
+ driver?: ApolloDriverConfig;
110
+ enableSubscriptionAuth?: boolean;
111
+ maxComplexity?: number;
112
+ options?: GqlModuleAsyncOptions;
113
+ };
114
+ ```
115
+
116
+ To:
117
+
118
+ ```typescript
119
+ // After (11.15.0)
120
+ graphQl?:
121
+ | false
122
+ | {
123
+ driver?: ApolloDriverConfig;
124
+ enableSubscriptionAuth?: boolean;
125
+ maxComplexity?: number;
126
+ options?: GqlModuleAsyncOptions;
127
+ };
128
+ ```
129
+
130
+ **Impact:** This is a **TypeScript-only** breaking change. The union type `false | { ... }` is a widening change — all existing configurations remain valid without modification. However, code that directly accesses `config.graphQl.driver` without checking for `false` first may now show TypeScript errors.
131
+
132
+ **If you access `graphQl` properties directly:**
133
+
134
+ ```typescript
135
+ // Before — may now show TS error: "Property 'driver' does not exist on type 'false'"
136
+ const driver = config.graphQl?.driver;
137
+
138
+ // After — add type narrowing
139
+ const driver = typeof config.graphQl === 'object' ? config.graphQl?.driver : undefined;
140
+
141
+ // Or simpler:
142
+ const driver = config.graphQl && config.graphQl !== false ? config.graphQl.driver : undefined;
143
+ ```
144
+
145
+ **If you only pass config to CoreModule.forRoot():** No changes needed.
146
+
147
+ ---
148
+
149
+ ## Detailed Migration Steps
150
+
151
+ ### Step 1: Update Package
152
+
153
+ ```bash
154
+ npm install @lenne.tech/nest-server@11.15.0
155
+ ```
156
+
157
+ ### Step 2: Check TypeScript Compilation
158
+
159
+ ```bash
160
+ npm run build
161
+ ```
162
+
163
+ If you get TypeScript errors related to `graphQl` property access, add type narrowing as shown above.
164
+
165
+ ### Step 3: Adopt New Features (Optional)
166
+
167
+ #### Disable GraphQL for REST-only projects
168
+
169
+ ```typescript
170
+ // config.env.ts
171
+ graphQl: false,
172
+ ```
173
+
174
+ #### Use test cleanup script
175
+
176
+ ```bash
177
+ npm run test:cleanup
178
+ ```
179
+
180
+ ### Step 4: Run Tests
181
+
182
+ ```bash
183
+ npm test
184
+ ```
185
+
186
+ ---
187
+
188
+ ## Compatibility Notes
189
+
190
+ ### Existing Projects (No Action Required)
191
+
192
+ Projects that don't set `graphQl: false` are completely unaffected. GraphQL remains enabled by default when `graphQl` is `undefined` or an object.
193
+
194
+ ### Projects Using `graphQl` Config
195
+
196
+ If your project configures GraphQL options:
197
+
198
+ ```typescript
199
+ // This still works exactly as before
200
+ graphQl: {
201
+ maxComplexity: 100,
202
+ enableSubscriptionAuth: true,
203
+ }
204
+ ```
205
+
206
+ ### BetterAuth Without GraphQL
207
+
208
+ When using `graphQl: false` with BetterAuth, the BetterAuth REST endpoints (`/iam/*`) continue to work. Only GraphQL resolvers and subscriptions are disabled.
209
+
210
+ ### Test Cleanup Script
211
+
212
+ The `test:cleanup` script is available in nest-server itself. Consuming projects with similar file upload tests may want to add a similar script to their own `package.json`.
213
+
214
+ ---
215
+
216
+ ## Troubleshooting
217
+
218
+ ### TypeScript Error: "Property does not exist on type 'false'"
219
+
220
+ **Cause:** Code accesses `config.graphQl?.someProperty` without narrowing the union type.
221
+
222
+ **Solution:** Add a type check:
223
+ ```typescript
224
+ if (config.graphQl && config.graphQl !== false) {
225
+ // Safe to access config.graphQl.driver etc.
226
+ }
227
+ ```
228
+
229
+ ### GraphQL Endpoint Returns 404 After Setting `graphQl: false`
230
+
231
+ **Cause:** This is the intended behavior. Setting `graphQl: false` removes the `/graphql` endpoint entirely.
232
+
233
+ **Solution:** Remove `graphQl: false` from config to re-enable GraphQL.
234
+
235
+ ### Resolvers/Mutations Not Found After Setting `graphQl: false`
236
+
237
+ **Cause:** GraphQL resolvers require the GraphQLModule. With `graphQl: false`, no resolvers are registered.
238
+
239
+ **Solution:** Use REST controllers for API endpoints when GraphQL is disabled.
240
+
241
+ ---
242
+
243
+ ## Module Documentation
244
+
245
+ ### CoreModule (Updated)
246
+
247
+ - **Key File:** [src/core.module.ts](../src/core.module.ts)
248
+ - **Interface:** [src/core/common/interfaces/server-options.interface.ts](../src/core/common/interfaces/server-options.interface.ts)
249
+ - **Changes:**
250
+ - `graphQl: false` support in `forRoot()` — skips GraphQLModule import, ComplexityPlugin, and upload middleware
251
+ - Static `graphQlEnabled` flag controls middleware registration in `configure()`
252
+ - Type-safe `graphQlOpts` extraction in all three GraphQL driver builders
253
+
254
+ ---
255
+
256
+ ## References
257
+
258
+ - [IServerOptions Interface](../src/core/common/interfaces/server-options.interface.ts) — Updated `graphQl` type definition
259
+ - [CoreModule](../src/core.module.ts) — Implementation of `graphQl: false` support
260
+ - [Unit Tests](../tests/unit/core-module-signatures.spec.ts) — Tests for all `graphQl: false` scenarios
261
+ - [Configurable Features Pattern](../.claude/rules/configurable-features.md) — Configuration patterns used
262
+ - [nest-server-starter](https://github.com/lenneTech/nest-server-starter) — Reference implementation