Skip to content

Commit 4793cff

Browse files
github-actions[bot]hckhanh
authored andcommitted
chore(release): bump version package
1 parent 6f39513 commit 4793cff

File tree

4 files changed

+56
-50
lines changed

4 files changed

+56
-50
lines changed

.changeset/fancy-geese-sleep.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

.changeset/polite-ads-play.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
11
# what-the-fetch
22

3+
## 2.2.0
4+
5+
### Minor Changes
6+
7+
- b5be69a: Add HTTP method prefix notation (@method/path) for declaring methods in API schema paths
8+
9+
### New Feature: HTTP Method Prefix Notation
10+
11+
You can now declare HTTP methods directly in API schema paths using the `@method/path` syntax:
12+
13+
```typescript
14+
const api = {
15+
"@get/users": {
16+
response: z.array(z.object({ id: z.number(), name: z.string() })),
17+
},
18+
"@post/users": {
19+
body: z.object({ name: z.string(), email: z.string() }),
20+
response: z.object({
21+
id: z.number(),
22+
name: z.string(),
23+
email: z.string(),
24+
}),
25+
},
26+
"@put/users/:id": {
27+
params: z.object({ id: z.number() }),
28+
body: z.object({ name: z.string() }),
29+
response: z.object({ id: z.number(), name: z.string() }),
30+
},
31+
} as const;
32+
```
33+
34+
**Key Features:**
35+
36+
- Supports all HTTP methods: `@get`, `@post`, `@put`, `@delete`, `@patch`, etc.
37+
- Method names are case-insensitive (normalized to uppercase)
38+
- `@get/api` is equivalent to `/api` in URL, only the HTTP method differs
39+
- Backward compatible: paths without prefix continue to work as before
40+
- Type-safe: `RequestInit` parameters are now `Omit<RequestInit, 'method'>` to prevent method override
41+
42+
**Implementation:**
43+
44+
- Added `parseMethodFromPath()` utility function to extract method prefix
45+
- Updated `createFetch()` to use the extracted method from path prefix
46+
- Restricted `RequestInit` types to prevent method override
47+
48+
### Patch Changes
49+
50+
- 52df593: Update `fast-url` dependency to version 6.0.2 for significant performance optimizations. This release includes:
51+
52+
- **Pre-compiled regex**: Path parameter regex is now extracted to module scope to avoid recompilation on every `path()` call, improving efficiency for path template processing
53+
- **Optimized string joining**: URL joining now uses direct string indexing instead of `endsWith`/`startsWith` methods, with fast paths for empty strings and common scenarios, reducing unnecessary string slicing
54+
- **Optimized parameter filtering**: The `removeNullOrUndef()` function now checks for null/undefined values before allocating new objects and uses direct property iteration instead of `Object.entries`/`Object.fromEntries`, resulting in faster execution and less memory usage
55+
56+
For full details, see the [fast-url 6.0.2 release notes](https://github.com/hckhanh/fast-url/releases/tag/fast-url%406.0.2).
57+
358
## 2.1.0
459

560
### Minor Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "what-the-fetch",
33
"description": "Type-safe API client with schema validation using Standard Schema",
4-
"version": "2.1.0",
4+
"version": "2.2.0",
55
"author": {
66
"name": "Khánh Hoàng",
77
"email": "[email protected]",

0 commit comments

Comments
 (0)