pokenode-ts 2.3.0 → 3.0.0
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/LICENSE +1 -1
- package/README.md +35 -36
- package/lib/index.cjs +4187 -11
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +721 -425
- package/lib/index.d.ts +721 -425
- package/lib/index.js +4095 -11
- package/lib/index.js.map +1 -1
- package/lib/rolldown-runtime-BOlb2svz.js +19 -0
- package/package.json +13 -13
- package/lib/rolldown-runtime-mLzODkzB.js +0 -16
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<img src="https://raw.githubusercontent.com/Gabb-c/pokenode-ts/main/docs/src/public/site-logo.svg" width="96" alt="" />
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Gabb-c/pokenode-ts/main/docs/src/public/site-logo.svg" width="96" alt="pokenode-ts-logo" />
|
|
4
4
|
|
|
5
5
|
# Pokenode-ts
|
|
6
6
|
|
|
7
7
|
**A typed [PokéAPI](https://pokeapi.co/) client with zero runtime dependencies.**
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/pokenode-ts)
|
|
10
|
+
[](https://bundlejs.com/?q=pokenode-ts)
|
|
10
11
|
[](https://github.com/Gabb-c/pokenode-ts/actions/workflows/ci.yml)
|
|
11
|
-
[](https://packagephobia.com/result?p=pokenode-ts)
|
|
12
|
+
[](https://sonarcloud.io/summary/new_code?id=Gabb-c_pokenode-ts)
|
|
13
13
|
|
|
14
14
|
[**Documentation**](https://pokenode-ts.vercel.app/) ·
|
|
15
15
|
[Getting started](https://pokenode-ts.vercel.app/guides/getting-started) ·
|
|
@@ -19,23 +19,28 @@
|
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
+
## Install
|
|
23
|
+
|
|
22
24
|
```bash
|
|
23
25
|
npm install pokenode-ts
|
|
24
26
|
```
|
|
25
27
|
|
|
28
|
+
Node 22+, Deno, Bun, browsers, edge runtimes.
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
26
32
|
```ts
|
|
27
33
|
import { PokemonClient } from 'pokenode-ts';
|
|
28
34
|
|
|
29
35
|
const api = new PokemonClient();
|
|
30
|
-
|
|
31
36
|
const luxray = await api.getPokemonByName('luxray');
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
luxray.types.map((slot) => slot.type.name); // ["electric"]
|
|
39
|
+
|
|
40
|
+
const ability = await api.resolve(luxray.abilities[0].ability); // typed Ability
|
|
35
41
|
```
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
sharing a single cache:
|
|
43
|
+
`MainClient` bundles all twelve section clients behind one object, sharing a single cache:
|
|
39
44
|
|
|
40
45
|
```ts
|
|
41
46
|
import { MainClient } from 'pokenode-ts';
|
|
@@ -46,27 +51,25 @@ await api.pokemon.getPokemonByName('luxray');
|
|
|
46
51
|
await api.berry.getBerryByName('cheri');
|
|
47
52
|
```
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- 🛠️ **Typed end to end** — every response mirrors the PokéAPI schema, checked at compile time.
|
|
52
|
-
- 🪶 **Zero dependencies** — native `fetch`. Node 22+, Deno, Bun, browsers, edge runtimes.
|
|
53
|
-
- 📦 **Caching you control** — in-memory by default; swap in Redis, KV, or any `CacheStore`.
|
|
54
|
-
- 🔌 **Your transport** — pass a custom `fetch` for proxies, retries, headers, or timeouts.
|
|
55
|
-
- 🌲 **Pluggable logging** — console, pino, a metrics collector, or nothing at all.
|
|
56
|
-
- 🧭 **One client or twelve** — a focused client, or `MainClient` sharing one cache across all.
|
|
54
|
+
Non-2xx responses reject with `PokenodeError`. Match it with the static guard — `instanceof`
|
|
55
|
+
breaks across the ESM/CJS boundary:
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
```ts
|
|
58
|
+
if (PokenodeError.isPokenodeError(err)) err.status; // 404
|
|
59
|
+
```
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
## Features
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
- **Typed end to end** — responses mirror the PokéAPI schema, checked at compile time.
|
|
64
|
+
- **Zero dependencies** — native `fetch`, nothing else.
|
|
65
|
+
- **Caching you control** — in-memory by default, or any `CacheStore` (Redis, KV).
|
|
66
|
+
- **Yours to wire up** — a custom `fetch` for proxies and retries; `with({ signal, timeout })` per
|
|
67
|
+
request; a logger, or none.
|
|
68
|
+
- **More than a wrapper** — type-chart effectiveness, evolution-chain flattening, sprite URLs,
|
|
69
|
+
localized names.
|
|
70
|
+
- **Conditional requests** — ETag revalidation; concurrent identical URLs share one round trip.
|
|
71
|
+
- **Pagination** — `for await (const berry of api.berry.paginate('listBerries'))`.
|
|
72
|
+
- **One client or twelve** — focused clients, or `MainClient` sharing one cache.
|
|
70
73
|
|
|
71
74
|
## Fair use
|
|
72
75
|
|
|
@@ -76,16 +79,12 @@ The PokéAPI is free and community-run. Pokenode-ts caches by default, which cov
|
|
|
76
79
|
|
|
77
80
|
## Contributing
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
[CONTRIBUTING.md](.github/CONTRIBUTING.md).
|
|
81
|
-
[Conventional Commits](https://www.conventionalcommits.org/).
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
- Found a problem? [Open an issue 🔎](https://github.com/Gabb-c/pokenode-ts/issues)
|
|
85
|
-
- Find it useful? [Buy me a coffee ❤️](https://github.com/sponsors/Gabb-c)
|
|
82
|
+
Issues and pull requests are welcome — see
|
|
83
|
+
[CONTRIBUTING.md](https://github.com/Gabb-c/pokenode-ts/blob/main/.github/CONTRIBUTING.md).
|
|
84
|
+
Commits follow [Conventional Commits](https://www.conventionalcommits.org/). If it's useful to you,
|
|
85
|
+
[star it](https://github.com/Gabb-c/pokenode-ts) or
|
|
86
|
+
[sponsor it](https://github.com/sponsors/Gabb-c).
|
|
86
87
|
|
|
87
88
|
## License
|
|
88
89
|
|
|
89
|
-
[MIT](LICENSE)
|
|
90
|
-
|
|
91
|
-

|
|
90
|
+
[MIT](https://github.com/Gabb-c/pokenode-ts/blob/main/LICENSE)
|