You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-1Lines changed: 29 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,31 @@ const api = createClient({
34
34
const user =awaitapi.get<{ id:string; name:string }>('/users/123')
35
35
```
36
36
37
+
### JSON request bodies
38
+
39
+
```ts
40
+
import { createClient } from'@gavoryn/clearfetch'
41
+
42
+
const api =createClient({
43
+
baseURL: 'https://api.example.com',
44
+
})
45
+
46
+
const created =awaitapi.post<{ id:string }>('/users', {
47
+
json: {
48
+
name: 'Ada Lovelace',
49
+
role: 'admin',
50
+
},
51
+
})
52
+
```
53
+
54
+
If `json` is provided, clearfetch:
55
+
56
+
- serializes the value with `JSON.stringify()`
57
+
- sets `Content-Type: application/json` if it is not already present
58
+
- rejects the request with `ConfigError` if `body` is also provided
59
+
60
+
Use `body` directly only when you want to send a raw payload such as `FormData`, `URLSearchParams`, or pre-serialized text.
61
+
37
62
### Extended client defaults
38
63
39
64
```ts
@@ -124,6 +149,8 @@ try {
124
149
-`beforeRequest` may mutate headers, but hook option metadata is read-only.
125
150
- Retry support is opt-in and conservative by default.
126
151
- Retry support does not allow streaming request bodies.
152
+
- The `json` helper serializes request bodies and sets `Content-Type: application/json` when absent.
153
+
-`body` and `json` cannot be used together.
127
154
- The package performs no telemetry or hidden network activity beyond the caller's request.
128
155
129
156
## Supported runtimes
@@ -148,6 +175,7 @@ The package is ESM-only and does not target legacy runtimes or polyfill-driven e
148
175
- CI also runs a lightweight browser-like test path using `happy-dom` on Node.js `20`.
149
176
- Dependency review is configured for pull requests and manual validation, but requires the relevant GitHub security features to be enabled on the repository.
150
177
- The release workflow supports a non-publishing dry-run path via manual dispatch.
178
+
- npm publishing now uses npm trusted publishing from GitHub Actions instead of a long-lived publish token.
151
179
- Normal releases are expected to publish from GitHub Actions, not from local machines.
152
180
- Release and repository protection policy is documented in [RELEASE.md](./RELEASE.md).
153
181
@@ -170,4 +198,4 @@ The public package surface is intentionally narrow:
170
198
171
199
## Status
172
200
173
-
`clearfetch` is ready for its initial `1.0.0` release as `@gavoryn/clearfetch`. Project goals and behavior are documented in `PURPOSE.md` and `DESIGN.md`.
201
+
`clearfetch` is published as `@gavoryn/clearfetch`. Project goals and behavior are documented in `PURPOSE.md` and `DESIGN.md`.
Copy file name to clipboardExpand all lines: RELEASE.md
+11-4Lines changed: 11 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,22 +45,29 @@ Release tags should be annotated and should be signed when practical.
45
45
46
46
If signed tags are not yet mandatory for every maintainer environment, they should still be treated as the target policy for official releases.
47
47
48
-
## npm account and token requirements
48
+
## npm account and trusted publishing requirements
49
49
50
50
The npm account used to administer the package should require 2FA.
51
51
52
-
Publishing from CI should use an npm automation token stored as the `NPM_TOKEN` GitHub Actions secret for the `npm` environment. That token should have the minimum scope necessary for publishing this package.
52
+
Publishing from CI should use npm trusted publishing through GitHub Actions OIDC, not a long-lived write token.
53
+
54
+
The npm package settings for `@gavoryn/clearfetch` should define a trusted publisher with:
55
+
56
+
- organization or user: `bmurdock`
57
+
- repository: `clearfetch`
58
+
- workflow filename: `release.yml`
59
+
- environment name: `npm`
53
60
54
61
## GitHub Actions configuration
55
62
56
63
The release workflow assumes:
57
64
58
65
- GitHub Actions is enabled for the repository
59
66
- an environment named `npm` exists
60
-
- the `npm` environment contains an `NPM_TOKEN` secret
67
+
- the npm package has a matching trusted publisher configured on npmjs.com
61
68
- maintainers review changes to workflow files with the same care as runtime code
62
69
63
-
The release workflow uses `id-token: write` so npm provenance can be attached during publish.
70
+
The release workflow uses `id-token: write` so npm can exchange the workflow identity for publish access. When trusted publishing is configured, npm also generates provenance automatically for public packages from public repositories.
0 commit comments