@lenne.tech/nest-server 11.42.10 → 11.42.11

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.
@@ -155,8 +155,10 @@ some projects copied `scripts/check.mjs` from 11.27.1+:
155
155
  no longer wipe each other's users/sessions mid-flight. A new reporter
156
156
  (`tests/db-lifecycle.reporter.ts`) drops the DB after a successful run and
157
157
  collects stale leftovers; after a failed run the DB is kept for debugging
158
- until the next successful run. An externally set `MONGODB_URI` (CI) keeps
159
- the previous behavior.
158
+ until the next successful run. An externally set `NSC__MONGOOSE__URI` (CI)
159
+ keeps the previous behavior. (This line originally said `MONGODB_URI`, the
160
+ variable the framework's own test setup reads; a starter-derived project's
161
+ `tests/global-setup.ts` reads `NSC__MONGOOSE__URI`.)
160
162
 
161
163
  ---
162
164
 
@@ -35,10 +35,15 @@ fix reaches an existing project.
35
35
  1. Your project's slug contains `ci`, `test`, `e2e` or `acctest` **as a substring** — including
36
36
  inside an ordinary word: `ci` hides in so**ci**al, spe**ci**al, finan**ci**al, invoi**ci**ng,
37
37
  pri**ci**ng, muni**ci**pal; `test` hides in la**test**, con**test**, **test**imonials.
38
- 2. You use `lt dev up`, which exports `MONGODB_URI` pointing at `<slug>-local` — your **development**
39
- database.
38
+ 2. You use `lt dev up`, which exports `NSC__MONGOOSE__URI` pointing at `<slug>-local` — your
39
+ **development** database, and the variable your `tests/global-setup.ts` drops when it is set.
40
40
  3. You started the e2e suite from that same shell.
41
41
 
42
+ > **Correction (11.42.x):** earlier versions of this guide named `MONGODB_URI` throughout. That is
43
+ > the variable the framework's OWN test setup reads; `lt dev` never sets it. A starter-derived
44
+ > project's `tests/global-setup.ts` reads `NSC__MONGOOSE__URI`, which `lt dev` does export — so
45
+ > the steps below are right for your project, only the variable name was wrong.
46
+
42
47
  Then `tests/global-setup.ts` dropped that database. The guard meant to prevent exactly this accepted
43
48
  it, because it matched the marker anywhere in the name rather than as a delimited segment.
44
49
 
@@ -82,7 +87,7 @@ cannot:
82
87
 
83
88
  **A second guard for the one drop site that has no other condition.** The startup sweep and the
84
89
  post-run collection both additionally require `isStaleTestDb()` — the name must belong to your own
85
- base. The externally-supplied-`MONGODB_URI` branch has no such backstop, and a project slug may
90
+ base. The externally-supplied-`NSC__MONGOOSE__URI` branch has no such backstop, and a project slug may
86
91
  legitimately carry a marker as a *whole word*: `ci` is the ordinary German abbreviation for
87
92
  *Corporate Identity*, `test` a product noun for an exam. `ci-portal-local` passes the segment rule.
88
93
 
@@ -100,7 +105,7 @@ Then use `isDroppableTestDb(db.databaseName)` in place of `SAFE_TEST_DB_PATTERN.
100
105
  database into a leaked one.
101
106
 
102
107
  **Refuse a URI that names no database.** `mongodb://127.0.0.1` makes the driver fall back to its
103
- default database, `test` — a name the guard accepts, so a truncated `MONGODB_URI` dropped the
108
+ default database, `test` — a name the guard accepts, so a truncated `NSC__MONGOOSE__URI` dropped the
104
109
  server's `test` database instead of failing. Note that this needs the `splitMongoUri()` fix too: the
105
110
  previous greedy form reported the **host** as the database name for such a URI, so the check could
106
111
  never fire.
@@ -125,7 +130,7 @@ refusal list *is* the specification, and reverting the anchoring turns 13 cases
125
130
  |---------|--------|
126
131
  | npm-mode projects | Unaffected by the package update; apply §1 to your own `tests/` |
127
132
  | Vendor-mode projects | Same — `tests/` is outside the vendor file set |
128
- | CI pipelines that pin `MONGODB_URI` | Unaffected, unless the pinned URI names no database or carries an environment suffix. A CI database called `myproject-ci` is fine; one called `myproject-ci-staging` is now refused |
133
+ | CI pipelines that pin `NSC__MONGOOSE__URI` | Unaffected, unless the pinned URI names no database or carries an environment suffix. A CI database called `myproject-ci` is fine; one called `myproject-ci-staging` is now refused |
129
134
  | Projects not generated from `nest-server-starter` | Nothing to do |
130
135
 
131
136
  ---
@@ -133,11 +138,11 @@ refusal list *is* the specification, and reverting the anchoring turns 13 cases
133
138
  ## Troubleshooting
134
139
 
135
140
  **`Refusing to dropDatabase("…"): not a recognized disposable test database`**
136
- Your `MONGODB_URI` points at something the guard will not delete. That is the guard working. Check
141
+ Your `NSC__MONGOOSE__URI` points at something the guard will not delete. That is the guard working. Check
137
142
  whether the URI is aimed at your development database — an `lt dev` shell exports it that way — and
138
143
  point it at a disposable test database instead. Do not loosen the pattern to get past this.
139
144
 
140
- **`Refusing to use MONGODB_URI="…": it names no database`**
145
+ **`Refusing to use NSC__MONGOOSE__URI="…": it names no database`**
141
146
  The URI has no path (`mongodb://host` rather than `mongodb://host/mydb`). Add the database name.
142
147
 
143
148
  **`N stale database(s) skipped by the safety guard`**
@@ -0,0 +1,160 @@
1
+ # Migration Guide: 11.42.10 → 11.42.11
2
+
3
+ ## Overview
4
+
5
+ | Category | Details |
6
+ | -------------------- | -------------------------------------------------------------------------------------------------------- |
7
+ | **Framework API** | No change |
8
+ | **Test tooling** | e2e low-resource cap fixed for Vitest 4, e2e run governor hardened, two `check.mjs` false greens closed (§1–§3) — reaches your project only through this guide |
9
+ | **Tests** | A race in tests that upload to a route a role guard refuses (§4) |
10
+ | **Documentation** | `lt dev` exports `NSC__MONGOOSE__URI`, never `MONGODB_URI`; two older guides corrected (§5) |
11
+ | **Dependencies** | `nodemailer` 10.1.0 (minor, no API change); dev tooling (§6) |
12
+ | **Breaking Changes** | None |
13
+ | **Migration Effort** | None for the package. Starter-derived projects older than starter 11.42.10 should port §1 and §2 |
14
+
15
+ ## Quick Migration
16
+
17
+ ```bash
18
+ pnpm update @lenne.tech/nest-server
19
+ ```
20
+
21
+ Vendor-mode projects pick it up with the core update. No code or configuration change is required for the
22
+ framework itself.
23
+
24
+ **Why the rest of this guide exists:** `tests/`, `scripts/` and `vitest-e2e.config.ts` do not ship in the npm
25
+ tarball and are not part of the vendor file set. They are template files: `nest-server-starter` ships them,
26
+ and every project generated from it holds a private copy that no update channel touches. The sections below
27
+ say which starter version already carries each fix, so you can tell whether your copy needs it.
28
+
29
+ ## 1. e2e low-resource mode: `maxWorkers` instead of `poolOptions` (Vitest 4)
30
+
31
+ Already in projects generated from **starter 11.42.10 or later**.
32
+
33
+ Vitest 4 removed `test.poolOptions`. The low-resource mode in `vitest-e2e.config.ts` still set
34
+ `poolOptions.forks.maxForks`, so the worker cap was announced on stderr and then discarded — measured: a run
35
+ logging `maxForks=2` used 8 workers on a 12-core machine, the same run with `maxWorkers` used 2. Low-resource
36
+ mode only raised the timeouts, and overlapping e2e runs (several sessions, `lt dev test` next to `check`) kept
37
+ starving each other into spurious 401s and timeouts.
38
+
39
+ ```typescript
40
+ // Before
41
+ ...(LOW_RESOURCE ? { poolOptions: { forks: { maxForks: LOW_RESOURCE_FORKS, minForks: 1 } } } : {}),
42
+
43
+ // After
44
+ maxWorkers: LOW_RESOURCE ? LOW_RESOURCE_FORKS : undefined,
45
+ ```
46
+
47
+ `undefined` leaves Vitest's default in place for a normal run. `minWorkers` does not exist in Vitest 4 — drop
48
+ `minForks` rather than translating it. Also rename the option in the stderr announcement, so the one line that
49
+ reports the cap names an option that exists.
50
+
51
+ A type check does not catch this: under `module: commonjs`, Vitest's config type collapses to `any`, so a
52
+ removed option compiles cleanly. The starter pins it with `tests/unit/vitest-e2e-config.spec.ts`.
53
+
54
+ **Not for your project: the framework's GitHub-runner exception.** nest-server additionally skips the cap when
55
+ the load signal is the only trigger and `RUNNER_ENVIRONMENT === 'github-hosted'`: a GitHub-hosted runner runs
56
+ one job per VM, so the load it sees is the job's own unit step, and the cap measurably slowed every build
57
+ (133 s → 198 s mean e2e time). A shared GitLab runner sets `CI` but not `RUNNER_ENVIRONMENT`, and there the
58
+ load is real contention — keep the cap.
59
+
60
+ ## 2. e2e run governor (`tests/e2e-run-slots.ts`) hardened
61
+
62
+ Already in projects generated from **starter 11.42.10 or later**.
63
+
64
+ The slot directory under `os.tmpdir()` is shared by every lt project on the machine. Three fixes, each pinned
65
+ by a test in `tests/unit/e2e-run-slots.spec.ts`:
66
+
67
+ | Defect | Fix |
68
+ | ------ | --- |
69
+ | A slot whose PID was recycled by an unrelated long-lived process counted as an active run forever | Reclaim a slot older than six hours even when its PID answers |
70
+ | On a multi-user Linux host (`/tmp` world-writable) a planted `<pid>.slot` symlink made the write follow it | Create the directory `0o700`, unlink the own path first, write with `flag: 'wx', mode: 0o600` |
71
+ | An unwritable slot directory threw out of `acquireRunSlot()` and aborted the suite, despite the documented fail-open | Catch the claim; the run proceeds ungoverned |
72
+
73
+ The easiest port is to copy `tests/e2e-run-slots.ts` and its spec from the current starter; the file has no
74
+ project-specific content.
75
+
76
+ ## 3. `scripts/check.mjs`: two false greens
77
+
78
+ Already in projects generated from **starter 11.40.0 or later**. nest-server's own copy caught up in this
79
+ release.
80
+
81
+ - **The "Vulnerabilities" summary line tested `audit.counts` before `audit.degraded`.** A silent audit outage
82
+ (exit 0, all-zero JSON, advisory service unreachable) keeps `counts` set, so the summary printed
83
+ `critical 0 · high 0 · …` for a run that never reached the service. Test `degraded` first.
84
+ - **The CLI guard compared `resolve(process.argv[1])` with the module's own path.** Node resolves the main
85
+ module's symlinks for `import.meta.url` but keeps `argv[1]` as typed, so a start through a symlink — on macOS
86
+ any absolute path under `/tmp` — skipped the pipeline and exited 0. Compare both sides through
87
+ `realpathSync`, and exit 1 when the entry cannot be resolved.
88
+
89
+ ## 4. Tests that upload to a refused route: send no file
90
+
91
+ Already in projects generated from **starter 11.41.9 or later** (for the avatar upload test).
92
+
93
+ When a role guard refuses a multipart upload route, it answers before the file interceptor reads the body. A
94
+ test that still attaches a file races that answer: the 401/403 arrives while the client is writing the
95
+ multipart body, and the write fails with `EPIPE` (observed 1 run in 14 in this repository with retries off).
96
+ The file cannot change the guard's answer, so send none — an open route then answers 400 for the missing file,
97
+ so the test still fails if the guard is gone:
98
+
99
+ ```typescript
100
+ // Before
101
+ await testHelper.rest('/files/upload', { attachments: { file: local }, statusCode: 401 });
102
+
103
+ // After
104
+ await testHelper.rest('/files/upload', { method: 'POST', statusCode: 401 });
105
+ ```
106
+
107
+ Search your `tests/` for `attachments:` next to `statusCode: 401` or `403`.
108
+
109
+ ## 5. Documentation corrections: `NSC__MONGOOSE__URI`, not `MONGODB_URI`
110
+
111
+ `lt dev` exports `NSC__MONGOOSE__URI` (and `DATABASE_URL`); it has never set `MONGODB_URI`. The guides
112
+ [11.36.3 → 11.36.4](./11.36.3-to-11.36.4.md) and [11.27.2 → 11.27.3](./11.27.2-to-11.27.3.md) named
113
+ `MONGODB_URI` where a starter-derived project's `tests/global-setup.ts` reads `NSC__MONGOOSE__URI`. Both are
114
+ corrected. The steps in them were right for your project — only the variable name was wrong, so nothing needs
115
+ redoing unless you adapted a script to the wrong name.
116
+
117
+ ## 6. Dependency updates
118
+
119
+ - **`nodemailer` 10.0.16 → 10.1.0** — minor release: hardened message streams, SMTP connection and pool
120
+ handling, SMTP and encoding fixes. No API change; the framework's real-SMTP round-trip test passes. A project
121
+ that carries a lock-step `nodemailer` override (nest-server-starter does) should raise it:
122
+
123
+ ```yaml
124
+ # Before
125
+ overrides:
126
+ 'nodemailer@<10.0.16': '10.0.16'
127
+
128
+ # After
129
+ overrides:
130
+ 'nodemailer@<10.1.0': '10.1.0'
131
+ ```
132
+
133
+ - **Development tooling only:** `@aws-sdk/*` 3.1149.0, `bullmq` 6.3.12, `smtp-server` 3.19.19, `vite` 8.3.4,
134
+ `@types/node` 26.6.5, `@types/lodash` 4.17.26. If your project pins `@types/node` exactly, raise it to 26.6.5
135
+ so a fresh install does not keep two copies.
136
+
137
+ Unchanged on purpose: `express` stays 5.2.1, because `@nestjs/platform-express` 11.2.7 pins it exactly — a
138
+ direct bump would put two copies of express into your tree. `better-auth` stays on 1.7.7, the current release.
139
+
140
+ ## Compatibility Notes
141
+
142
+ | Pattern | Status |
143
+ | ------- | ------ |
144
+ | npm-mode and vendor-mode projects | Unaffected by the package update; §1–§4 apply to your own `tests/` and `scripts/` |
145
+ | Projects generated from starter ≥ 11.42.10 | §1–§4 already present |
146
+ | Projects not generated from `nest-server-starter` | Nothing to do |
147
+ | CI on a shared GitLab runner | Keep the low-resource cap; do not add a GitHub-runner exception |
148
+
149
+ ## Troubleshooting
150
+
151
+ **`[e2e] low-resource mode: … -> maxForks=…` in your log**
152
+ Your copy still sets `poolOptions` — the cap is not applied. Port §1.
153
+
154
+ **`[e2e-governor] could not claim a slot (…) — proceeding without the governor.`**
155
+ The slot directory is not writable (owned by another user, read-only tmpdir). The run continues, ungoverned.
156
+ Point `LT_E2E_SLOT_DIR` at a writable directory to get the governor back.
157
+
158
+ ## Module Documentation
159
+
160
+ - [`.claude/rules/testing.md`](../.claude/rules/testing.md) — run governor, low-resource mode, drop guard
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "11.42.10",
3
+ "version": "11.42.11",
4
4
  "description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
5
5
  "keywords": [
6
6
  "node",
@@ -34,7 +34,7 @@
34
34
  "check:server-start": "cross-env NODE_ENV=local node scripts/check-server-start.mjs --entry=dist/main.js --port-env=NSC__PORT --ready=\"Server starte[dt] at\" --path=/",
35
35
  "check:swc-tdz": "nest build -b swc -p tsconfig.swc-tdz.json && node scripts/check-swc-tdz.mjs",
36
36
  "cnaf": "pnpm run check:naf",
37
- "docs": "pnpm run docs:ci && open http://127.0.0.1:8080/ && open ./public/index.html && compodoc -p tsconfig.json -s ",
37
+ "docs": "pnpm run docs:ci && node scripts/open.mjs http://127.0.0.1:8080/ ./public/index.html && compodoc -p tsconfig.json -s",
38
38
  "docs:bootstrap": "node extras/update-spectaql-version.mjs && node scripts/run-spectaql.mjs",
39
39
  "docs:ci": "ts-node ./scripts/init-server.ts && pnpm run docs:bootstrap && compodoc -p tsconfig.json",
40
40
  "format": "oxfmt --write src/ scripts/",
@@ -59,7 +59,7 @@
59
59
  "start:prod": "cross-env NODE_ENV=production node dist/main.js",
60
60
  "test": "pnpm run vitest:unit && pnpm run vitest",
61
61
  "test:ci": "pnpm run vitest:unit && pnpm run vitest:ci",
62
- "test:cleanup": "find tests -type f \\( -name '*.txt' -o -name '*.bin' -o -name '*.png' \\) -not -name '.gitkeep' -delete && echo 'Test artifacts cleaned up'",
62
+ "test:cleanup": "node scripts/clean-test-artifacts.mjs",
63
63
  "test:cov": "pnpm run vitest:unit:cov && pnpm run vitest:cov",
64
64
  "test:e2e": "pnpm run vitest",
65
65
  "test:infra": "node scripts/test-infra.mjs up",
@@ -129,7 +129,7 @@
129
129
  "mongoose": "9.10.4",
130
130
  "multer": "2.4.0",
131
131
  "node-mailjet": "6.0.11",
132
- "nodemailer": "10.0.16",
132
+ "nodemailer": "10.1.0",
133
133
  "passport": "0.7.0",
134
134
  "passport-jwt": "4.0.1",
135
135
  "reflect-metadata": "0.2.2",
@@ -182,9 +182,9 @@
182
182
  }
183
183
  },
184
184
  "devDependencies": {
185
- "@aws-sdk/client-s3": "3.1147.0",
186
- "@aws-sdk/lib-storage": "3.1147.0",
187
- "@aws-sdk/s3-request-presigner": "3.1147.0",
185
+ "@aws-sdk/client-s3": "3.1149.0",
186
+ "@aws-sdk/lib-storage": "3.1149.0",
187
+ "@aws-sdk/s3-request-presigner": "3.1149.0",
188
188
  "@better-auth/core": "1.7.7",
189
189
  "@better-auth/passkey": "1.7.7",
190
190
  "@compodoc/compodoc": "2.0.0",
@@ -198,13 +198,13 @@
198
198
  "@types/cookie-parser": "1.4.10",
199
199
  "@types/ejs": "3.1.5",
200
200
  "@types/express": "5.0.6",
201
- "@types/lodash": "4.17.25",
201
+ "@types/lodash": "4.17.26",
202
202
  "@types/multer": "2.3.0",
203
- "@types/node": "26.6.4",
203
+ "@types/node": "26.6.5",
204
204
  "@types/passport": "1.0.17",
205
205
  "@vitest/coverage-v8": "4.1.11",
206
206
  "better-auth": "1.7.7",
207
- "bullmq": "6.3.11",
207
+ "bullmq": "6.3.12",
208
208
  "cross-env": "10.1.0",
209
209
  "ioredis": "6.0.0",
210
210
  "nodemon": "3.1.14",
@@ -213,14 +213,14 @@
213
213
  "oxfmt": "0.71.0",
214
214
  "oxlint": "1.87.0",
215
215
  "rimraf": "6.1.3",
216
- "smtp-server": "3.19.17",
216
+ "smtp-server": "3.19.19",
217
217
  "ts-node": "10.9.2",
218
218
  "tsconfig-paths": "4.2.0",
219
219
  "tsx": "4.23.15",
220
220
  "tus-js-client": "4.3.1",
221
221
  "typescript": "5.9.3",
222
222
  "unplugin-swc": "2.0.0",
223
- "vite": "8.3.3",
223
+ "vite": "8.3.4",
224
224
  "vite-plugin-node": "8.0.0",
225
225
  "vitest": "4.1.11"
226
226
  },