-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start on the really big rest rewrite
- Loading branch information
1 parent
9a05595
commit eb36d78
Showing
36 changed files
with
3,487 additions
and
7,949 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
**/.env | ||
.yarn/cache | ||
.yarn/install-state.gz | ||
**/.token | ||
**/.token | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,47 @@ | ||
# @fuwa/rest | ||
|
||
## 0.4.0 | ||
|
||
### Major Changes | ||
|
||
- changed certain endpoints from using function arguments for the JSON body to an object | ||
|
||
```ts | ||
import { REST } from '@fuwa/rest/dist'; | ||
|
||
const client = new REST() | ||
|
||
await client.executeWebhook("webhookId", "token", "") | ||
``` | ||
|
||
- renamed some endpoint methods to their equivalent in the Discord API docs | ||
- moved from having `reason` and `with_*` options as their own arguments to having them inside an extended | ||
version of `RequestOptions` | ||
|
||
|
||
### Minor Changes | ||
|
||
- add options to all `RESTManager` methods, providing access to options like whether to use auth, rate limits, etc. | ||
|
||
|
||
## 0.3.0 | ||
|
||
### Minor Changes | ||
|
||
- add REST entrypoint class | ||
|
||
Similar to [ottercord](https://github.com/Commandtechno/ottercord) but all | ||
Similar to [ottercord](https://github.com/Commandtechno/ottercord) but all | ||
manual. | ||
|
||
Its core function is to provide an easier method of interacting directly with | ||
Its core function is to provide an easier method of interacting directly with | ||
the API instead of using the main package and implementing the extra HTTP | ||
boilerplate yourself. | ||
|
||
- a new class, `REST`, which provides an almost [`@discordjs/rest`]-like feel | ||
has been added | ||
- easy methods and typings for documented routes have been added to the above | ||
class | ||
- eg: `REST.createMessage("channelId", { content: "a" })` | ||
- a new class, `REST`, which provides an almost [`@discordjs/rest`]-like feel | ||
has been added | ||
- easy methods and typings for documented routes have been added to the above | ||
class | ||
|
||
```ts | ||
client.createMessage("channelId", { content: "test" }) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
# @fuwa/rest | ||
|
||
A minimal, yet feature-complete, client for [Discord](https://discord.com)'s | ||
public [REST API](https://discord.com/developers/docs). Uses undici. | ||
public [REST API](https://discord.com/developers/docs). Uses undici internally. | ||
|
||
Although the project is designed for Discord, it can be used for many types of | ||
RESTful APIs. | ||
# Installation | ||
|
||
# installation. | ||
|
||
```sh | ||
yarn add @fuwa/rest | ||
npm install --save @fuwa/rest | ||
```shell | ||
# using yarn | ||
$ yarn add @fuwa/rest | ||
# or pnpm | ||
$ pnpm add @fuwa/rest | ||
# or even npm | ||
$ npm install --save @fuwa/rest | ||
``` | ||
|
||
# usage. | ||
# Usage | ||
|
||
```js | ||
import RESTManager, { RESTClient, DefaultDiscordOptions } from '@fuwa/rest'; | ||
|
||
const REST = new RESTManager( | ||
new RESTClient({ | ||
...DefaultDiscordOptions, | ||
auth: 'Bot <token>', | ||
}), | ||
); | ||
|
||
REST.queue({ | ||
route: '/abc/def', | ||
method: 'PATCH', // needs to be uppercase! | ||
import { REST } from '@fuwa/rest'; | ||
|
||
const client = new REST("my_token"); | ||
|
||
await client.patch("/users/@me", { | ||
body: { | ||
foo: 'bar', | ||
username: "fuwa_l0v3r" | ||
}, | ||
}) | ||
// undici's ResponseData is returned | ||
.then(d => d.body.json()); | ||
}); | ||
|
||
// want it simpler? here you go: | ||
await client.editCurrentUser({ | ||
username: "fuwa_l0v3r_shorthand" | ||
}); | ||
``` | ||
|
||
# documentation. | ||
# Documentation | ||
|
||
All endpoints under `REST` are represented by their name in the [Discord Developer Docs](https://discord.com/developers/docs). | ||
|
||
Documentation is planned. Watch this space! | ||
Documentation is planned and on the roadmap. Check back here later. | ||
|
||
# links. | ||
# Links | ||
|
||
- [source.](https://github.com/fuwa-org/fuwa) | ||
- [source code](https://github.com/fuwa-org/fuwa) | ||
- [npm package](https://npmjs.com/@fuwa/rest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.