Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pavel-durov/poke-sdk-typescript
PokeAPI sdk written in Typescript
https://github.com/pavel-durov/poke-sdk-typescript
Last synced: 19 days ago
JSON representation
PokeAPI sdk written in Typescript
- Host: GitHub
- URL: https://github.com/pavel-durov/poke-sdk-typescript
- Owner: Pavel-Durov
- License: mit
- Created: 2023-08-08T08:41:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-08T17:19:49.000Z (over 1 year ago)
- Last Synced: 2024-11-30T08:39:05.034Z (about 1 month ago)
- Language: TypeScript
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# poke.sdk.ts
[PokeAPI](https://pokeapi.co/) SDK written in Typescript.
Supported endpoints:
- `GET https://pokeapi.co/api/v2/pokemon/{id or name}`
- `GET https://pokeapi.co/api/v2/nature/{id or name}`
- `GET https://pokeapi.co/api/v2/stat/{id or name}`## SDK Installation
### Installing via npm
```shell
$ npm install poke-sdk-typescript
```
### Installing from source
```shell
$ git clone https://github.com/Pavel-Durov/poke-sdk-typescript.git
$ cd poke-sdk-typescript
$ npm run build
$ npm pack --pack-destination .
$ npm install file:/path/to/poke-sdk-typescript-0.0.1.tgz # execute in the target project
```## SDK Example Usage
```typescript
import SDK from 'poke-sdk-typescript';(async () => {
const sdk = new SDK();
const pokemon = await sdk.Poke.getPokemon('1');
const nature = await sdk.Poke.getNature('2');
const stat = await sdk.Poke.getStat('3');
console.log({ pokemon, nature, stat });
})()
```## SDK Errors
In case of an API error, a generic error with an appropriate error message and HTTP status cade will be produced.
Example:```shell
const sdk = new SDK();
const pokemon = await sdk.Poke.getPokemon('pavelchu');
...
(node:171922) UnhandledPromiseRejectionWarning: NetworkError: Request failed with status code 404
at Poke. (/home/kimchi/git-repos/Pavel-Durov/poke.sdk.ts/.build/node_modules/poke-sdk-typescript/dist/poke.js:37:23)
at Generator.throw ()
at rejected (/home/kimchi/git-repos/Pavel-Durov/poke.sdk.ts/.build/node_modules/poke-sdk-typescript/dist/poke.js:6:65)
at processTicksAndRejections (internal/process/task_queues.js:95:5
```## Tests
```shell
$ npm run test # run unit tests
$ npm run test:integration # run integration tests
$ ./scripts/e2e.sh # end-to-end tests
```## Lint
```shell
$ npm run lint # check linting errors
$ npm run lint:fix # fix linting errors
```## Build
```
$ npm run build
```