@stonyx/orm 0.3.2-alpha.96 → 0.3.2-alpha.98

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 (2) hide show
  1. package/README.md +13 -8
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -351,16 +351,21 @@ the mount point, so inside the REST server it is `/angela`, not `/owners/angela`
351
351
  — a suffix comparison against it never matches and the request falls through to
352
352
  whatever the method returns next. `request.originalUrl` keeps the full path but
353
353
  is still the raw text the client sent, so it varies with query strings
354
- (`/owners?x=1`), trailing slashes (`/owners/angela/`), casing (`/OwNeRs/angela`,
355
- which Express routes to the same handler) and percent-encoding
356
- (`/owners/%61ngela`). Each of those is a plain address-bar request, and each one
357
- slips past a URL predicate. `request.params.id` is identical for all of them.
354
+ (`/owners?x=1`), trailing slashes (`/owners/angela/`), casing (`/OwNeRs/angela`)
355
+ and percent-encoding (`/owners/%61ngela`). Each of those is a plain address-bar
356
+ request. Which of them reach your handler at all depends on how the REST server
357
+ configures Express route matching that is a deployment detail you should not
358
+ be building an authorization decision on top of. `request.params.id` is
359
+ identical for every spelling that does reach you.
358
360
 
359
361
  **One access class per model when the rules are model-specific.** `access()`
360
- receives only the request, and the request does not carry the model name in any
361
- form that is safe to match on — `request.baseUrl` is the mount text as the
362
- client spelled it (`/OWNERS`), not the model. A class may still list several
363
- models in `models` when they share one rule.
362
+ receives only the request, and the request does not carry the model name
363
+ directly — `request.baseUrl` is the *mount text as the client spelled it*
364
+ (`/OWNERS`), so it must be case-normalised before it is compared, and it is
365
+ still the mount rather than the model. Deriving a model from it means every
366
+ unrecognised spelling falls through to whatever your method returns next, so
367
+ prefer one class per model. A class may still list several models in `models`
368
+ when they share one rule.
364
369
 
365
370
  **Numeric ids: normalise before you compare.** `request.params.id` is raw text
366
371
  from the client. When it looks numeric the ORM coerces it — `isNaN(id) ? id :
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "stonyx-async",
5
5
  "stonyx-module"
6
6
  ],
7
- "version": "0.3.2-alpha.96",
7
+ "version": "0.3.2-alpha.98",
8
8
  "description": "",
9
9
  "main": "dist/index.js",
10
10
  "type": "module",
@@ -105,8 +105,8 @@
105
105
  "build:test": "tsc -p tsconfig.test.json",
106
106
  "test": "pnpm build && NODE_ENV=test node --import tsx/esm --import ./test/setup.ts node_modules/qunit/bin/qunit.js 'test/**/*-test.ts' && ORM_TEST_ROUTE=/ pnpm test:mounted && ORM_TEST_ROUTE=/api pnpm test:mounted && ORM_TEST_ROUTE=api pnpm test:mounted && ORM_TEST_ROUTE=/api/v1 pnpm test:mounted && ORM_TEST_ROUTE=/api/ pnpm test:mounted && pnpm test:readme && pnpm test:reference",
107
107
  "test:mounted": "node --import tsx/esm --import ./test/integration/mounted-route/setup.ts node_modules/qunit/bin/qunit.js 'test/integration/mounted-route/links-mounted.ts' 'test/zz-exit-test.ts'",
108
- "test:readme": "node --import tsx/esm --import ./test/integration/readme-access/setup.ts node_modules/qunit/bin/qunit.js 'test/integration/readme-access/readme-sample.ts' 'test/zz-exit-test.ts'",
109
- "test:reference": "node --import tsx/esm --import ./test/integration/reference-access/setup.ts node_modules/qunit/bin/qunit.js 'test/integration/reference-access/reference-sample.ts' 'test/zz-exit-test.ts'",
108
+ "test:readme": "pnpm build && node --import tsx/esm --import ./test/integration/readme-access/setup.ts node_modules/qunit/bin/qunit.js 'test/integration/readme-access/readme-sample.ts' 'test/zz-exit-test.ts'",
109
+ "test:reference": "pnpm build && node --import tsx/esm --import ./test/integration/reference-access/setup.ts node_modules/qunit/bin/qunit.js 'test/integration/reference-access/reference-sample.ts' 'test/zz-exit-test.ts'",
110
110
  "test:dynamodb": "pnpm build && node --import tsx/esm --import ./test/integration/dynamodb/setup.ts node_modules/qunit/bin/qunit.js 'test/integration/dynamodb/**/*-test.ts'"
111
111
  }
112
112
  }