@sapphire/plugin-api 7.0.0-next.d27dc1c → 7.0.0-next.d6024cd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +23 -9
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +273 -149
- package/dist/cjs/lib/structures/Augmentations.d.cjs +1 -1
- package/dist/cjs/lib/structures/Augmentations.d.cjs.map +1 -1
- package/dist/cjs/lib/structures/MediaParser.cjs +1 -1
- package/dist/cjs/lib/structures/MediaParser.cjs.map +1 -1
- package/dist/cjs/lib/structures/MediaParserStore.cjs +1 -1
- package/dist/cjs/lib/structures/MediaParserStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/Middleware.cjs +2 -2
- package/dist/cjs/lib/structures/Middleware.cjs.map +1 -1
- package/dist/cjs/lib/structures/MiddlewareStore.cjs +4 -4
- package/dist/cjs/lib/structures/MiddlewareStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/Route.cjs +18 -35
- package/dist/cjs/lib/structures/Route.cjs.map +1 -1
- package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs +20 -0
- package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs.map +1 -0
- package/dist/cjs/lib/structures/RouteStore.cjs +6 -44
- package/dist/cjs/lib/structures/RouteStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/api/ApiRequest.cjs +27 -1
- package/dist/cjs/lib/structures/api/ApiRequest.cjs.map +1 -1
- package/dist/cjs/lib/structures/api/ApiResponse.cjs +8 -2
- package/dist/cjs/lib/structures/api/ApiResponse.cjs.map +1 -1
- package/dist/cjs/lib/structures/api/CookieStore.cjs +4 -4
- package/dist/cjs/lib/structures/api/CookieStore.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/Auth.cjs +2 -2
- package/dist/cjs/lib/structures/http/Auth.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/HttpCodes.cjs +1 -1
- package/dist/cjs/lib/structures/http/HttpCodes.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/HttpMethods.cjs +38 -7
- package/dist/cjs/lib/structures/http/HttpMethods.cjs.map +1 -1
- package/dist/cjs/lib/structures/http/Server.cjs +16 -15
- package/dist/cjs/lib/structures/http/Server.cjs.map +1 -1
- package/dist/cjs/lib/structures/router/RouterBranch.cjs +184 -0
- package/dist/cjs/lib/structures/router/RouterBranch.cjs.map +1 -0
- package/dist/cjs/lib/structures/router/RouterNode.cjs +67 -0
- package/dist/cjs/lib/structures/router/RouterNode.cjs.map +1 -0
- package/dist/cjs/lib/structures/router/RouterRoot.cjs +71 -0
- package/dist/cjs/lib/structures/router/RouterRoot.cjs.map +1 -0
- package/dist/cjs/lib/utils/MimeTypes.cjs +1 -1
- package/dist/cjs/lib/utils/MimeTypes.cjs.map +1 -1
- package/dist/cjs/listeners/PluginRouteError.cjs +3 -3
- package/dist/cjs/listeners/PluginRouteError.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerMiddlewareError.cjs +3 -3
- package/dist/cjs/listeners/PluginServerMiddlewareError.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs +5 -5
- package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs.map +1 -1
- package/dist/cjs/listeners/PluginServerRequest.cjs +42 -8
- package/dist/cjs/listeners/PluginServerRequest.cjs.map +1 -1
- package/dist/cjs/listeners/{PluginServerMatch.cjs → PluginServerRouterBranchMethodNotAllowed.cjs} +5 -10
- package/dist/cjs/listeners/PluginServerRouterBranchMethodNotAllowed.cjs.map +1 -0
- package/dist/cjs/listeners/{PluginServerNoMatch.cjs → PluginServerRouterBranchNotFound.cjs} +3 -3
- package/dist/cjs/listeners/PluginServerRouterBranchNotFound.cjs.map +1 -0
- package/dist/cjs/listeners/PluginServerRouterFound.cjs +22 -0
- package/dist/cjs/listeners/PluginServerRouterFound.cjs.map +1 -0
- package/dist/cjs/listeners/_load.cjs +7 -5
- package/dist/cjs/listeners/_load.cjs.map +1 -1
- package/dist/cjs/mediaParsers/_load.cjs +1 -1
- package/dist/cjs/mediaParsers/_load.cjs.map +1 -1
- package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs +1 -1
- package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs.map +1 -1
- package/dist/cjs/mediaParsers/applicationJson.cjs +1 -1
- package/dist/cjs/mediaParsers/applicationJson.cjs.map +1 -1
- package/dist/cjs/mediaParsers/textPlain.cjs +1 -1
- package/dist/cjs/mediaParsers/textPlain.cjs.map +1 -1
- package/dist/cjs/middlewares/_load.cjs +1 -1
- package/dist/cjs/middlewares/_load.cjs.map +1 -1
- package/dist/cjs/middlewares/auth.cjs +2 -2
- package/dist/cjs/middlewares/auth.cjs.map +1 -1
- package/dist/cjs/middlewares/body.cjs +6 -5
- package/dist/cjs/middlewares/body.cjs.map +1 -1
- package/dist/cjs/middlewares/cookies.cjs +1 -1
- package/dist/cjs/middlewares/cookies.cjs.map +1 -1
- package/dist/cjs/middlewares/headers.cjs +19 -9
- package/dist/cjs/middlewares/headers.cjs.map +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/cjs/register.cjs.map +1 -1
- package/dist/cjs/routes/_load.cjs +5 -5
- package/dist/cjs/routes/_load.cjs.map +1 -1
- package/dist/cjs/routes/oauth/{callback.cjs → callback.post.cjs} +5 -6
- package/dist/cjs/routes/oauth/callback.post.cjs.map +1 -0
- package/dist/cjs/routes/oauth/{logout.cjs → logout.post.cjs} +6 -8
- package/dist/cjs/routes/oauth/logout.post.cjs.map +1 -0
- package/dist/esm/{chunk-JTFKMR4I.mjs → chunk-S573YWRP.mjs} +4 -3
- package/dist/esm/chunk-S573YWRP.mjs.map +1 -0
- package/dist/esm/index.d.mts +273 -149
- package/dist/esm/index.mjs +6 -4
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/structures/Augmentations.d.mjs +1 -1
- package/dist/esm/lib/structures/Augmentations.d.mjs.map +1 -1
- package/dist/esm/lib/structures/MediaParser.mjs +2 -2
- package/dist/esm/lib/structures/MediaParser.mjs.map +1 -1
- package/dist/esm/lib/structures/MediaParserStore.mjs +2 -2
- package/dist/esm/lib/structures/MediaParserStore.mjs.map +1 -1
- package/dist/esm/lib/structures/Middleware.mjs +2 -2
- package/dist/esm/lib/structures/Middleware.mjs.map +1 -1
- package/dist/esm/lib/structures/MiddlewareStore.mjs +4 -4
- package/dist/esm/lib/structures/MiddlewareStore.mjs.map +1 -1
- package/dist/esm/lib/structures/Route.mjs +19 -36
- package/dist/esm/lib/structures/Route.mjs.map +1 -1
- package/dist/esm/lib/structures/RouteLoaderStrategy.mjs +17 -0
- package/dist/esm/lib/structures/RouteLoaderStrategy.mjs.map +1 -0
- package/dist/esm/lib/structures/RouteStore.mjs +6 -44
- package/dist/esm/lib/structures/RouteStore.mjs.map +1 -1
- package/dist/esm/lib/structures/api/ApiRequest.mjs +28 -2
- package/dist/esm/lib/structures/api/ApiRequest.mjs.map +1 -1
- package/dist/esm/lib/structures/api/ApiResponse.mjs +8 -2
- package/dist/esm/lib/structures/api/ApiResponse.mjs.map +1 -1
- package/dist/esm/lib/structures/api/CookieStore.mjs +5 -5
- package/dist/esm/lib/structures/api/CookieStore.mjs.map +1 -1
- package/dist/esm/lib/structures/http/Auth.mjs +2 -2
- package/dist/esm/lib/structures/http/Auth.mjs.map +1 -1
- package/dist/esm/lib/structures/http/HttpCodes.mjs +2 -2
- package/dist/esm/lib/structures/http/HttpCodes.mjs.map +1 -1
- package/dist/esm/lib/structures/http/HttpMethods.mjs +40 -6
- package/dist/esm/lib/structures/http/HttpMethods.mjs.map +1 -1
- package/dist/esm/lib/structures/http/Server.mjs +17 -16
- package/dist/esm/lib/structures/http/Server.mjs.map +1 -1
- package/dist/esm/lib/structures/router/RouterBranch.mjs +179 -0
- package/dist/esm/lib/structures/router/RouterBranch.mjs.map +1 -0
- package/dist/esm/lib/structures/router/RouterNode.mjs +56 -0
- package/dist/esm/lib/structures/router/RouterNode.mjs.map +1 -0
- package/dist/esm/lib/structures/router/RouterRoot.mjs +68 -0
- package/dist/esm/lib/structures/router/RouterRoot.mjs.map +1 -0
- package/dist/esm/lib/utils/MimeTypes.mjs +2 -2
- package/dist/esm/lib/utils/MimeTypes.mjs.map +1 -1
- package/dist/esm/listeners/PluginRouteError.mjs +5 -5
- package/dist/esm/listeners/PluginRouteError.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerMiddlewareError.mjs +5 -5
- package/dist/esm/listeners/PluginServerMiddlewareError.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs +7 -7
- package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerRequest.mjs +38 -10
- package/dist/esm/listeners/PluginServerRequest.mjs.map +1 -1
- package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs +18 -0
- package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs.map +1 -0
- package/dist/esm/listeners/{PluginServerNoMatch.mjs → PluginServerRouterBranchNotFound.mjs} +5 -5
- package/dist/esm/listeners/PluginServerRouterBranchNotFound.mjs.map +1 -0
- package/dist/esm/listeners/PluginServerRouterFound.mjs +19 -0
- package/dist/esm/listeners/PluginServerRouterFound.mjs.map +1 -0
- package/dist/esm/listeners/_load.mjs +14 -12
- package/dist/esm/listeners/_load.mjs.map +1 -1
- package/dist/esm/mediaParsers/_load.mjs +2 -2
- package/dist/esm/mediaParsers/_load.mjs.map +1 -1
- package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs +2 -2
- package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs.map +1 -1
- package/dist/esm/mediaParsers/applicationJson.mjs +2 -2
- package/dist/esm/mediaParsers/applicationJson.mjs.map +1 -1
- package/dist/esm/mediaParsers/textPlain.mjs +2 -2
- package/dist/esm/mediaParsers/textPlain.mjs.map +1 -1
- package/dist/esm/middlewares/_load.mjs +2 -2
- package/dist/esm/middlewares/_load.mjs.map +1 -1
- package/dist/esm/middlewares/auth.mjs +2 -2
- package/dist/esm/middlewares/auth.mjs.map +1 -1
- package/dist/esm/middlewares/body.mjs +6 -5
- package/dist/esm/middlewares/body.mjs.map +1 -1
- package/dist/esm/middlewares/cookies.mjs +2 -2
- package/dist/esm/middlewares/cookies.mjs.map +1 -1
- package/dist/esm/middlewares/headers.mjs +20 -10
- package/dist/esm/middlewares/headers.mjs.map +1 -1
- package/dist/esm/register.mjs +2 -2
- package/dist/esm/register.mjs.map +1 -1
- package/dist/esm/routes/_load.mjs +4 -4
- package/dist/esm/routes/_load.mjs.map +1 -1
- package/dist/esm/routes/oauth/{callback.mjs → callback.post.mjs} +5 -6
- package/dist/esm/routes/oauth/callback.post.mjs.map +1 -0
- package/dist/esm/routes/oauth/{logout.mjs → logout.post.mjs} +6 -8
- package/dist/esm/routes/oauth/logout.post.mjs.map +1 -0
- package/package.json +6 -5
- package/dist/cjs/lib/utils/RouteData.cjs +0 -62
- package/dist/cjs/lib/utils/RouteData.cjs.map +0 -1
- package/dist/cjs/listeners/PluginServerMatch.cjs.map +0 -1
- package/dist/cjs/listeners/PluginServerNoMatch.cjs.map +0 -1
- package/dist/cjs/routes/oauth/callback.cjs.map +0 -1
- package/dist/cjs/routes/oauth/logout.cjs.map +0 -1
- package/dist/esm/chunk-JTFKMR4I.mjs.map +0 -1
- package/dist/esm/lib/utils/RouteData.mjs +0 -56
- package/dist/esm/lib/utils/RouteData.mjs.map +0 -1
- package/dist/esm/listeners/PluginServerMatch.mjs +0 -23
- package/dist/esm/listeners/PluginServerMatch.mjs.map +0 -1
- package/dist/esm/listeners/PluginServerNoMatch.mjs.map +0 -1
- package/dist/esm/routes/oauth/callback.mjs.map +0 -1
- package/dist/esm/routes/oauth/logout.mjs.map +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -12,16 +12,18 @@ var MediaParserStore_cjs = require('./lib/structures/MediaParserStore.cjs');
|
|
|
12
12
|
var Middleware_cjs = require('./lib/structures/Middleware.cjs');
|
|
13
13
|
var MiddlewareStore_cjs = require('./lib/structures/MiddlewareStore.cjs');
|
|
14
14
|
var Route_cjs = require('./lib/structures/Route.cjs');
|
|
15
|
+
var RouterBranch_cjs = require('./lib/structures/router/RouterBranch.cjs');
|
|
16
|
+
var RouterNode_cjs = require('./lib/structures/router/RouterNode.cjs');
|
|
17
|
+
var RouterRoot_cjs = require('./lib/structures/router/RouterRoot.cjs');
|
|
15
18
|
var RouteStore_cjs = require('./lib/structures/RouteStore.cjs');
|
|
16
19
|
var MimeTypes_cjs = require('./lib/utils/MimeTypes.cjs');
|
|
17
|
-
var RouteData_cjs = require('./lib/utils/RouteData.cjs');
|
|
18
20
|
var _load_cjs = require('./listeners/_load.cjs');
|
|
19
21
|
var _load_cjs$1 = require('./mediaParsers/_load.cjs');
|
|
20
22
|
var _load_cjs$2 = require('./middlewares/_load.cjs');
|
|
21
23
|
var _load_cjs$3 = require('./routes/_load.cjs');
|
|
22
24
|
|
|
23
25
|
// src/index.ts
|
|
24
|
-
var version = "7.0.0-next.
|
|
26
|
+
var version = "7.0.0-next.d6024cd";
|
|
25
27
|
|
|
26
28
|
Object.defineProperty(exports, "loadListeners", {
|
|
27
29
|
enumerable: true,
|
|
@@ -112,23 +114,35 @@ Object.keys(Route_cjs).forEach(function (k) {
|
|
|
112
114
|
get: function () { return Route_cjs[k]; }
|
|
113
115
|
});
|
|
114
116
|
});
|
|
115
|
-
Object.keys(
|
|
117
|
+
Object.keys(RouterBranch_cjs).forEach(function (k) {
|
|
116
118
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
117
119
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
120
|
+
get: function () { return RouterBranch_cjs[k]; }
|
|
119
121
|
});
|
|
120
122
|
});
|
|
121
|
-
Object.keys(
|
|
123
|
+
Object.keys(RouterNode_cjs).forEach(function (k) {
|
|
122
124
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
123
125
|
enumerable: true,
|
|
124
|
-
get: function () { return
|
|
126
|
+
get: function () { return RouterNode_cjs[k]; }
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
Object.keys(RouterRoot_cjs).forEach(function (k) {
|
|
130
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () { return RouterRoot_cjs[k]; }
|
|
125
133
|
});
|
|
126
134
|
});
|
|
127
|
-
Object.keys(
|
|
135
|
+
Object.keys(RouteStore_cjs).forEach(function (k) {
|
|
136
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
get: function () { return RouteStore_cjs[k]; }
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
Object.keys(MimeTypes_cjs).forEach(function (k) {
|
|
128
142
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
129
143
|
enumerable: true,
|
|
130
|
-
get: function () { return
|
|
144
|
+
get: function () { return MimeTypes_cjs[k]; }
|
|
131
145
|
});
|
|
132
146
|
});
|
|
133
|
-
//# sourceMappingURL=
|
|
147
|
+
//# sourceMappingURL=index.cjs.map
|
|
134
148
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyDO,IAAM,OAAkB,GAAA","file":"index.cjs","sourcesContent":["import type { Server, ServerOptions } from './lib/structures/http/Server';\nimport type { MediaParserStore } from './lib/structures/MediaParserStore';\nimport type { MiddlewareStore } from './lib/structures/MiddlewareStore';\nimport type { RouteStore } from './lib/structures/RouteStore';\n\nexport * from './lib/structures/api/ApiRequest';\nexport * from './lib/structures/api/ApiResponse';\nexport * from './lib/structures/api/CookieStore';\nexport * from './lib/structures/http/Auth';\nexport * from './lib/structures/http/HttpCodes';\nexport * from './lib/structures/http/HttpMethods';\nexport * from './lib/structures/http/Server';\nexport * from './lib/structures/MediaParser';\nexport * from './lib/structures/MediaParserStore';\nexport * from './lib/structures/Middleware';\nexport * from './lib/structures/MiddlewareStore';\nexport * from './lib/structures/Route';\nexport * from './lib/structures/router/RouterBranch';\nexport * from './lib/structures/router/RouterNode';\nexport * from './lib/structures/router/RouterRoot';\nexport * from './lib/structures/RouteStore';\nexport * from './lib/utils/MimeTypes';\n\nexport { loadListeners } from './listeners/_load';\nexport { loadMediaParsers } from './mediaParsers/_load';\nexport { loadMiddlewares } from './middlewares/_load';\nexport { loadRoutes } from './routes/_load';\n\ndeclare module 'discord.js' {\n\tinterface Client {\n\t\tserver: Server;\n\t}\n\n\tinterface ClientOptions {\n\t\tapi?: ServerOptions;\n\t}\n}\n\ndeclare module '@sapphire/pieces' {\n\tinterface StoreRegistryEntries {\n\t\troutes: RouteStore;\n\t\tmediaParsers: MediaParserStore;\n\t\tmiddlewares: MiddlewareStore;\n\t}\n\n\tinterface Container {\n\t\tserver: Server;\n\t}\n}\n\n/**\n * The [@sapphire/plugin-api](https://github.com/sapphiredev/plugins/blob/main/packages/api) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '7.0.0-next.d6024cd';\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
2
2
|
import { IncomingMessage, ServerResponse, Server as Server$1, ServerOptions as ServerOptions$1 } from 'node:http';
|
|
3
3
|
import { ListenOptions } from 'node:net';
|
|
4
|
-
import {
|
|
4
|
+
import { Piece, Store } from '@sapphire/pieces';
|
|
5
5
|
import { Awaitable } from '@sapphire/utilities';
|
|
6
6
|
import { Gunzip } from 'zlib';
|
|
7
|
-
import { Snowflake, OAuth2Scopes, RESTGetAPICurrentUserResult, RESTGetAPICurrentUserGuildsResult, RESTGetAPICurrentUserConnectionsResult, Collection } from 'discord.js';
|
|
8
7
|
import { Readable } from 'node:stream';
|
|
8
|
+
import { Snowflake, OAuth2Scopes, RESTGetAPICurrentUserResult, RESTGetAPICurrentUserGuildsResult, RESTGetAPICurrentUserConnectionsResult } from 'discord.js';
|
|
9
|
+
|
|
10
|
+
declare enum MimeTypes {
|
|
11
|
+
ApplicationFormUrlEncoded = "application/x-www-form-urlencoded",
|
|
12
|
+
ApplicationJson = "application/json",
|
|
13
|
+
AudioOgg = "audio/ogg",
|
|
14
|
+
AudioOpus = "audio/opus",
|
|
15
|
+
AudioWebm = "audio/webm",
|
|
16
|
+
ImageGif = "image/gif",
|
|
17
|
+
ImageJpg = "image/jpeg",
|
|
18
|
+
ImagePng = "image/png",
|
|
19
|
+
ImageWebp = "image/webp",
|
|
20
|
+
ImageXIcon = "image/x-icon",
|
|
21
|
+
TextPlain = "text/plain",
|
|
22
|
+
TextHtml = "text/html",
|
|
23
|
+
VideoMp4 = "video/mp4",
|
|
24
|
+
VideoMpeg = "video/mpeg",
|
|
25
|
+
VideoOgg = "video/ogg",
|
|
26
|
+
VideoWebm = "video/webm"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type MethodName = (typeof MethodNames)[number];
|
|
30
|
+
declare const MethodNames: readonly ["ACL", "BIND", "CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LINK", "LOCK", "M-SEARCH", "MERGE", "MKACTIVITY", "MKCALENDAR", "MKCOL", "MOVE", "NOTIFY", "OPTIONS", "PATCH", "POST", "PROPFIND", "PROPPATCH", "PURGE", "PUT", "REBIND", "REPORT", "SEARCH", "SOURCE", "SUBSCRIBE", "TRACE", "UNBIND", "UNLINK", "UNLOCK", "UNSUBSCRIBE"];
|
|
9
31
|
|
|
10
32
|
declare class Auth {
|
|
11
33
|
#private;
|
|
@@ -167,82 +189,6 @@ interface LoginDataTransformer<T extends LoginData = LoginData> {
|
|
|
167
189
|
(data: LoginData): Awaitable<T>;
|
|
168
190
|
}
|
|
169
191
|
|
|
170
|
-
declare class ApiRequest extends IncomingMessage {
|
|
171
|
-
/**
|
|
172
|
-
* The query parameters.
|
|
173
|
-
*/
|
|
174
|
-
query: Record<string, string | string[]>;
|
|
175
|
-
/**
|
|
176
|
-
* The URI parameters.
|
|
177
|
-
*/
|
|
178
|
-
params: Record<string, string>;
|
|
179
|
-
/**
|
|
180
|
-
* The body that was sent by the user.
|
|
181
|
-
*/
|
|
182
|
-
body?: unknown;
|
|
183
|
-
/**
|
|
184
|
-
* The authorization information. This field indicates three possible values:
|
|
185
|
-
*
|
|
186
|
-
* - `undefined`: The authorization middleware has not been executed yet.
|
|
187
|
-
* - `null`: The user is not authorized.
|
|
188
|
-
* - `AuthData`: The user is authorized.
|
|
189
|
-
*/
|
|
190
|
-
auth?: AuthData | null;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* @since 1.0.0
|
|
195
|
-
*/
|
|
196
|
-
declare enum TypeState {
|
|
197
|
-
/**
|
|
198
|
-
* @since 1.0.0
|
|
199
|
-
*/
|
|
200
|
-
Static = 0,
|
|
201
|
-
/**
|
|
202
|
-
* @since 1.0.0
|
|
203
|
-
*/
|
|
204
|
-
Dynamic = 1
|
|
205
|
-
}
|
|
206
|
-
type MatchData = Record<string, string> | null;
|
|
207
|
-
declare class RouteData {
|
|
208
|
-
readonly path: string;
|
|
209
|
-
private readonly static;
|
|
210
|
-
private readonly parts;
|
|
211
|
-
constructor(path: string);
|
|
212
|
-
match(split: readonly string[]): MatchData;
|
|
213
|
-
/**
|
|
214
|
-
* @since 1.0.0
|
|
215
|
-
*/
|
|
216
|
-
private static parsePart;
|
|
217
|
-
/**
|
|
218
|
-
* @since 1.0.0
|
|
219
|
-
*/
|
|
220
|
-
private static split;
|
|
221
|
-
}
|
|
222
|
-
interface ParsedPart {
|
|
223
|
-
value: string;
|
|
224
|
-
type: TypeState;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
declare enum MimeTypes {
|
|
228
|
-
ApplicationFormUrlEncoded = "application/x-www-form-urlencoded",
|
|
229
|
-
ApplicationJson = "application/json",
|
|
230
|
-
AudioOgg = "audio/ogg",
|
|
231
|
-
AudioOpus = "audio/opus",
|
|
232
|
-
AudioWebm = "audio/webm",
|
|
233
|
-
ImageGif = "image/gif",
|
|
234
|
-
ImageJpg = "image/jpeg",
|
|
235
|
-
ImagePng = "image/png",
|
|
236
|
-
ImageWebp = "image/webp",
|
|
237
|
-
ImageXIcon = "image/x-icon",
|
|
238
|
-
TextPlain = "text/plain",
|
|
239
|
-
TextHtml = "text/html",
|
|
240
|
-
VideoMp4 = "video/mp4",
|
|
241
|
-
VideoMpeg = "video/mpeg",
|
|
242
|
-
VideoOgg = "video/ogg",
|
|
243
|
-
VideoWebm = "video/webm"
|
|
244
|
-
}
|
|
245
|
-
|
|
246
192
|
declare class CookieStore extends Map<string, string> {
|
|
247
193
|
protected request: ApiRequest;
|
|
248
194
|
protected response: ApiResponse;
|
|
@@ -307,6 +253,10 @@ declare class ApiResponse<Request extends IncomingMessage = IncomingMessage> ext
|
|
|
307
253
|
* @since 1.0.0
|
|
308
254
|
*/
|
|
309
255
|
notFound(data?: unknown): void;
|
|
256
|
+
/**
|
|
257
|
+
* @since 7.0.0
|
|
258
|
+
*/
|
|
259
|
+
methodNotAllowed(data?: unknown): void;
|
|
310
260
|
/**
|
|
311
261
|
* @since 1.0.0
|
|
312
262
|
*/
|
|
@@ -350,32 +300,13 @@ declare class ApiResponse<Request extends IncomingMessage = IncomingMessage> ext
|
|
|
350
300
|
setContentType(contentType: MimeTypes): this;
|
|
351
301
|
}
|
|
352
302
|
|
|
353
|
-
type Methods = 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' | 'M-SEARCH' | 'MERGE' | 'MKACTIVITY' | 'MKCALENDAR' | 'MKCOL' | 'MOVE' | 'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' | 'PRI' | 'PROPFIND' | 'PROPPATCH' | 'PURGE' | 'PUT' | 'REBIND' | 'REPORT' | 'SEARCH' | 'SOURCE' | 'SUBSCRIBE' | 'TRACE' | 'UNBIND' | 'UNLINK' | 'UNLOCK' | 'UNSUBSCRIBE';
|
|
354
|
-
declare const methods: Record<Methods, symbol>;
|
|
355
|
-
declare const methodEntries: readonly [Methods, symbol][];
|
|
356
|
-
|
|
357
|
-
interface MethodCallback {
|
|
358
|
-
(request: ApiRequest, response: ApiResponse): unknown;
|
|
359
|
-
}
|
|
360
|
-
interface RouteMatch {
|
|
361
|
-
route: Route;
|
|
362
|
-
cb: MethodCallback;
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* @since 1.0.0
|
|
366
|
-
*/
|
|
367
|
-
declare class RouteStore extends Store<Route, 'routes'> {
|
|
368
|
-
readonly table: Collection<Methods, Collection<Route<RouteOptions>, MethodCallback>>;
|
|
369
|
-
constructor();
|
|
370
|
-
match(request: ApiRequest): RouteMatch | null;
|
|
371
|
-
private parseURL;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
303
|
interface RouteOptions extends Piece.Options {
|
|
375
304
|
/**
|
|
376
305
|
* The route the piece should represent.
|
|
377
306
|
* @since 1.0.0
|
|
378
|
-
*
|
|
307
|
+
*
|
|
308
|
+
* @defaultValue The filesystem-based path, or the name if the location is virtual.
|
|
309
|
+
*
|
|
379
310
|
* @example
|
|
380
311
|
* ```typescript
|
|
381
312
|
* '/users'
|
|
@@ -391,18 +322,61 @@ interface RouteOptions extends Piece.Options {
|
|
|
391
322
|
/**
|
|
392
323
|
* (RFC 7230 3.3.2) The maximum decimal number of octets.
|
|
393
324
|
* @since 1.0.0
|
|
394
|
-
*
|
|
325
|
+
*
|
|
326
|
+
* @defaultValue this.context.server.options.maximumBodyLength ?? 1024 * 1024 * 50
|
|
395
327
|
*/
|
|
396
328
|
maximumBodyLength?: number;
|
|
397
329
|
/**
|
|
398
330
|
* The accepted content types for this route. If set to null, the route will accept any data.
|
|
399
331
|
* @since 1.3.0
|
|
400
|
-
*
|
|
332
|
+
*
|
|
333
|
+
* @defaultValue this.context.server.options.acceptedContentMimeTypes ?? null
|
|
401
334
|
*/
|
|
402
|
-
acceptedContentMimeTypes?: MimeTypeWithoutParameters[] | null;
|
|
335
|
+
acceptedContentMimeTypes?: readonly MimeTypeWithoutParameters[] | null;
|
|
336
|
+
/**
|
|
337
|
+
* The methods this route accepts.
|
|
338
|
+
* @since 7.0.0
|
|
339
|
+
*
|
|
340
|
+
* @defaultValue The method defined in the piece name, or none if not set.
|
|
341
|
+
*/
|
|
342
|
+
methods?: readonly MethodName[];
|
|
403
343
|
}
|
|
404
344
|
/**
|
|
405
345
|
* @since 1.0.0
|
|
346
|
+
*
|
|
347
|
+
* @example A simple GET route that returns a JSON response:
|
|
348
|
+
* ```typescript
|
|
349
|
+
* // hello.get.ts
|
|
350
|
+
* import { Route } from '@sapphire/plugin-api';
|
|
351
|
+
*
|
|
352
|
+
* export class MyRoute extends Route {
|
|
353
|
+
* public run(request: Route.Request, response: Route.Response) {
|
|
354
|
+
* return response.json({ message: 'Hello, World!' });
|
|
355
|
+
* }
|
|
356
|
+
* }
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* ```bash
|
|
360
|
+
* $ curl http://localhost:4000/hello
|
|
361
|
+
* {"message":"Hello, World!"}
|
|
362
|
+
* ```
|
|
363
|
+
*
|
|
364
|
+
* @example A simple POST route that reads the body and returns it:
|
|
365
|
+
* ```typescript
|
|
366
|
+
* // echo.post.ts
|
|
367
|
+
* import { Route } from '@sapphire/plugin-api';
|
|
368
|
+
*
|
|
369
|
+
* export class MyRoute extends Route {
|
|
370
|
+
* public run(request: Route.Request, response: Route.Response) {
|
|
371
|
+
* return response.json(request.params);
|
|
372
|
+
* }
|
|
373
|
+
* }
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* ```bash
|
|
377
|
+
* $ curl -X POST -H "Content-Type: application/json" -d '{"hello":"world"}' http://localhost:4000/echo
|
|
378
|
+
* {"hello":"world"}
|
|
379
|
+
* ```
|
|
406
380
|
*/
|
|
407
381
|
declare abstract class Route<Options extends Route.Options = Route.Options> extends Piece<Options, 'routes'> {
|
|
408
382
|
/**
|
|
@@ -414,24 +388,15 @@ declare abstract class Route<Options extends Route.Options = Route.Options> exte
|
|
|
414
388
|
*/
|
|
415
389
|
readonly acceptedContentMimeTypes: readonly MimeTypeWithoutParameters[] | null;
|
|
416
390
|
/**
|
|
417
|
-
* The route
|
|
391
|
+
* The path this route represents.
|
|
418
392
|
*/
|
|
419
|
-
readonly
|
|
393
|
+
readonly path: readonly string[];
|
|
420
394
|
/**
|
|
421
395
|
* The methods this route accepts.
|
|
422
396
|
*/
|
|
423
|
-
readonly methods:
|
|
397
|
+
readonly methods: ReadonlySet<MethodName>;
|
|
424
398
|
constructor(context: Route.LoaderContext, options?: Options);
|
|
425
|
-
|
|
426
|
-
* Per-piece listener that is called when the piece is loaded into the store.
|
|
427
|
-
* Useful to set-up asynchronous initialization tasks.
|
|
428
|
-
*/
|
|
429
|
-
onLoad(): Awaitable<unknown>;
|
|
430
|
-
/**
|
|
431
|
-
* Per-piece listener that is called when the piece is unloaded from the store.
|
|
432
|
-
* Useful to set-up clean-up tasks.
|
|
433
|
-
*/
|
|
434
|
-
onUnload(): Awaitable<unknown>;
|
|
399
|
+
abstract run(request: Route.Request, response: Route.Response): Awaitable<unknown>;
|
|
435
400
|
}
|
|
436
401
|
declare namespace Route {
|
|
437
402
|
/** @deprecated Use {@linkcode LoaderContext} instead. */
|
|
@@ -444,6 +409,141 @@ declare namespace Route {
|
|
|
444
409
|
type Response = ApiResponse;
|
|
445
410
|
}
|
|
446
411
|
|
|
412
|
+
declare class RouterBranch {
|
|
413
|
+
/**
|
|
414
|
+
* The name of the branch.
|
|
415
|
+
*/
|
|
416
|
+
readonly name: string;
|
|
417
|
+
/**
|
|
418
|
+
* Whether or not the branch is dynamic.
|
|
419
|
+
*/
|
|
420
|
+
readonly dynamic: boolean;
|
|
421
|
+
/**
|
|
422
|
+
* The parent branch, if any.
|
|
423
|
+
*/
|
|
424
|
+
readonly parent: RouterBranch | null;
|
|
425
|
+
/**
|
|
426
|
+
* The node this branch is associated with.
|
|
427
|
+
*/
|
|
428
|
+
readonly node: RouterNode;
|
|
429
|
+
/**
|
|
430
|
+
* The methods supported by the branch's node or any of its children.
|
|
431
|
+
*/
|
|
432
|
+
supportedMethods: readonly string[];
|
|
433
|
+
private _staticChildren;
|
|
434
|
+
private _dynamicChild;
|
|
435
|
+
constructor(name: string, dynamic: boolean, parent: RouterBranch | null);
|
|
436
|
+
/**
|
|
437
|
+
* The path representing this branch
|
|
438
|
+
* @version 7.0.0
|
|
439
|
+
*/
|
|
440
|
+
get path(): string;
|
|
441
|
+
/**
|
|
442
|
+
* The branches the branch is associated with
|
|
443
|
+
* @version 7.0.0
|
|
444
|
+
*/
|
|
445
|
+
get children(): RouterBranch[];
|
|
446
|
+
/**
|
|
447
|
+
* Whether or not the branch is empty
|
|
448
|
+
* @version 7.0.0
|
|
449
|
+
*/
|
|
450
|
+
get empty(): boolean;
|
|
451
|
+
/**
|
|
452
|
+
* Tries to find a branch given a path
|
|
453
|
+
* @version 7.0.0
|
|
454
|
+
*
|
|
455
|
+
* @param parts The parts of a path to find a node from
|
|
456
|
+
* @returns The branch found, or null if not found
|
|
457
|
+
*/
|
|
458
|
+
find(parts: readonly string[]): RouterBranch | null;
|
|
459
|
+
/**
|
|
460
|
+
* Checks if the given name matches the branch
|
|
461
|
+
* @version 7.0.0
|
|
462
|
+
*
|
|
463
|
+
* @param name The name to match
|
|
464
|
+
* @returns Whether or not the branch matches the name
|
|
465
|
+
*/
|
|
466
|
+
matches(name: string): boolean;
|
|
467
|
+
/**
|
|
468
|
+
* Returns the string representation of the branch
|
|
469
|
+
* @version 7.0.0
|
|
470
|
+
*
|
|
471
|
+
* @returns The string representation of the branch
|
|
472
|
+
*/
|
|
473
|
+
toString(): string;
|
|
474
|
+
nodes(): IterableIterator<RouterNode>;
|
|
475
|
+
protected _add(parts: readonly string[], index: number, route: Route): RouterNode;
|
|
476
|
+
protected _remove(parts: readonly string[], index: number, route: Route): boolean;
|
|
477
|
+
protected _performAdd(parts: readonly string[], index: number, route: Route): RouterNode;
|
|
478
|
+
protected _performRemove(parts: readonly string[], index: number, route: Route): boolean;
|
|
479
|
+
protected _find(parts: readonly string[], index: number): RouterBranch | null;
|
|
480
|
+
protected _updateSupportedChildrenMethods(): void;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
declare class RouterNode {
|
|
484
|
+
#private;
|
|
485
|
+
/**
|
|
486
|
+
* The branch containing this node.
|
|
487
|
+
*/
|
|
488
|
+
readonly parent: RouterBranch;
|
|
489
|
+
constructor(parent: RouterBranch);
|
|
490
|
+
get path(): string;
|
|
491
|
+
extractParameters(parts: readonly string[]): Record<string, string>;
|
|
492
|
+
get(method: MethodName): Route | null;
|
|
493
|
+
set(method: MethodName, route: Route): this;
|
|
494
|
+
delete(method: MethodName, route: Route): boolean;
|
|
495
|
+
methods(): IterableIterator<MethodName>;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
declare class ApiRequest extends IncomingMessage {
|
|
499
|
+
/**
|
|
500
|
+
* The query parameters.
|
|
501
|
+
*/
|
|
502
|
+
query: Record<string, string | string[]>;
|
|
503
|
+
/**
|
|
504
|
+
* The URI parameters.
|
|
505
|
+
*/
|
|
506
|
+
params: Record<string, string>;
|
|
507
|
+
/**
|
|
508
|
+
* The body that was sent by the user.
|
|
509
|
+
*/
|
|
510
|
+
body?: unknown;
|
|
511
|
+
/**
|
|
512
|
+
* The authorization information. This field indicates three possible values:
|
|
513
|
+
*
|
|
514
|
+
* - `undefined`: The authorization middleware has not been executed yet.
|
|
515
|
+
* - `null`: The user is not authorized.
|
|
516
|
+
* - `AuthData`: The user is authorized.
|
|
517
|
+
*/
|
|
518
|
+
auth?: AuthData | null;
|
|
519
|
+
/**
|
|
520
|
+
* The router node that matched the request. The field indicates three
|
|
521
|
+
* possible values:
|
|
522
|
+
*
|
|
523
|
+
* - `undefined`: The router handler has not been executed yet.
|
|
524
|
+
* - `null`: The router handler has been executed, but no node matched the
|
|
525
|
+
* request.
|
|
526
|
+
* - `RouterNode`: The router handler has been executed and a node matched
|
|
527
|
+
* the request.
|
|
528
|
+
*
|
|
529
|
+
* @since 7.0.0
|
|
530
|
+
*/
|
|
531
|
+
routerNode?: RouterNode | null;
|
|
532
|
+
/**
|
|
533
|
+
* The route that matched the request. The field indicates three possible
|
|
534
|
+
* values:
|
|
535
|
+
*
|
|
536
|
+
* - `undefined`: The router handler has not been executed yet.
|
|
537
|
+
* - `null`: The router handler has been executed, but no route matched the
|
|
538
|
+
* request.
|
|
539
|
+
* - `Route`: The router handler has been executed and a route matched the
|
|
540
|
+
* request.
|
|
541
|
+
*
|
|
542
|
+
* @since 7.0.0
|
|
543
|
+
*/
|
|
544
|
+
route?: Route | null;
|
|
545
|
+
}
|
|
546
|
+
|
|
447
547
|
/**
|
|
448
548
|
* A media parser
|
|
449
549
|
* @since 1.3.0
|
|
@@ -454,7 +554,7 @@ declare abstract class MediaParser<Options extends MediaParser.Options = MediaPa
|
|
|
454
554
|
* Parses the body data from an API request.
|
|
455
555
|
* @since 1.3.0
|
|
456
556
|
*/
|
|
457
|
-
abstract run(request:
|
|
557
|
+
abstract run(request: MediaParser.Request): Awaitable<unknown>;
|
|
458
558
|
/**
|
|
459
559
|
* Checks if a route accepts the media type from this parser.
|
|
460
560
|
* @since 1.3.0
|
|
@@ -466,19 +566,19 @@ declare abstract class MediaParser<Options extends MediaParser.Options = MediaPa
|
|
|
466
566
|
* @since 1.3.0
|
|
467
567
|
* @param request The request to read the body from.
|
|
468
568
|
*/
|
|
469
|
-
protected readString(request:
|
|
569
|
+
protected readString(request: MediaParser.Request): Promise<string>;
|
|
470
570
|
/**
|
|
471
571
|
* Reads the content body as a buffer, this is useful for parsing/reading binary data.
|
|
472
572
|
* @since 1.3.0
|
|
473
573
|
* @param request The request to read the body from.
|
|
474
574
|
*/
|
|
475
|
-
protected readBuffer(request:
|
|
575
|
+
protected readBuffer(request: MediaParser.Request): Promise<Buffer>;
|
|
476
576
|
/**
|
|
477
577
|
* Reads the content stream from a request, piping the data through a transformer stream.
|
|
478
578
|
* @since 1.3.0
|
|
479
579
|
* @param request The request to read the body from.
|
|
480
580
|
*/
|
|
481
|
-
protected contentStream(request:
|
|
581
|
+
protected contentStream(request: MediaParser.Request): MediaParser.Request | Gunzip | null;
|
|
482
582
|
}
|
|
483
583
|
declare namespace MediaParser {
|
|
484
584
|
/** @deprecated Use {@linkcode LoaderContext} instead. */
|
|
@@ -487,6 +587,7 @@ declare namespace MediaParser {
|
|
|
487
587
|
type Options = Piece.Options;
|
|
488
588
|
type JSON = Piece.JSON;
|
|
489
589
|
type LocationJSON = Piece.LocationJSON;
|
|
590
|
+
type Request = ApiRequest;
|
|
490
591
|
}
|
|
491
592
|
|
|
492
593
|
/**
|
|
@@ -535,7 +636,7 @@ declare abstract class Middleware<Options extends Middleware.Options = Middlewar
|
|
|
535
636
|
* @param response The server's response.
|
|
536
637
|
* @param route The route that matched this request, will be `null` if none matched.
|
|
537
638
|
*/
|
|
538
|
-
abstract run(request:
|
|
639
|
+
abstract run(request: Middleware.Request, response: Middleware.Response): Awaitable<unknown>;
|
|
539
640
|
}
|
|
540
641
|
declare namespace Middleware {
|
|
541
642
|
/** @deprecated Use {@linkcode LoaderContext} instead. */
|
|
@@ -544,6 +645,8 @@ declare namespace Middleware {
|
|
|
544
645
|
type Options = MiddlewareOptions;
|
|
545
646
|
type JSON = Piece.JSON;
|
|
546
647
|
type LocationJSON = Piece.LocationJSON;
|
|
648
|
+
type Request = ApiRequest;
|
|
649
|
+
type Response = ApiResponse;
|
|
547
650
|
}
|
|
548
651
|
|
|
549
652
|
/**
|
|
@@ -555,26 +658,68 @@ declare class MiddlewareStore extends Store<Middleware, 'middlewares'> {
|
|
|
555
658
|
*/
|
|
556
659
|
readonly sortedMiddlewares: Middleware[];
|
|
557
660
|
constructor();
|
|
558
|
-
run(request:
|
|
661
|
+
run(request: Middleware.Request, response: Middleware.Response): Promise<void>;
|
|
559
662
|
set(key: string, value: Middleware): this;
|
|
560
663
|
delete(key: string): boolean;
|
|
561
664
|
clear(): void;
|
|
562
665
|
}
|
|
563
666
|
|
|
564
|
-
declare
|
|
667
|
+
declare class RouterRoot extends RouterBranch {
|
|
668
|
+
constructor();
|
|
669
|
+
/**
|
|
670
|
+
* Adds a route to the branch
|
|
671
|
+
*
|
|
672
|
+
* @param route The route to add
|
|
673
|
+
* @returns The node the route was added to
|
|
674
|
+
*/
|
|
675
|
+
add(route: Route): RouterNode;
|
|
676
|
+
/**
|
|
677
|
+
* Removes a route from the branch
|
|
678
|
+
*
|
|
679
|
+
* @param route The route to remove
|
|
680
|
+
* @returns Whether or not the route was removed
|
|
681
|
+
*/
|
|
682
|
+
remove(route: Route): boolean;
|
|
683
|
+
get path(): string;
|
|
684
|
+
toString(): string;
|
|
685
|
+
static normalize(path: string | null | undefined): string[];
|
|
686
|
+
static extractMethod(path: readonly string[]): MethodName | null;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* @since 1.0.0
|
|
691
|
+
*/
|
|
692
|
+
declare class RouteStore extends Store<Route, 'routes'> {
|
|
693
|
+
readonly router: RouterRoot;
|
|
694
|
+
constructor();
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
declare enum ServerEvent {
|
|
565
698
|
Error = "error",
|
|
566
699
|
Request = "request",
|
|
567
|
-
|
|
568
|
-
|
|
700
|
+
RouterBranchNotFound = "routerBranchNotFound",
|
|
701
|
+
RouterBranchMethodNotAllowed = "routerBranchMethodNotAllowed",
|
|
702
|
+
RouterFound = "routerFound",
|
|
569
703
|
RouteError = "routeError",
|
|
570
704
|
MiddlewareFailure = "middlewareFailure",
|
|
571
705
|
MiddlewareError = "middlewareError",
|
|
572
706
|
MiddlewareSuccess = "middlewareSuccess"
|
|
573
707
|
}
|
|
708
|
+
interface ServerEvents {
|
|
709
|
+
[ServerEvent.Error]: [error: Error, request: ApiRequest, response: ApiResponse];
|
|
710
|
+
[ServerEvent.Request]: [request: ApiRequest, response: ApiResponse];
|
|
711
|
+
[ServerEvent.RouterBranchNotFound]: [request: ApiRequest, response: ApiResponse];
|
|
712
|
+
[ServerEvent.RouterBranchMethodNotAllowed]: [request: ApiRequest, response: ApiResponse, node: RouterBranch];
|
|
713
|
+
[ServerEvent.RouterFound]: [request: ApiRequest, response: ApiResponse];
|
|
714
|
+
[ServerEvent.RouteError]: [error: Error, request: ApiRequest, response: ApiResponse];
|
|
715
|
+
[ServerEvent.MiddlewareFailure]: [request: ApiRequest, response: ApiResponse];
|
|
716
|
+
[ServerEvent.MiddlewareSuccess]: [request: Route.Request, response: Route.Response, route: Route];
|
|
717
|
+
[ServerEvent.MiddlewareError]: [error: Error, request: ApiRequest, response: ApiResponse];
|
|
718
|
+
}
|
|
574
719
|
/**
|
|
575
720
|
* @since 1.0.0
|
|
576
721
|
*/
|
|
577
|
-
declare class Server extends
|
|
722
|
+
declare class Server extends AsyncEventEmitter<ServerEvents> {
|
|
578
723
|
/**
|
|
579
724
|
* The routes this server holds.
|
|
580
725
|
* @since 1.0.0
|
|
@@ -707,27 +852,6 @@ interface ServerOptions {
|
|
|
707
852
|
* @since 1.0.0
|
|
708
853
|
*/
|
|
709
854
|
type AuthLessServerOptions = Omit<ServerOptions, 'auth'>;
|
|
710
|
-
/**
|
|
711
|
-
* The context sent in the error events.
|
|
712
|
-
* @since 1.2.0
|
|
713
|
-
*/
|
|
714
|
-
interface MiddlewareErrorContext {
|
|
715
|
-
/**
|
|
716
|
-
* The erroneous request.
|
|
717
|
-
* @since 1.2.0
|
|
718
|
-
*/
|
|
719
|
-
request: ApiRequest;
|
|
720
|
-
/**
|
|
721
|
-
* The server's response.
|
|
722
|
-
* @since 1.2.0
|
|
723
|
-
*/
|
|
724
|
-
response: ApiResponse;
|
|
725
|
-
/**
|
|
726
|
-
* The route match.
|
|
727
|
-
* @since 1.2.0
|
|
728
|
-
*/
|
|
729
|
-
match: RouteMatch;
|
|
730
|
-
}
|
|
731
855
|
|
|
732
856
|
declare enum HttpCodes {
|
|
733
857
|
/**
|
|
@@ -1141,4 +1265,4 @@ declare module '@sapphire/pieces' {
|
|
|
1141
1265
|
*/
|
|
1142
1266
|
declare const version: string;
|
|
1143
1267
|
|
|
1144
|
-
export { ApiRequest, ApiResponse, Auth, type AuthData, type AuthLessServerOptions, type ContentTypeParameter, type ContentTypeType, CookieStore, HttpCodes, type LoginData, type LoginDataTransformer,
|
|
1268
|
+
export { ApiRequest, ApiResponse, Auth, type AuthData, type AuthLessServerOptions, type ContentTypeParameter, type ContentTypeType, CookieStore, HttpCodes, type LoginData, type LoginDataTransformer, MediaParser, MediaParserStore, type MethodName, MethodNames, Middleware, type MiddlewareOptions, MiddlewareStore, type MimeType, type MimeTypeWithoutParameters, MimeTypes, Route, type RouteOptions, RouteStore, RouterBranch, RouterNode, RouterRoot, type SecureCookieStoreSetOptions, Server, ServerEvent, type ServerEvents, type ServerOptions, type ServerOptionsAuth, loadListeners, loadMediaParsers, loadMiddlewares, loadRoutes, version };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"Augmentations.d.cjs"}
|