From d2f139d99f8adbe3397636104315938ac4794a1e Mon Sep 17 00:00:00 2001 From: darthmaim Date: Fri, 10 Nov 2023 13:08:49 +0100 Subject: [PATCH] Add package readmes --- README.md | 20 ++++++++++++++++++++ packages/client/LICENSE | 21 +++++++++++++++++++++ packages/client/README.md | 33 +++++++++++++++++++++++++++++++++ packages/fetch/LICENSE | 21 +++++++++++++++++++++ packages/fetch/README.md | 26 ++++++++++++++++++++++++++ packages/types/LICENSE | 21 +++++++++++++++++++++ packages/types/README.md | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 174 insertions(+) create mode 100644 packages/client/LICENSE create mode 100644 packages/client/README.md create mode 100644 packages/fetch/LICENSE create mode 100644 packages/fetch/README.md create mode 100644 packages/types/LICENSE create mode 100644 packages/types/README.md diff --git a/README.md b/README.md index a901bf6..f1e260e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,22 @@ # gw2api + TypeScript first packages to work with the Guild Wars 2 API + +- [`@gw2api/types`](./packages/types/): Strong types for all data structures used by the Guild Wars 2 API +- [`@gw2api/fetch`](./packages/fetch/): Tiny wrapper around fetch that returns type-safe responses. +- [`@gw2api/client`](./packages/client/): High level abstraction to access the Guild Wars 2 API with support for automatic batching, middlewares, caching, rate-limiting and more. + + +## Contributing + +1. Clone this repository or [make a fork](https://docs.github.com/en/github/getting-started-with-github/quickstart/fork-a-repo) if you plan to submit your changes. +2. Run `npm install` to install the required dependencies. +3. Make your changes. +4. Run `npm run test` to test your changes (make sure to include new tests if you add new functionality). +4. Commit the changes to a new branch and push them to your fork. +5. Create a new [Pull Request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests). + + +## License + +Licensed under the [MIT License](./LICENSE). diff --git a/packages/client/LICENSE b/packages/client/LICENSE new file mode 100644 index 0000000..bf1a8cc --- /dev/null +++ b/packages/client/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 darthmaim + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/client/README.md b/packages/client/README.md new file mode 100644 index 0000000..2060ce3 --- /dev/null +++ b/packages/client/README.md @@ -0,0 +1,33 @@ +# `@gw2api/client` + +This package provies a high level abstraction to access the Guild Wars 2 API in a typesafe way. + +## Usage + +> [!WARNING] +> This package is still highly Work In Progress and the API might change drastically in the first few versions. + + +```ts +import { Gw2ApiClient } from '@gw2api/client'; + +const client = new Gw2ApiClient(); + +// get the first 10 items in german +const items = await client.items.lang('de').page(0, 10); +// -> Array<{ id: number, name: string, ... }> +``` + +## Installation + +```sh +npm i @gw2api/client +``` + +## Contributing + +See [parent readme](../../README.md#contributing). + +## License + +Licensed under the [MIT License](./LICENSE). diff --git a/packages/fetch/LICENSE b/packages/fetch/LICENSE new file mode 100644 index 0000000..bf1a8cc --- /dev/null +++ b/packages/fetch/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 darthmaim + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/fetch/README.md b/packages/fetch/README.md new file mode 100644 index 0000000..7725054 --- /dev/null +++ b/packages/fetch/README.md @@ -0,0 +1,26 @@ +# `@gw2api/fetch` + +This package provides a tiny wrapper around native fetch to call the Guild Wars 2 API that returns typesafe responses. + +## Usage + +```ts +import { fetchGw2Api } from '@gw2api/fetch'; + +const item = await fetchGw2Api('/v2/items/1234'); +// -> { id: number, name: string, ... } +``` + +## Installation + +```sh +npm i @gw2api/fetch +``` + +## Contributing + +See [parent readme](../../README.md#contributing). + +## License + +Licensed under the [MIT License](./LICENSE). diff --git a/packages/types/LICENSE b/packages/types/LICENSE new file mode 100644 index 0000000..bf1a8cc --- /dev/null +++ b/packages/types/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 darthmaim + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/types/README.md b/packages/types/README.md new file mode 100644 index 0000000..137317e --- /dev/null +++ b/packages/types/README.md @@ -0,0 +1,32 @@ +# `@gw2api/types` + +TypeScript types for all datastructures used by the Guild Wars 2 API. + +## Usage + +You can use this library to add strong types when working with the Guild Wars 2 API and not using `@gw2api/fetch` or `@gw2api/client`, for example when using your own api client, working with data from a database, or writing helper functions. + +```ts +import type { Gw2Api, EndpointType } from '@gw2api/types'; + +function getItemName(item: Gw2Api.V2.Item) { + return item.name; +} + +type ItemEndpointResponse = EndpointType<'/v2/items?ids=1,2,3'>; +// -> Array<{ id: number, name: string, ... }> +``` + +## Installation + +```sh +npm i @gw2api/types +``` + +## Contributing + +See [parent readme](../../README.md#contributing). + +## License + +Licensed under the [MIT License](./LICENSE).