chore: rest readme

This commit is contained in:
Yuzu 2022-08-01 20:36:53 -05:00
parent dc6dd6c08b
commit 5464da10ae
9 changed files with 86 additions and 3 deletions

View File

@ -22,7 +22,7 @@ for further reading join our [Discord](https://discord.gg/zmuvzzEFz2)
import type { DiscordUser } from '@biscuitland/api-types'; import type { DiscordUser } from '@biscuitland/api-types';
``` ```
## Example for [Deno](https://deno.land/) ## Example for [Deno](https://deno.land/)
``` ```ts
import type { DiscordUser } from "https://unpkg.com/@biscuitland/api-types@1.1.0/dist/index.d.ts"; import type { DiscordUser } from "https://unpkg.com/@biscuitland/api-types@1.1.0/dist/index.d.ts";
``` ```

View File

@ -52,7 +52,7 @@ B:\project> node index.js
For node 16.+: For node 16.+:
``` ```
B:\project> node --experimenta-fetch index.js B:\project> node --experimental-fetch index.js
``` ```
## Links ## Links

View File

@ -0,0 +1,20 @@
# biscuit
## A brand new bleeding edge non bloated Discord library
<img align="right" src="https://raw.githubusercontent.com/oasisjs/biscuit/main/assets/icon.svg" alt="biscuit"/>
## Install (for [node18](https://nodejs.org/en/download/))
```sh-session
npm install @biscuitland/helpers
yarn add @biscuitland/helpers
```
for further reading join our [Discord](https://discord.gg/zmuvzzEFz2)
## Most importantly, helpers is:
- Collectors
- Builders
- Other helper functions such as setPresence

View File

@ -1,5 +1,5 @@
{ {
"name": "@biscuitland/extra", "name": "@biscuitland/helpers",
"version": "1.1.0", "version": "1.1.0",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",

View File

@ -0,0 +1,63 @@
# biscuit
## A brand new bleeding edge non bloated Discord library
<img align="right" src="https://raw.githubusercontent.com/oasisjs/biscuit/main/assets/icon.svg" alt="biscuit"/>
## Install (for [node18](https://nodejs.org/en/download/))
```sh-session
npm install @biscuitland/rest
yarn add @biscuitland/rest
```
for further reading join our [Discord](https://discord.gg/zmuvzzEFz2)
## Most importantly, biscuit's rest is:
An standalone rest library that is yet easy to use and easy to host on a serverless infraestructure, it is meant to be used with biscuit's libraries
## Example
```ts
import { DefaultRestAdapter } from "@biscuitland/rest";
import Fastify from "fastify";
const manager = new DefaultRestAdapter({
url: `http://localhost:port...`,
token: "your token goes here",
version: 10,
});
const app = Fastify({});
app.all("*", (req, reply) => {
let response: unknown;
switch (req.method) {
case "GET":
response = await rest.get(req.url, req.body);
break;
case "POST":
response = await rest.post(req.url, req.body);
break;
case "PUT":
response = await rest.put(req.url, req.body);
break;
case "PATCH":
response = await rest.patch(req.url, req.body);
break;
case "DELETE":
response = await rest.delete(req.url, req.body);
break;
}
if (response)
reply.status(200).send({ status: 200, data: response });
else
reply.status(204).send({ status: 204, data: null });
});
app.listen({ port: "port..." });
```
This package can be delivered through [unpkg](https://unpkg.com/) however is not tested yet