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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Gabriel
3
+ Copyright (c) 2021-present Gabriel da Cunha
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
  [![npm version](https://img.shields.io/npm/v/pokenode-ts?logo=npm)](https://www.npmjs.com/package/pokenode-ts)
10
+ [![min+gzip](https://img.shields.io/bundlejs/size/pokenode-ts?label=min%2Bgzip)](https://bundlejs.com/?q=pokenode-ts)
10
11
  [![CI](https://github.com/Gabb-c/pokenode-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/Gabb-c/pokenode-ts/actions/workflows/ci.yml)
11
- [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Gabb-c_pokenode-ts&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Gabb-c_pokenode-ts)
12
- [![install size](https://packagephobia.com/badge?p=pokenode-ts)](https://packagephobia.com/result?p=pokenode-ts)
12
+ [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=Gabb-c_pokenode-ts&metric=alert_status)](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
- console.log(luxray.name); // "luxray"
34
- console.log(luxray.types.map((slot) => slot.type.name)); // ["electric"]
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
- Need more than one section of the API? `MainClient` bundles all twelve clients behind one object,
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
- ## Features
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
- ## Documentation
57
+ ```ts
58
+ if (PokenodeError.isPokenodeError(err)) err.status; // 404
59
+ ```
59
60
 
60
- Guides and a page per client live at **[pokenode-ts.vercel.app](https://pokenode-ts.vercel.app/)**.
61
+ ## Features
61
62
 
62
- | Guide | |
63
- | --- | --- |
64
- | [Getting started](https://pokenode-ts.vercel.app/guides/getting-started) | Installation, first request, choosing a client |
65
- | [Errors](https://pokenode-ts.vercel.app/guides/errors) | What throws, what doesn't, and how to tell |
66
- | [Cache](https://pokenode-ts.vercel.app/guides/cache) | Tuning the default store, or supplying your own |
67
- | [Logging](https://pokenode-ts.vercel.app/guides/logging) | The `Logger` interface |
68
- | [Custom Fetch](https://pokenode-ts.vercel.app/guides/fetch) | Proxies, retries, headers, timeouts |
69
- | [Migrating to 2.0](https://pokenode-ts.vercel.app/guides/migration) | Coming from the Axios-based 1.x |
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
- Bug reports, docs fixes, and pull requests are welcome — see
80
- [CONTRIBUTING.md](.github/CONTRIBUTING.md). Commits follow
81
- [Conventional Commits](https://www.conventionalcommits.org/).
82
-
83
- - Liked it? [Give it a star ⭐](https://github.com/Gabb-c/pokenode-ts)
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
- ![Analytics](https://repobeats.axiom.co/api/embed/f71a113e3161e1d054170c94e4ac3fcfc960cdd4.svg 'Repobeats analytics image')
90
+ [MIT](https://github.com/Gabb-c/pokenode-ts/blob/main/LICENSE)