cursedops 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/serve.ts +20 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursedops",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "The build-and-ops answers this generation's apps wrote independently and identically: finding a generation's roots without knowing a path, macOS launchd agent install/replace/remove, the scaffolding of a deployed smoke, and the static-serving helpers eight apps copied — the path-traversal guard and the API floor among them. Mechanism only — no app knows its name from here. Bun, zero dependencies, ships source.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
package/src/serve.ts
CHANGED
|
@@ -207,13 +207,27 @@ export function canonicalApiPath(urlPath: string): string | null {
|
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
209
|
* The same normalisation, applied to a whole request. Returns the request unchanged when
|
|
210
|
-
* there is nothing to normalise, so
|
|
210
|
+
* there is nothing to normalise, so a caller that guards on {@link canonicalApiPath}
|
|
211
|
+
* allocates nothing.
|
|
211
212
|
*
|
|
212
|
-
* 🔴
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
213
|
+
* 🔴 **Call it from INSIDE the floor handler and re-dispatch, not from the host's
|
|
214
|
+
* `fetch`.** Both work; only one of them cannot be wired up wrong. A router has many
|
|
215
|
+
* callers — `Bun.serve`, a Worker's `export default`, and every test harness that drives
|
|
216
|
+
* `app.fetch` directly — and a wrap installed at one of them is absent from the others.
|
|
217
|
+
* That is the shape of the fault this whole family exists to close: the previous
|
|
218
|
+
* generation's artifact had a floor its harness mounted correctly and production did not,
|
|
219
|
+
* and it stayed green for six days. A floor that answers
|
|
220
|
+
*
|
|
221
|
+
* const canonical = canonicalApiPath(new URL(c.req.url).pathname);
|
|
222
|
+
* if (canonical !== null) return app.fetch(canonicalApiRequest(c.req.raw));
|
|
223
|
+
* return c.json(apiNotFoundBody(...), 404, ...);
|
|
224
|
+
*
|
|
225
|
+
* is reached by every caller there will ever be, costs nothing on the hot path — only a
|
|
226
|
+
* MISS gets here — and cannot loop, because the canonical path has no trailing slash left
|
|
227
|
+
* to strip and a second miss falls straight to the body.
|
|
228
|
+
*
|
|
229
|
+
* It must not be a Hono middleware either: Hono matches the route before the chain runs,
|
|
230
|
+
* so a middleware cannot change which handler answers, which is the entire job here.
|
|
217
231
|
*/
|
|
218
232
|
export function canonicalApiRequest(request: Request): Request {
|
|
219
233
|
const url = new URL(request.url);
|