@sapphire/plugin-api
Advanced tools
Comparing version 2.1.5-next.73a35e98da56a27a05b2179188599fcaf1d87ff0.0 to 2.1.5-next.ab0f777.0
@@ -14,3 +14,3 @@ import type { ApiRequest } from './ApiRequest'; | ||
/** | ||
* Parses a host using the {@link https://github.com/lupomontero/psl psl} library to extract the domain. | ||
* Parses a host using the {@linkplain https://github.com/lupomontero/psl psl} library to extract the domain. | ||
* This is used for the domain of the cookie | ||
@@ -17,0 +17,0 @@ * @param host The hot to parse |
@@ -103,3 +103,3 @@ "use strict"; | ||
/** | ||
* Parses a host using the {@link https://github.com/lupomontero/psl psl} library to extract the domain. | ||
* Parses a host using the {@linkplain https://github.com/lupomontero/psl psl} library to extract the domain. | ||
* This is used for the domain of the cookie | ||
@@ -106,0 +106,0 @@ * @param host The hot to parse |
{ | ||
"name": "@sapphire/plugin-api", | ||
"version": "2.1.5-next.73a35e98da56a27a05b2179188599fcaf1d87ff0.0", | ||
"version": "2.1.5-next.ab0f777.0", | ||
"description": "Plugin for @sapphire/framework to expose a REST API", | ||
@@ -36,3 +36,5 @@ "author": "@sapphire", | ||
"dependencies": { | ||
"@types/node-fetch": "^2.5.10", | ||
"@types/psl": "^1.1.0", | ||
"@types/ws": "latest", | ||
"node-fetch": "^2.6.1", | ||
@@ -42,21 +44,2 @@ "psl": "^1.8.0", | ||
}, | ||
"peerDependencies": { | ||
"@sapphire/framework": "^1.x", | ||
"@sapphire/pieces": "1.x", | ||
"@types/node-fetch": "^2.x", | ||
"@types/ws": "latest", | ||
"discord-api-types": "^0.18.x", | ||
"discord.js": "12.x" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@types/ws": { | ||
"optional": true | ||
}, | ||
"@types/node-fetch": { | ||
"optional": true | ||
}, | ||
"discord-api-types": { | ||
"optional": true | ||
} | ||
}, | ||
"repository": { | ||
@@ -92,3 +75,3 @@ "type": "git", | ||
}, | ||
"gitHead": "73a35e98da56a27a05b2179188599fcaf1d87ff0" | ||
"gitHead": "ab0f77790d3d83175a1b49d9566be1a4c51b3e16" | ||
} |
@@ -19,3 +19,3 @@ <div align="center"> | ||
T.B.D. | ||
This plugin provides an API endpoint for your bot that can be called from external services. A good exemplary use case for this is once your bot grows to have enough configuration options that you want to offer a website to your end-users to change those settings, and your website needs to interface with the bot for this to work. | ||
@@ -28,7 +28,17 @@ ## Features | ||
- Includes ESM ready entrypoint | ||
- Premade OAuth 2.0 endpoints | ||
## Installation | ||
`@sapphire/plugin-api` depends on the following packages. Be sure to install these along with this package! | ||
- [`@sapphire/framework`](https://www.npmjs.com/package/@sapphire/framework) | ||
- [`@sapphire/pieces v1.x`](https://www.npmjs.com/package/@sapphire/pieces/v/1.2.5) | ||
- [`discord.js`](https://www.npmjs.com/package/discord.js) | ||
- [`discord-api-types`](https://www.npmjs.com/package/discord-api-types) | ||
You can use the following command to install this package, or replace `npm install` with your package manager of choice. | ||
```sh | ||
yarn add @sapphire/plugin-api | ||
npm install @sapphire/plugin-api @sapphire/framework @sapphire/pieces@1 discord.js discord-api-types | ||
``` | ||
@@ -40,4 +50,49 @@ | ||
T.B.D. | ||
Start by importing the registration file in your project to use the plugin: | ||
**JavaScript** | ||
```js | ||
require('@sapphire/plugin-api/register'); | ||
``` | ||
**TypeScript** | ||
```ts | ||
import '@sapphire/plugin-api/register'; | ||
``` | ||
Then, you can use the following configuration options in your SapphireClient extension class or initializer. This will either be located in your `new SapphireClient` constructor call, or `super` in your constructor method if you use an extension class. | ||
```js | ||
{ | ||
auth: { | ||
// The application/client ID of your bot. | ||
// You can find this at https://discord.com/developers/applications | ||
id: '', | ||
// The client secret of your bot. | ||
// You can find this at https://discord.com/developers/applications | ||
secret: '', | ||
// The name of the authentication cookie. | ||
cookie: 'SAPPHIRE_AUTH', | ||
// The URL that users should be redirected to after a successful authentication | ||
redirect: '', | ||
// The scopes that should be given to the authentication. | ||
scopes: ['identify'], | ||
// Transformers to transform the raw data from Discord to a different structure. | ||
transformers: [] | ||
}, | ||
// The prefix for all routes, e.g. / or v1/. | ||
prefix: '', | ||
// The origin header to be set on every request at 'Access-Control-Allow-Origin. | ||
origin: '*', | ||
// Any options passed to the NodeJS "net" internal server.listen function | ||
// See https://nodejs.org/api/net.html#net_server_listen_options_callback | ||
listenOptions: { | ||
// The port the API will listen on. | ||
port: 4000 | ||
} | ||
} | ||
``` | ||
## API Documentation | ||
@@ -44,0 +99,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199361
6
142
+ Added@types/node-fetch@^2.5.10
+ Added@types/ws@latest
- Removed@discordjs/collection@0.1.6(transitive)
- Removed@discordjs/form-data@3.0.1(transitive)
- Removed@sapphire/discord-utilities@2.12.0(transitive)
- Removed@sapphire/discord.js-utilities@1.6.0(transitive)
- Removed@sapphire/framework@1.0.2(transitive)
- Removed@sapphire/pieces@1.2.5(transitive)
- Removed@sapphire/ratelimits@1.2.5(transitive)
- Removed@sapphire/utilities@1.7.0(transitive)
- Removedabort-controller@3.0.0(transitive)
- Removeddiscord-api-types@0.18.10.36.3(transitive)
- Removeddiscord.js@12.5.3(transitive)
- Removedevent-target-shim@5.0.1(transitive)
- Removedlexure@0.17.0(transitive)
- Removedprism-media@1.3.5(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedtweetnacl@1.0.3(transitive)
- Removedws@7.5.10(transitive)