@sapphire/plugin-api 7.0.3-next.c49da29 → 7.0.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ # [@sapphire/plugin-api@7.0.3](https://github.com/sapphiredev/plugins/compare/@sapphire/plugin-api@7.0.2...@sapphire/plugin-api@7.0.3) - (2024-11-06)
6
+
7
+ ## 🐛 Bug Fixes
8
+
9
+ - **cors:** Use `RouterNode` for the available ACAM values ([b77af3f](https://github.com/sapphiredev/plugins/commit/b77af3f30897a3e123dce323f02cffba30ce4735)) ([#658](https://github.com/sapphiredev/plugins/pull/658) by @kyranet)
10
+
5
11
  # [@sapphire/plugin-api@7.0.2](https://github.com/sapphiredev/plugins/compare/@sapphire/plugin-api@7.0.1...@sapphire/plugin-api@7.0.2) - (2024-11-05)
6
12
 
7
13
  ## 🐛 Bug Fixes
@@ -19,7 +19,7 @@ var _load_cjs$1 = require('./middlewares/_load.cjs');
19
19
  var _load_cjs$2 = require('./routes/_load.cjs');
20
20
 
21
21
  // src/index.ts
22
- var version = "7.0.3-next.c49da29";
22
+ var version = "7.0.3";
23
23
 
24
24
  Object.defineProperty(exports, "loadListeners", {
25
25
  enumerable: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoDO,IAAM,OAAkB,GAAA","file":"index.cjs","sourcesContent":["import type { Server, ServerOptions } from './lib/structures/http/Server';\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/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 type * from './lib/utils/MimeType';\n\nexport { loadListeners } from './listeners/_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\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.3-next.c49da29';\n"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoDO,IAAM,OAAkB,GAAA","file":"index.cjs","sourcesContent":["import type { Server, ServerOptions } from './lib/structures/http/Server';\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/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 type * from './lib/utils/MimeType';\n\nexport { loadListeners } from './listeners/_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\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.3';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/structures/router/RouterNode.ts"],"names":["Collection"],"mappings":";;;;;;;;;;;;;;AAAA,IAAA,QAAA;AAKO,IAAM,WAAA,GAAN,MAAM,WAAW,CAAA;AAAA,EAWhB,YAAY,MAAsB,EAAA;AAPzC;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAKhB;AAAA;AAAA;AAAA,IAAA,YAAA,CAAA,IAAA,EAAA,QAAA,EAAW,IAAIA,qBAA8B,EAAA,CAAA;AAG5C,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AAAA;AACf,EAEA,IAAW,IAAO,GAAA;AACjB,IAAA,OAAO,KAAK,MAAO,CAAA,IAAA;AAAA;AACpB,EAEO,kBAAkB,KAAkD,EAAA;AAC1E,IAAA,MAAM,aAAqC,EAAC;AAE5C,IAAA,IAAI,SAA8B,IAAK,CAAA,MAAA;AACvC,IAAI,IAAA,KAAA,GAAQ,MAAM,MAAS,GAAA,CAAA;AAC3B,IAAG,GAAA;AACF,MAAA,IAAI,OAAO,OAAS,EAAA,UAAA,CAAW,OAAO,IAAI,CAAA,GAAI,MAAM,KAAK,CAAA;AAEzD,MAAA,MAAA,GAAS,MAAO,CAAA,MAAA;AAChB,MAAE,EAAA,KAAA;AAAA,KACM,QAAA,MAAA;AAET,IAAO,OAAA,UAAA;AAAA;AACR,EAEO,IAAI,MAAkC,EAAA;AAC5C,IAAA,OAAO,YAAK,CAAA,IAAA,EAAA,QAAA,CAAA,CAAS,GAAI,CAAA,MAAM,CAAK,IAAA,IAAA;AAAA;AACrC,EAEO,GAAA,CAAI,QAAoB,KAAoB,EAAA;AAClD,IAAK,YAAA,CAAA,IAAA,EAAA,QAAA,CAAA,CAAS,GAAI,CAAA,MAAA,EAAQ,KAAK,CAAA;AAC/B,IAAO,OAAA,IAAA;AAAA;AACR,EAEO,MAAA,CAAO,QAAoB,KAAuB,EAAA;AACxD,IAAA,MAAM,QAAW,GAAA,YAAA,CAAA,IAAA,EAAK,QAAS,CAAA,CAAA,GAAA,CAAI,MAAM,CAAA;AACzC,IAAA,IAAI,aAAa,KAAO,EAAA;AACvB,MAAK,YAAA,CAAA,IAAA,EAAA,QAAA,CAAA,CAAS,OAAO,MAAM,CAAA;AAC3B,MAAO,OAAA,IAAA;AAAA;AAGR,IAAO,OAAA,KAAA;AAAA;AACR,EAEO,OAAwC,GAAA;AAC9C,IAAO,OAAA,YAAA,CAAA,IAAA,EAAK,UAAS,IAAK,EAAA;AAAA;AAE5B,CAAA;AA/CC,QAAA,GAAA,IAAA,OAAA,EAAA;AATuB,MAAA,CAAA,WAAA,EAAA,YAAA,CAAA;AAAjB,IAAM,UAAN,GAAA","file":"RouterNode.cjs","sourcesContent":["import { Collection } from 'discord.js';\nimport type { Route } from '../Route';\nimport type { MethodName } from '../http/HttpMethods';\nimport type { RouterBranch } from './RouterBranch';\n\nexport class RouterNode {\n\t/**\n\t * The branch containing this node.\n\t */\n\tpublic readonly parent: RouterBranch;\n\n\t/**\n\t * The methods this node supports.\n\t */\n\t#methods = new Collection<MethodName, Route>();\n\n\tpublic constructor(parent: RouterBranch) {\n\t\tthis.parent = parent;\n\t}\n\n\tpublic get path() {\n\t\treturn this.parent.path;\n\t}\n\n\tpublic extractParameters(parts: readonly string[]): Record<string, string> {\n\t\tconst parameters: Record<string, string> = {};\n\n\t\tlet branch: RouterBranch | null = this.parent;\n\t\tlet index = parts.length - 1;\n\t\tdo {\n\t\t\tif (branch.dynamic) parameters[branch.name] = parts[index];\n\n\t\t\tbranch = branch.parent;\n\t\t\t--index;\n\t\t} while (branch);\n\n\t\treturn parameters;\n\t}\n\n\tpublic get(method: MethodName): Route | null {\n\t\treturn this.#methods.get(method) ?? null;\n\t}\n\n\tpublic set(method: MethodName, route: Route): this {\n\t\tthis.#methods.set(method, route);\n\t\treturn this;\n\t}\n\n\tpublic delete(method: MethodName, route: Route): boolean {\n\t\tconst existing = this.#methods.get(method);\n\t\tif (existing === route) {\n\t\t\tthis.#methods.delete(method);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tpublic methods(): IterableIterator<MethodName> {\n\t\treturn this.#methods.keys();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../../../src/lib/structures/router/RouterNode.ts"],"names":["Collection"],"mappings":";;;;;;;;;;;;;;AAAA,IAAA,QAAA;AAKO,IAAM,WAAA,GAAN,MAAM,WAAW,CAAA;AAAA,EAWhB,YAAY,MAAsB,EAAA;AAPzC;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAKhB;AAAA;AAAA;AAAA,IAAS,YAAA,CAAA,IAAA,EAAA,QAAA,EAAW,IAAIA,qBAA8B,EAAA,CAAA;AAGrD,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AAAA;AACf,EAEA,IAAW,IAAO,GAAA;AACjB,IAAA,OAAO,KAAK,MAAO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":"RouterNode.cjs","sourcesContent":["import { Collection } from 'discord.js';\nimport type { Route } from '../Route';\nimport type { MethodName } from '../http/HttpMethods';\nimport type { RouterBranch } from './RouterBranch';\n\nexport class RouterNode {\n\t/**\n\t * The branch containing this node.\n\t */\n\tpublic readonly parent: RouterBranch;\n\n\t/**\n\t * The methods this node supports.\n\t */\n\treadonly #methods = new Collection<MethodName, Route>();\n\n\tpublic constructor(parent: RouterBranch) {\n\t\tthis.parent = parent;\n\t}\n\n\tpublic get path() {\n\t\treturn this.parent.path;\n\t}\n\n\tpublic extractParameters(parts: readonly string[]): Record<string, string> {\n\t\tconst parameters: Record<string, string> = {};\n\n\t\tlet branch: RouterBranch | null = this.parent;\n\t\tlet index = parts.length - 1;\n\t\tdo {\n\t\t\tif (branch.dynamic) parameters[branch.name] = parts[index];\n\n\t\t\tbranch = branch.parent;\n\t\t\t--index;\n\t\t} while (branch);\n\n\t\treturn parameters;\n\t}\n\n\tpublic get(method: MethodName): Route | null {\n\t\treturn this.#methods.get(method) ?? null;\n\t}\n\n\tpublic set(method: MethodName, route: Route): this {\n\t\tthis.#methods.set(method, route);\n\t\treturn this;\n\t}\n\n\tpublic delete(method: MethodName, route: Route): boolean {\n\t\tconst existing = this.#methods.get(method);\n\t\tif (existing === route) {\n\t\t\tthis.#methods.delete(method);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tpublic methods(): IterableIterator<MethodName> {\n\t\treturn this.#methods.keys();\n\t}\n}\n"]}
@@ -11,7 +11,7 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware_cjs.Middlewar
11
11
  constructor(context) {
12
12
  super(context, { position: 30 });
13
13
  __publicField(this, "production", process.env.NODE_ENV === "production");
14
- __publicField(this, "domainOverwrite", null);
14
+ __publicField(this, "domainOverwrite");
15
15
  const { server } = this.container;
16
16
  this.domainOverwrite = server.auth?.domainOverwrite ?? null;
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/cookies.ts"],"names":["Middleware","CookieStore"],"mappings":";;;;;;;;;AAGO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyBA,yBAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,EAAsB,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,YAAA,CAAA;AAChE,IAAA,aAAA,CAAA,IAAA,EAAQ,iBAAiC,EAAA,IAAA,CAAA;AAKxC,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA;AACxB,IAAK,IAAA,CAAA,eAAA,GAAkB,MAAO,CAAA,IAAA,EAAM,eAAmB,IAAA,IAAA;AAAA;AACxD,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAS,QAAA,CAAA,OAAA,GAAU,IAAIC,2BAAY,CAAA,OAAA,EAAS,UAAU,IAAK,CAAA,UAAA,EAAY,KAAK,eAAe,CAAA;AAAA;AAE7F,CAAA;AAdiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"cookies.cjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\nimport { CookieStore } from '../lib/structures/api/CookieStore';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly production: boolean = process.env.NODE_ENV === 'production';\n\tprivate domainOverwrite: string | null = null;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 30 });\n\n\t\tconst { server } = this.container;\n\t\tthis.domainOverwrite = server.auth?.domainOverwrite ?? null;\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.cookies = new CookieStore(request, response, this.production, this.domainOverwrite);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/cookies.ts"],"names":["Middleware","CookieStore"],"mappings":";;;;;;;;;AAGO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyBA,yBAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,EAAsB,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,YAAA,CAAA;AAChE,IAAiB,aAAA,CAAA,IAAA,EAAA,iBAAA,CAAA;AAKhB,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA;AACxB,IAAK,IAAA,CAAA,eAAA,GAAkB,MAAO,CAAA,IAAA,EAAM,eAAmB,IAAA,IAAA;AAAA;AACxD,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAS,QAAA,CAAA,OAAA,GAAU,IAAIC,2BAAY,CAAA,OAAA,EAAS,UAAU,IAAK,CAAA,UAAA,EAAY,KAAK,eAAe,CAAA;AAAA;AAE7F,CAAA;AAdiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"cookies.cjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\nimport { CookieStore } from '../lib/structures/api/CookieStore';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly production: boolean = process.env.NODE_ENV === 'production';\n\tprivate readonly domainOverwrite: string | null;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 30 });\n\n\t\tconst { server } = this.container;\n\t\tthis.domainOverwrite = server.auth?.domainOverwrite ?? null;\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.cookies = new CookieStore(request, response, this.production, this.domainOverwrite);\n\t}\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var utilities = require('@sapphire/utilities');
3
4
  var Middleware_cjs = require('../lib/structures/Middleware.cjs');
4
5
  var HttpCodes_cjs = require('../lib/structures/http/HttpCodes.cjs');
5
6
 
@@ -20,16 +21,14 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware_cjs.Middlewar
20
21
  response.setHeader("Access-Control-Allow-Credentials", "true");
21
22
  response.setHeader("Access-Control-Allow-Origin", this.origin);
22
23
  response.setHeader("Access-Control-Allow-Headers", "Authorization, User-Agent, Content-Type");
23
- response.setHeader("Access-Control-Allow-Methods", this.getMethods(request.route ?? null));
24
+ response.setHeader("Access-Control-Allow-Methods", this.getMethods(request.routerNode));
24
25
  this.ensurePotentialEarlyExit(request, response);
25
26
  }
26
- getMethods(route) {
27
- if (route === null) {
27
+ getMethods(routerNode) {
28
+ if (utilities.isNullish(routerNode)) {
28
29
  return this.routes.router.supportedMethods.join(", ");
29
30
  }
30
- if (route.methods.size === 0) return "";
31
- if (route.methods.size === 1) return route.methods.keys().next().value;
32
- return [...route.methods].join(", ");
31
+ return [...routerNode.methods()].join(", ");
33
32
  }
34
33
  /**
35
34
  * **RFC 7231 4.3.7.**
@@ -48,7 +47,7 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware_cjs.Middlewar
48
47
  */
49
48
  ensurePotentialEarlyExit({ method, route, routerNode }, response) {
50
49
  if (method === "OPTIONS") {
51
- if (!route || !route.methods.has("OPTIONS")) {
50
+ if (!route?.methods.has("OPTIONS")) {
52
51
  response.end();
53
52
  }
54
53
  } else if (routerNode === null) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/headers.ts"],"names":["Middleware","HttpCodes"],"mappings":";;;;;;;;;AAKO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyBA,yBAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AACjB,IAAiB,aAAA,CA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBQ,yBAAyB,EAAE,MAAA,EAAQ,KAAO,EAAA,UAAA,IAAkC,QAA+B,EAAA;AAClH,IAAA,IAAI,WAAW,SAAW,EAAA;AACzB,MAAA,IAAI,CAAC,KAAS,IAAA,CAAC,MAAM,OAAQ,CAAA,GAAA,CAAI,SAAS,CAAG,EAAA;AAC5C,QAAA,QAAA,CAAS,GAAI,EAAA;AAAA;AACd,KACD,MAAA,IAAW,eAAe,IAAM,EAAA;AAC/B,MAAA,QAAA,CAAS,MAAO,CAAAC,uBAAA,CAAU,QAAQ,CAAA,CAAE,GAAI,EAAA;AAAA,KACzC,MAAA,IAAW,UAAU,IAAM,EAAA;AAC1B,MAAA,QAAA,CAAS,MAAO,CAAAA,uBAAA,CAAU,gBAAgB,CAAA,CAAE,GAAI,EAAA;AAAA;AACjD;AAEF,CAAA;AAxDiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"headers.cjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\nimport type { Route } from '../lib/structures/Route';\nimport type { RouteStore } from '../lib/structures/RouteStore';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly origin: string;\n\tprivate readonly routes: RouteStore;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 10 });\n\t\tthis.origin = this.container.server.options.origin ?? '*';\n\t\tthis.routes = this.container.stores.get('routes');\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.setHeader('Date', new Date().toUTCString());\n\t\tresponse.setHeader('Access-Control-Allow-Credentials', 'true');\n\t\tresponse.setHeader('Access-Control-Allow-Origin', this.origin);\n\t\tresponse.setHeader('Access-Control-Allow-Headers', 'Authorization, User-Agent, Content-Type');\n\t\tresponse.setHeader('Access-Control-Allow-Methods', this.getMethods(request.route ?? null));\n\n\t\tthis.ensurePotentialEarlyExit(request, response);\n\t}\n\n\tprivate getMethods(route: Route | null) {\n\t\tif (route === null) {\n\t\t\treturn this.routes.router.supportedMethods.join(', ');\n\t\t}\n\n\t\tif (route.methods.size === 0) return '';\n\t\tif (route.methods.size === 1) return route.methods.keys().next().value;\n\t\treturn [...route.methods].join(', ');\n\t}\n\n\t/**\n\t * **RFC 7231 4.3.7.**\n\t * > This method allows a client to determine the options and/or requirements associated with a\n\t * > resource, or the capabilities of a server, without implying a resource action.\n\t *\n\t * This method ensures that the request is exited early in case required\n\t * The conditions in which an early exit is required are:\n\t * 1. If the request method is 'OPTIONS'. In this case the request is returned with status code 200\n\t * 2. If the requested route isn't matched with any existing route in the RouteStore.\n\t * In this case the request is returned with a status code 404.\n\t *\n\t * @param request The API Request coming in\n\t * @param response The API response that will go out\n\t * @param route The route being requested by the request\n\t */\n\tprivate ensurePotentialEarlyExit({ method, route, routerNode }: Middleware.Request, response: Middleware.Response) {\n\t\tif (method === 'OPTIONS') {\n\t\t\tif (!route || !route.methods.has('OPTIONS')) {\n\t\t\t\tresponse.end();\n\t\t\t}\n\t\t} else if (routerNode === null) {\n\t\t\tresponse.status(HttpCodes.NotFound).end();\n\t\t} else if (route === null) {\n\t\t\tresponse.status(HttpCodes.MethodNotAllowed).end();\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/headers.ts"],"names":["Middleware","isNullish","HttpCodes"],"mappings":";;;;;;;;;;AAMO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyBA,yBAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAIhB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,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AAA;AACd,KACD,MAAA,IAAW,eAAe,IAAM,EAAA;AAC/B,MAAA,QAAA,CAAS,MAAO,CAAAC,uBAAA,CAAU,QAAQ,CAAA,CAAE,GAAI,EAAA;AAAA,KACzC,MAAA,IAAW,UAAU,IAAM,EAAA;AAC1B,MAAA,QAAA,CAAS,MAAO,CAAAA,uBAAA,CAAU,gBAAgB,CAAA,CAAE,GAAI,EAAA;AAAA;AACjD;AAEF,CAAA;AAtDiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"headers.cjs","sourcesContent":["import { isNullish } from '@sapphire/utilities';\nimport { Middleware } from '../lib/structures/Middleware';\nimport type { RouteStore } from '../lib/structures/RouteStore';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport type { RouterNode } from '../lib/structures/router/RouterNode';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly origin: string;\n\tprivate readonly routes: RouteStore;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 10 });\n\t\tthis.origin = this.container.server.options.origin ?? '*';\n\t\tthis.routes = this.container.stores.get('routes');\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.setHeader('Date', new Date().toUTCString());\n\t\tresponse.setHeader('Access-Control-Allow-Credentials', 'true');\n\t\tresponse.setHeader('Access-Control-Allow-Origin', this.origin);\n\t\tresponse.setHeader('Access-Control-Allow-Headers', 'Authorization, User-Agent, Content-Type');\n\t\tresponse.setHeader('Access-Control-Allow-Methods', this.getMethods(request.routerNode));\n\n\t\tthis.ensurePotentialEarlyExit(request, response);\n\t}\n\n\tprivate getMethods(routerNode: RouterNode | null | undefined): string {\n\t\tif (isNullish(routerNode)) {\n\t\t\treturn this.routes.router.supportedMethods.join(', ');\n\t\t}\n\n\t\treturn [...routerNode.methods()].join(', ');\n\t}\n\n\t/**\n\t * **RFC 7231 4.3.7.**\n\t * > This method allows a client to determine the options and/or requirements associated with a\n\t * > resource, or the capabilities of a server, without implying a resource action.\n\t *\n\t * This method ensures that the request is exited early in case required\n\t * The conditions in which an early exit is required are:\n\t * 1. If the request method is 'OPTIONS'. In this case the request is returned with status code 200\n\t * 2. If the requested route isn't matched with any existing route in the RouteStore.\n\t * In this case the request is returned with a status code 404.\n\t *\n\t * @param request The API Request coming in\n\t * @param response The API response that will go out\n\t * @param route The route being requested by the request\n\t */\n\tprivate ensurePotentialEarlyExit({ method, route, routerNode }: Middleware.Request, response: Middleware.Response) {\n\t\tif (method === 'OPTIONS') {\n\t\t\tif (!route?.methods.has('OPTIONS')) {\n\t\t\t\tresponse.end();\n\t\t\t}\n\t\t} else if (routerNode === null) {\n\t\t\tresponse.status(HttpCodes.NotFound).end();\n\t\t} else if (route === null) {\n\t\t\tresponse.status(HttpCodes.MethodNotAllowed).end();\n\t\t}\n\t}\n}\n"]}
@@ -17,7 +17,7 @@ export { loadListeners } from './listeners/_load.mjs';
17
17
  export { loadMiddlewares } from './middlewares/_load.mjs';
18
18
  export { loadRoutes } from './routes/_load.mjs';
19
19
 
20
- var version = "7.0.3-next.c49da29";
20
+ var version = "7.0.3";
21
21
 
22
22
  export { version };
23
23
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAoDO,IAAM,OAAkB,GAAA","file":"index.mjs","sourcesContent":["import type { Server, ServerOptions } from './lib/structures/http/Server';\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/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 type * from './lib/utils/MimeType';\n\nexport { loadListeners } from './listeners/_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\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.3-next.c49da29';\n"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAoDO,IAAM,OAAkB,GAAA","file":"index.mjs","sourcesContent":["import type { Server, ServerOptions } from './lib/structures/http/Server';\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/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 type * from './lib/utils/MimeType';\n\nexport { loadListeners } from './listeners/_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\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.3';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/structures/router/RouterNode.ts"],"names":[],"mappings":";;;AAAA,IAAA,QAAA;AAKO,IAAM,WAAA,GAAN,MAAM,WAAW,CAAA;AAAA,EAWhB,YAAY,MAAsB,EAAA;AAPzC;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAKhB;AAAA;AAAA;AAAA,IAAA,YAAA,CAAA,IAAA,EAAA,QAAA,EAAW,IAAI,UAA8B,EAAA,CAAA;AAG5C,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AAAA;AACf,EAEA,IAAW,IAAO,GAAA;AACjB,IAAA,OAAO,KAAK,MAAO,CAAA,IAAA;AAAA;AACpB,EAEO,kBAAkB,KAAkD,EAAA;AAC1E,IAAA,MAAM,aAAqC,EAAC;AAE5C,IAAA,IAAI,SAA8B,IAAK,CAAA,MAAA;AACvC,IAAI,IAAA,KAAA,GAAQ,MAAM,MAAS,GAAA,CAAA;AAC3B,IAAG,GAAA;AACF,MAAA,IAAI,OAAO,OAAS,EAAA,UAAA,CAAW,OAAO,IAAI,CAAA,GAAI,MAAM,KAAK,CAAA;AAEzD,MAAA,MAAA,GAAS,MAAO,CAAA,MAAA;AAChB,MAAE,EAAA,KAAA;AAAA,KACM,QAAA,MAAA;AAET,IAAO,OAAA,UAAA;AAAA;AACR,EAEO,IAAI,MAAkC,EAAA;AAC5C,IAAA,OAAO,YAAK,CAAA,IAAA,EAAA,QAAA,CAAA,CAAS,GAAI,CAAA,MAAM,CAAK,IAAA,IAAA;AAAA;AACrC,EAEO,GAAA,CAAI,QAAoB,KAAoB,EAAA;AAClD,IAAK,YAAA,CAAA,IAAA,EAAA,QAAA,CAAA,CAAS,GAAI,CAAA,MAAA,EAAQ,KAAK,CAAA;AAC/B,IAAO,OAAA,IAAA;AAAA;AACR,EAEO,MAAA,CAAO,QAAoB,KAAuB,EAAA;AACxD,IAAA,MAAM,QAAW,GAAA,YAAA,CAAA,IAAA,EAAK,QAAS,CAAA,CAAA,GAAA,CAAI,MAAM,CAAA;AACzC,IAAA,IAAI,aAAa,KAAO,EAAA;AACvB,MAAK,YAAA,CAAA,IAAA,EAAA,QAAA,CAAA,CAAS,OAAO,MAAM,CAAA;AAC3B,MAAO,OAAA,IAAA;AAAA;AAGR,IAAO,OAAA,KAAA;AAAA;AACR,EAEO,OAAwC,GAAA;AAC9C,IAAO,OAAA,YAAA,CAAA,IAAA,EAAK,UAAS,IAAK,EAAA;AAAA;AAE5B,CAAA;AA/CC,QAAA,GAAA,IAAA,OAAA,EAAA;AATuB,MAAA,CAAA,WAAA,EAAA,YAAA,CAAA;AAAjB,IAAM,UAAN,GAAA","file":"RouterNode.mjs","sourcesContent":["import { Collection } from 'discord.js';\nimport type { Route } from '../Route';\nimport type { MethodName } from '../http/HttpMethods';\nimport type { RouterBranch } from './RouterBranch';\n\nexport class RouterNode {\n\t/**\n\t * The branch containing this node.\n\t */\n\tpublic readonly parent: RouterBranch;\n\n\t/**\n\t * The methods this node supports.\n\t */\n\t#methods = new Collection<MethodName, Route>();\n\n\tpublic constructor(parent: RouterBranch) {\n\t\tthis.parent = parent;\n\t}\n\n\tpublic get path() {\n\t\treturn this.parent.path;\n\t}\n\n\tpublic extractParameters(parts: readonly string[]): Record<string, string> {\n\t\tconst parameters: Record<string, string> = {};\n\n\t\tlet branch: RouterBranch | null = this.parent;\n\t\tlet index = parts.length - 1;\n\t\tdo {\n\t\t\tif (branch.dynamic) parameters[branch.name] = parts[index];\n\n\t\t\tbranch = branch.parent;\n\t\t\t--index;\n\t\t} while (branch);\n\n\t\treturn parameters;\n\t}\n\n\tpublic get(method: MethodName): Route | null {\n\t\treturn this.#methods.get(method) ?? null;\n\t}\n\n\tpublic set(method: MethodName, route: Route): this {\n\t\tthis.#methods.set(method, route);\n\t\treturn this;\n\t}\n\n\tpublic delete(method: MethodName, route: Route): boolean {\n\t\tconst existing = this.#methods.get(method);\n\t\tif (existing === route) {\n\t\t\tthis.#methods.delete(method);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tpublic methods(): IterableIterator<MethodName> {\n\t\treturn this.#methods.keys();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../../../src/lib/structures/router/RouterNode.ts"],"names":[],"mappings":";;;AAAA,IAAA,QAAA;AAKO,IAAM,WAAA,GAAN,MAAM,WAAW,CAAA;AAAA,EAWhB,YAAY,MAAsB,EAAA;AAPzC;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAKhB;AAAA;AAAA;AAAA,IAAS,YAAA,CAAA,IAAA,EAAA,QAAA,EAAW,IAAI,UAA8B,EAAA,CAAA;AAGrD,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AAAA;AACf,EAEA,IAAW,IAAO,GAAA;AACjB,IAAA,OAAO,KAAK,MAAO,CAAA,IAAA;AAAA;AACpB,EAEO,kBAAkB,KAAkD,EAAA;AAC1E,IAAA,MAAM,aAAqC,EAAC;AAE5C,IAAA,IAAI,SAA8B,IAAK,CAAA,MAAA;AACvC,IAAI,IAAA,KAAA,GAAQ,MAAM,MAAS,GAAA,CAAA;AAC3B,IAAG,GAAA;AACF,MAAA,IAAI,OAAO,OAAS,EAAA,UAAA,CAAW,OAAO,IAAI,CAAA,GAAI,MAAM,KAAK,CAAA;AAEzD,MAAA,MAAA,GAAS,MAAO,CAAA,MAAA;AAChB,MAAE,EAAA,KAAA;AAAA,KACM,QAAA,MAAA;AAET,IAAO,OAAA,UAAA;AAAA;AACR,EAEO,IAAI,MAAkC,EAAA;AAC5C,IAAA,OAAO,YAAK,CAAA,IAAA,EAAA,QAAA,CAAA,CAAS,GAAI,CAAA,MAAM,CAAK,IAAA,IAAA;AAAA;AACrC,EAEO,GAAA,CAAI,QAAoB,KAAoB,EAAA;AAClD,IAAK,YAAA,CAAA,IAAA,EAAA,QAAA,CAAA,CAAS,GAAI,CAAA,MAAA,EAAQ,KAAK,CAAA;AAC/B,IAAO,OAAA,IAAA;AAAA;AACR,EAEO,MAAA,CAAO,QAAoB,KAAuB,EAAA;AACxD,IAAA,MAAM,QAAW,GAAA,YAAA,CAAA,IAAA,EAAK,QAAS,CAAA,CAAA,GAAA,CAAI,MAAM,CAAA;AACzC,IAAA,IAAI,aAAa,KAAO,EAAA;AACvB,MAAK,YAAA,CAAA,IAAA,EAAA,QAAA,CAAA,CAAS,OAAO,MAAM,CAAA;AAC3B,MAAO,OAAA,IAAA;AAAA;AAGR,IAAO,OAAA,KAAA;AAAA;AACR,EAEO,OAAwC,GAAA;AAC9C,IAAO,OAAA,YAAA,CAAA,IAAA,EAAK,UAAS,IAAK,EAAA;AAAA;AAE5B,CAAA;AA/CU,QAAA,GAAA,IAAA,OAAA,EAAA;AATc,MAAA,CAAA,WAAA,EAAA,YAAA,CAAA;AAAjB,IAAM,UAAN,GAAA","file":"RouterNode.mjs","sourcesContent":["import { Collection } from 'discord.js';\nimport type { Route } from '../Route';\nimport type { MethodName } from '../http/HttpMethods';\nimport type { RouterBranch } from './RouterBranch';\n\nexport class RouterNode {\n\t/**\n\t * The branch containing this node.\n\t */\n\tpublic readonly parent: RouterBranch;\n\n\t/**\n\t * The methods this node supports.\n\t */\n\treadonly #methods = new Collection<MethodName, Route>();\n\n\tpublic constructor(parent: RouterBranch) {\n\t\tthis.parent = parent;\n\t}\n\n\tpublic get path() {\n\t\treturn this.parent.path;\n\t}\n\n\tpublic extractParameters(parts: readonly string[]): Record<string, string> {\n\t\tconst parameters: Record<string, string> = {};\n\n\t\tlet branch: RouterBranch | null = this.parent;\n\t\tlet index = parts.length - 1;\n\t\tdo {\n\t\t\tif (branch.dynamic) parameters[branch.name] = parts[index];\n\n\t\t\tbranch = branch.parent;\n\t\t\t--index;\n\t\t} while (branch);\n\n\t\treturn parameters;\n\t}\n\n\tpublic get(method: MethodName): Route | null {\n\t\treturn this.#methods.get(method) ?? null;\n\t}\n\n\tpublic set(method: MethodName, route: Route): this {\n\t\tthis.#methods.set(method, route);\n\t\treturn this;\n\t}\n\n\tpublic delete(method: MethodName, route: Route): boolean {\n\t\tconst existing = this.#methods.get(method);\n\t\tif (existing === route) {\n\t\t\tthis.#methods.delete(method);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tpublic methods(): IterableIterator<MethodName> {\n\t\treturn this.#methods.keys();\n\t}\n}\n"]}
@@ -6,7 +6,7 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware {
6
6
  constructor(context) {
7
7
  super(context, { position: 30 });
8
8
  __publicField(this, "production", process.env.NODE_ENV === "production");
9
- __publicField(this, "domainOverwrite", null);
9
+ __publicField(this, "domainOverwrite");
10
10
  const { server } = this.container;
11
11
  this.domainOverwrite = server.auth?.domainOverwrite ?? null;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/cookies.ts"],"names":[],"mappings":";;;;AAGO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,EAAsB,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,YAAA,CAAA;AAChE,IAAA,aAAA,CAAA,IAAA,EAAQ,iBAAiC,EAAA,IAAA,CAAA;AAKxC,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA;AACxB,IAAK,IAAA,CAAA,eAAA,GAAkB,MAAO,CAAA,IAAA,EAAM,eAAmB,IAAA,IAAA;AAAA;AACxD,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAS,QAAA,CAAA,OAAA,GAAU,IAAI,WAAY,CAAA,OAAA,EAAS,UAAU,IAAK,CAAA,UAAA,EAAY,KAAK,eAAe,CAAA;AAAA;AAE7F,CAAA;AAdiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"cookies.mjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\nimport { CookieStore } from '../lib/structures/api/CookieStore';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly production: boolean = process.env.NODE_ENV === 'production';\n\tprivate domainOverwrite: string | null = null;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 30 });\n\n\t\tconst { server } = this.container;\n\t\tthis.domainOverwrite = server.auth?.domainOverwrite ?? null;\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.cookies = new CookieStore(request, response, this.production, this.domainOverwrite);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/cookies.ts"],"names":[],"mappings":";;;;AAGO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,EAAsB,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,YAAA,CAAA;AAChE,IAAiB,aAAA,CAAA,IAAA,EAAA,iBAAA,CAAA;AAKhB,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA;AACxB,IAAK,IAAA,CAAA,eAAA,GAAkB,MAAO,CAAA,IAAA,EAAM,eAAmB,IAAA,IAAA;AAAA;AACxD,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAS,QAAA,CAAA,OAAA,GAAU,IAAI,WAAY,CAAA,OAAA,EAAS,UAAU,IAAK,CAAA,UAAA,EAAY,KAAK,eAAe,CAAA;AAAA;AAE7F,CAAA;AAdiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"cookies.mjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\nimport { CookieStore } from '../lib/structures/api/CookieStore';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly production: boolean = process.env.NODE_ENV === 'production';\n\tprivate readonly domainOverwrite: string | null;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 30 });\n\n\t\tconst { server } = this.container;\n\t\tthis.domainOverwrite = server.auth?.domainOverwrite ?? null;\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.cookies = new CookieStore(request, response, this.production, this.domainOverwrite);\n\t}\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { __name, __publicField } from '../chunk-S573YWRP.mjs';
2
+ import { isNullish } from '@sapphire/utilities';
2
3
  import { Middleware } from '../lib/structures/Middleware.mjs';
3
4
  import { HttpCodes } from '../lib/structures/http/HttpCodes.mjs';
4
5
 
@@ -15,16 +16,14 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware {
15
16
  response.setHeader("Access-Control-Allow-Credentials", "true");
16
17
  response.setHeader("Access-Control-Allow-Origin", this.origin);
17
18
  response.setHeader("Access-Control-Allow-Headers", "Authorization, User-Agent, Content-Type");
18
- response.setHeader("Access-Control-Allow-Methods", this.getMethods(request.route ?? null));
19
+ response.setHeader("Access-Control-Allow-Methods", this.getMethods(request.routerNode));
19
20
  this.ensurePotentialEarlyExit(request, response);
20
21
  }
21
- getMethods(route) {
22
- if (route === null) {
22
+ getMethods(routerNode) {
23
+ if (isNullish(routerNode)) {
23
24
  return this.routes.router.supportedMethods.join(", ");
24
25
  }
25
- if (route.methods.size === 0) return "";
26
- if (route.methods.size === 1) return route.methods.keys().next().value;
27
- return [...route.methods].join(", ");
26
+ return [...routerNode.methods()].join(", ");
28
27
  }
29
28
  /**
30
29
  * **RFC 7231 4.3.7.**
@@ -43,7 +42,7 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware {
43
42
  */
44
43
  ensurePotentialEarlyExit({ method, route, routerNode }, response) {
45
44
  if (method === "OPTIONS") {
46
- if (!route || !route.methods.has("OPTIONS")) {
45
+ if (!route?.methods.has("OPTIONS")) {
47
46
  response.end();
48
47
  }
49
48
  } else if (routerNode === null) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/headers.ts"],"names":[],"mappings":";;;;AAKO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAIhB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,QAAQ,MAAU,IAAA,GAAA;AACtD,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,IAAI,QAAQ,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,CAAA,GAAA,CAAI,SAAS,CAAG,EAAA;AAC5C,QAAA,QAAA,CAAS,GAAI,EAAA;AAAA;AACd,KACD,MAAA,IAAW,eAAe,IAAM,EAAA;AAC/B,MAAA,QAAA,CAAS,MAAO,CAAA,SAAA,CAAU,QAAQ,CAAA,CAAE,GAAI,EAAA;AAAA,KACzC,MAAA,IAAW,UAAU,IAAM,EAAA;AAC1B,MAAA,QAAA,CAAS,MAAO,CAAA,SAAA,CAAU,gBAAgB,CAAA,CAAE,GAAI,EAAA;AAAA;AACjD;AAEF,CAAA;AAxDiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"headers.mjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\nimport type { Route } from '../lib/structures/Route';\nimport type { RouteStore } from '../lib/structures/RouteStore';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly origin: string;\n\tprivate readonly routes: RouteStore;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 10 });\n\t\tthis.origin = this.container.server.options.origin ?? '*';\n\t\tthis.routes = this.container.stores.get('routes');\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.setHeader('Date', new Date().toUTCString());\n\t\tresponse.setHeader('Access-Control-Allow-Credentials', 'true');\n\t\tresponse.setHeader('Access-Control-Allow-Origin', this.origin);\n\t\tresponse.setHeader('Access-Control-Allow-Headers', 'Authorization, User-Agent, Content-Type');\n\t\tresponse.setHeader('Access-Control-Allow-Methods', this.getMethods(request.route ?? null));\n\n\t\tthis.ensurePotentialEarlyExit(request, response);\n\t}\n\n\tprivate getMethods(route: Route | null) {\n\t\tif (route === null) {\n\t\t\treturn this.routes.router.supportedMethods.join(', ');\n\t\t}\n\n\t\tif (route.methods.size === 0) return '';\n\t\tif (route.methods.size === 1) return route.methods.keys().next().value;\n\t\treturn [...route.methods].join(', ');\n\t}\n\n\t/**\n\t * **RFC 7231 4.3.7.**\n\t * > This method allows a client to determine the options and/or requirements associated with a\n\t * > resource, or the capabilities of a server, without implying a resource action.\n\t *\n\t * This method ensures that the request is exited early in case required\n\t * The conditions in which an early exit is required are:\n\t * 1. If the request method is 'OPTIONS'. In this case the request is returned with status code 200\n\t * 2. If the requested route isn't matched with any existing route in the RouteStore.\n\t * In this case the request is returned with a status code 404.\n\t *\n\t * @param request The API Request coming in\n\t * @param response The API response that will go out\n\t * @param route The route being requested by the request\n\t */\n\tprivate ensurePotentialEarlyExit({ method, route, routerNode }: Middleware.Request, response: Middleware.Response) {\n\t\tif (method === 'OPTIONS') {\n\t\t\tif (!route || !route.methods.has('OPTIONS')) {\n\t\t\t\tresponse.end();\n\t\t\t}\n\t\t} else if (routerNode === null) {\n\t\t\tresponse.status(HttpCodes.NotFound).end();\n\t\t} else if (route === null) {\n\t\t\tresponse.status(HttpCodes.MethodNotAllowed).end();\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/headers.ts"],"names":[],"mappings":";;;;;AAMO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAIhB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,QAAQ,MAAU,IAAA,GAAA;AACtD,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,IAAI,QAAQ,CAAA;AAAA;AACjD,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAA,QAAA,CAAS,UAAU,MAAQ,EAAA,iB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;AAAA;AACjD;AAEF,CAAA;AAtDiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"headers.mjs","sourcesContent":["import { isNullish } from '@sapphire/utilities';\nimport { Middleware } from '../lib/structures/Middleware';\nimport type { RouteStore } from '../lib/structures/RouteStore';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport type { RouterNode } from '../lib/structures/router/RouterNode';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly origin: string;\n\tprivate readonly routes: RouteStore;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 10 });\n\t\tthis.origin = this.container.server.options.origin ?? '*';\n\t\tthis.routes = this.container.stores.get('routes');\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tresponse.setHeader('Date', new Date().toUTCString());\n\t\tresponse.setHeader('Access-Control-Allow-Credentials', 'true');\n\t\tresponse.setHeader('Access-Control-Allow-Origin', this.origin);\n\t\tresponse.setHeader('Access-Control-Allow-Headers', 'Authorization, User-Agent, Content-Type');\n\t\tresponse.setHeader('Access-Control-Allow-Methods', this.getMethods(request.routerNode));\n\n\t\tthis.ensurePotentialEarlyExit(request, response);\n\t}\n\n\tprivate getMethods(routerNode: RouterNode | null | undefined): string {\n\t\tif (isNullish(routerNode)) {\n\t\t\treturn this.routes.router.supportedMethods.join(', ');\n\t\t}\n\n\t\treturn [...routerNode.methods()].join(', ');\n\t}\n\n\t/**\n\t * **RFC 7231 4.3.7.**\n\t * > This method allows a client to determine the options and/or requirements associated with a\n\t * > resource, or the capabilities of a server, without implying a resource action.\n\t *\n\t * This method ensures that the request is exited early in case required\n\t * The conditions in which an early exit is required are:\n\t * 1. If the request method is 'OPTIONS'. In this case the request is returned with status code 200\n\t * 2. If the requested route isn't matched with any existing route in the RouteStore.\n\t * In this case the request is returned with a status code 404.\n\t *\n\t * @param request The API Request coming in\n\t * @param response The API response that will go out\n\t * @param route The route being requested by the request\n\t */\n\tprivate ensurePotentialEarlyExit({ method, route, routerNode }: Middleware.Request, response: Middleware.Response) {\n\t\tif (method === 'OPTIONS') {\n\t\t\tif (!route?.methods.has('OPTIONS')) {\n\t\t\t\tresponse.end();\n\t\t\t}\n\t\t} else if (routerNode === null) {\n\t\t\tresponse.status(HttpCodes.NotFound).end();\n\t\t} else if (route === null) {\n\t\t\tresponse.status(HttpCodes.MethodNotAllowed).end();\n\t\t}\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/plugin-api",
3
- "version": "7.0.3-next.c49da29",
3
+ "version": "7.0.3",
4
4
  "description": "Plugin for @sapphire/framework to expose a REST API",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",