@stonyx/rest-server 0.2.1-alpha.32 → 0.2.1-alpha.34
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/README.md +10 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,6 +15,12 @@ REST server module for the [Stonyx framework](https://github.com/abofs/stonyx),
|
|
|
15
15
|
* **Singleton server:** Only one RestServer instance runs, preventing accidental multiple listeners.
|
|
16
16
|
* **Framework integration:** Works seamlessly as part of the Stonyx framework—auto-initialized with the rest of your modules.
|
|
17
17
|
|
|
18
|
+
## Usage reference
|
|
19
|
+
|
|
20
|
+
The sample request classes in [`test/sample/`](https://github.com/abofs/stonyx-rest-server/tree/dev/test/sample) are the canonical usage reference for this module; the integration tests run against them. They are not included in the npm package.
|
|
21
|
+
|
|
22
|
+
The package has a single export, `@stonyx/rest-server` (the `RestServer` default export and the named `Request` export). There are no subpath exports.
|
|
23
|
+
|
|
18
24
|
## RestServer
|
|
19
25
|
|
|
20
26
|
The `RestServer` class wraps an Express.js instance to provide:
|
|
@@ -74,7 +80,7 @@ Configuration is read from `stonyx/config` under `restServer`:
|
|
|
74
80
|
| Option | Type | Default | Description |
|
|
75
81
|
| :---------------: | :-----------------: | :---------- | :--------------------------------------------------------- |
|
|
76
82
|
| `dir` | **String** | `'./requests'` | Directory containing request classes to mount as routes |
|
|
77
|
-
| `camelCaseRoutes` | **Boolean** | `
|
|
83
|
+
| `camelCaseRoutes` | **Boolean** | *(unset — `config/environment.js` sets no default)* | When explicitly `true`, converts hyphenated filenames to camelCase when generating route paths. Unset, so filenames are used **verbatim** |
|
|
78
84
|
| `port` | **Number** | `2666` | Port to listen on |
|
|
79
85
|
| `origin` | **String \| Array** | `'*'` | CORS origin(s) allowed |
|
|
80
86
|
| `methods` | **String** | `'GET,POST,PATCH,PUT,DELETE'` | CORS allowed methods |
|
|
@@ -116,7 +122,7 @@ Case-sensitive matching is a **behaviour change**. Requests that previously reac
|
|
|
116
122
|
**Who is affected:**
|
|
117
123
|
|
|
118
124
|
* Any client sending a URL whose case does not exactly match the mounted path — hand-written links, bookmarked or cached URLs, third-party callers, anything that upper-cases path segments.
|
|
119
|
-
* Any app with a capitalised or hyphenated request filename. Mount paths come from filenames, and `camelCaseRoutes` never lower-cases anything: it only upper-cases the letter following a `-`. So `Users.ts` mounts at `/Users` under **both** `camelCaseRoutes` settings, including the default `
|
|
125
|
+
* Any app with a capitalised or hyphenated request filename. Mount paths come from filenames, and `camelCaseRoutes` never lower-cases anything: it only upper-cases the letter following a `-`. So `Users.ts` mounts at `/Users` under **both** `camelCaseRoutes` settings, including the default. `phone-number.ts` mounts at `/phone-number` by default — `config/environment.js` declares no `camelCaseRoutes` key, so filenames are used verbatim — and at `/phoneNumber` only if you have explicitly set `camelCaseRoutes: true`. Clients that hardcode `/users` or `/phonenumber` start 404ing.
|
|
120
126
|
* Anything matching the URL downstream of the router — reverse proxies, WAF path rules, analytics path grouping, `originalUrl`-based routing.
|
|
121
127
|
* `GET /HEALTH` no longer answers. Only `GET /health` does.
|
|
122
128
|
|
|
@@ -138,7 +144,7 @@ If routes appear to have vanished after upgrading, `Cannot GET` in the response
|
|
|
138
144
|
ls requests/ # every filename becomes a mount path
|
|
139
145
|
```
|
|
140
146
|
|
|
141
|
-
Any filename that is not already all-lowercase
|
|
147
|
+
Any filename that is not already all-lowercase produces a mixed-case mount that now requires exact casing from callers. Hyphenated filenames are **not** affected by default, because `camelCaseRoutes` is unset and filenames are used verbatim; they are only at risk if you have explicitly set `camelCaseRoutes: true`, which mounts `phone-number.ts` at `/phoneNumber`.
|
|
142
148
|
|
|
143
149
|
**Opting out (temporary).** Two forms, and they are **not** interchangeable:
|
|
144
150
|
|
|
@@ -237,7 +243,7 @@ project-root/
|
|
|
237
243
|
* `public.js` — contains public-facing routes without authentication
|
|
238
244
|
* `private.js` — contains routes with authentication via the `auth` hook
|
|
239
245
|
|
|
240
|
-
The `RestServer` will automatically mount these routes using the filenames as paths (`/public` and `/private` by default, or
|
|
246
|
+
The `RestServer` will automatically mount these routes using the filenames as paths (`/public` and `/private` by default, or camelCased if `camelCaseRoutes` is enabled).
|
|
241
247
|
|
|
242
248
|
### Example Requests
|
|
243
249
|
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"stonyx-async",
|
|
5
5
|
"stonyx-module"
|
|
6
6
|
],
|
|
7
|
-
"version": "0.2.1-alpha.
|
|
7
|
+
"version": "0.2.1-alpha.34",
|
|
8
8
|
"description": "Rest Server Module for Stonyx Framework",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"cors": "^2.8.5",
|
|
38
38
|
"express": "^5.1.0",
|
|
39
|
-
"stonyx": "0.2.3-beta.
|
|
39
|
+
"stonyx": "0.2.3-beta.98"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@stonyx/utils": "0.2.3-beta.
|
|
42
|
+
"@stonyx/utils": "0.2.3-beta.27",
|
|
43
43
|
"@types/cors": "^2.8.17",
|
|
44
44
|
"@types/express": "^5.0.6",
|
|
45
45
|
"@types/node": "^25.5.2",
|