@sapphire/plugin-api 7.0.0-next.fc8e636 → 7.0.0

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.
Files changed (193) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +0 -1
  3. package/dist/cjs/index.cjs +6 -32
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +91 -109
  6. package/dist/cjs/lib/structures/Augmentations.d.cjs +1 -1
  7. package/dist/cjs/lib/structures/Augmentations.d.cjs.map +1 -1
  8. package/dist/cjs/lib/structures/Middleware.cjs +2 -2
  9. package/dist/cjs/lib/structures/Middleware.cjs.map +1 -1
  10. package/dist/cjs/lib/structures/MiddlewareStore.cjs +2 -2
  11. package/dist/cjs/lib/structures/MiddlewareStore.cjs.map +1 -1
  12. package/dist/cjs/lib/structures/Route.cjs +5 -10
  13. package/dist/cjs/lib/structures/Route.cjs.map +1 -1
  14. package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs +1 -1
  15. package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs.map +1 -1
  16. package/dist/cjs/lib/structures/RouteStore.cjs +2 -2
  17. package/dist/cjs/lib/structures/RouteStore.cjs.map +1 -1
  18. package/dist/cjs/lib/structures/api/ApiRequest.cjs +129 -5
  19. package/dist/cjs/lib/structures/api/ApiRequest.cjs.map +1 -1
  20. package/dist/cjs/lib/structures/api/ApiResponse.cjs +6 -7
  21. package/dist/cjs/lib/structures/api/ApiResponse.cjs.map +1 -1
  22. package/dist/cjs/lib/structures/api/CookieStore.cjs +1 -1
  23. package/dist/cjs/lib/structures/api/CookieStore.cjs.map +1 -1
  24. package/dist/cjs/lib/structures/http/Auth.cjs +2 -2
  25. package/dist/cjs/lib/structures/http/Auth.cjs.map +1 -1
  26. package/dist/cjs/lib/structures/http/HttpCodes.cjs +1 -1
  27. package/dist/cjs/lib/structures/http/HttpCodes.cjs.map +1 -1
  28. package/dist/cjs/lib/structures/http/HttpMethods.cjs +2 -1
  29. package/dist/cjs/lib/structures/http/HttpMethods.cjs.map +1 -1
  30. package/dist/cjs/lib/structures/http/Server.cjs +2 -9
  31. package/dist/cjs/lib/structures/http/Server.cjs.map +1 -1
  32. package/dist/cjs/lib/structures/router/RouterBranch.cjs +1 -1
  33. package/dist/cjs/lib/structures/router/RouterBranch.cjs.map +1 -1
  34. package/dist/cjs/lib/structures/router/RouterNode.cjs +2 -2
  35. package/dist/cjs/lib/structures/router/RouterNode.cjs.map +1 -1
  36. package/dist/cjs/lib/structures/router/RouterRoot.cjs +12 -2
  37. package/dist/cjs/lib/structures/router/RouterRoot.cjs.map +1 -1
  38. package/dist/cjs/lib/utils/MimeType.cjs +4 -0
  39. package/dist/cjs/lib/utils/MimeType.cjs.map +1 -0
  40. package/dist/cjs/lib/utils/_body/RequestHeadersProxy.cjs +100 -0
  41. package/dist/cjs/lib/utils/_body/RequestHeadersProxy.cjs.map +1 -0
  42. package/dist/cjs/lib/utils/_body/RequestProxy.cjs +124 -0
  43. package/dist/cjs/lib/utils/_body/RequestProxy.cjs.map +1 -0
  44. package/dist/cjs/lib/utils/_body/RequestURLProxy.cjs +179 -0
  45. package/dist/cjs/lib/utils/_body/RequestURLProxy.cjs.map +1 -0
  46. package/dist/cjs/lib/utils/constants.cjs +8 -0
  47. package/dist/cjs/lib/utils/constants.cjs.map +1 -0
  48. package/dist/cjs/listeners/PluginRouteError.cjs +1 -1
  49. package/dist/cjs/listeners/PluginRouteError.cjs.map +1 -1
  50. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs +1 -1
  51. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs.map +1 -1
  52. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs +1 -1
  53. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs.map +1 -1
  54. package/dist/cjs/listeners/PluginServerRequest.cjs +2 -2
  55. package/dist/cjs/listeners/PluginServerRequest.cjs.map +1 -1
  56. package/dist/cjs/listeners/PluginServerRouterBranchMethodNotAllowed.cjs +1 -1
  57. package/dist/cjs/listeners/PluginServerRouterBranchMethodNotAllowed.cjs.map +1 -1
  58. package/dist/cjs/listeners/PluginServerRouterBranchNotFound.cjs +1 -1
  59. package/dist/cjs/listeners/PluginServerRouterBranchNotFound.cjs.map +1 -1
  60. package/dist/cjs/listeners/PluginServerRouterFound.cjs +3 -2
  61. package/dist/cjs/listeners/PluginServerRouterFound.cjs.map +1 -1
  62. package/dist/cjs/listeners/_load.cjs +1 -1
  63. package/dist/cjs/listeners/_load.cjs.map +1 -1
  64. package/dist/cjs/middlewares/_load.cjs +1 -1
  65. package/dist/cjs/middlewares/_load.cjs.map +1 -1
  66. package/dist/cjs/middlewares/auth.cjs +2 -2
  67. package/dist/cjs/middlewares/auth.cjs.map +1 -1
  68. package/dist/cjs/middlewares/body.cjs +2 -18
  69. package/dist/cjs/middlewares/body.cjs.map +1 -1
  70. package/dist/cjs/middlewares/cookies.cjs +1 -1
  71. package/dist/cjs/middlewares/cookies.cjs.map +1 -1
  72. package/dist/cjs/middlewares/headers.cjs +1 -1
  73. package/dist/cjs/middlewares/headers.cjs.map +1 -1
  74. package/dist/cjs/register.cjs +3 -4
  75. package/dist/cjs/register.cjs.map +1 -1
  76. package/dist/cjs/register.d.cts +0 -1
  77. package/dist/cjs/routes/_load.cjs +1 -1
  78. package/dist/cjs/routes/_load.cjs.map +1 -1
  79. package/dist/cjs/routes/oauth/callback.post.cjs +3 -3
  80. package/dist/cjs/routes/oauth/callback.post.cjs.map +1 -1
  81. package/dist/cjs/routes/oauth/logout.post.cjs +1 -1
  82. package/dist/cjs/routes/oauth/logout.post.cjs.map +1 -1
  83. package/dist/esm/chunk-S573YWRP.mjs +1 -1
  84. package/dist/esm/chunk-S573YWRP.mjs.map +1 -1
  85. package/dist/esm/index.d.mts +91 -109
  86. package/dist/esm/index.mjs +2 -6
  87. package/dist/esm/index.mjs.map +1 -1
  88. package/dist/esm/lib/structures/Augmentations.d.mjs +1 -1
  89. package/dist/esm/lib/structures/Augmentations.d.mjs.map +1 -1
  90. package/dist/esm/lib/structures/Middleware.mjs +1 -1
  91. package/dist/esm/lib/structures/Middleware.mjs.map +1 -1
  92. package/dist/esm/lib/structures/MiddlewareStore.mjs +1 -1
  93. package/dist/esm/lib/structures/MiddlewareStore.mjs.map +1 -1
  94. package/dist/esm/lib/structures/Route.mjs +5 -10
  95. package/dist/esm/lib/structures/Route.mjs.map +1 -1
  96. package/dist/esm/lib/structures/RouteLoaderStrategy.mjs +1 -1
  97. package/dist/esm/lib/structures/RouteLoaderStrategy.mjs.map +1 -1
  98. package/dist/esm/lib/structures/RouteStore.mjs +1 -1
  99. package/dist/esm/lib/structures/RouteStore.mjs.map +1 -1
  100. package/dist/esm/lib/structures/api/ApiRequest.mjs +123 -6
  101. package/dist/esm/lib/structures/api/ApiRequest.mjs.map +1 -1
  102. package/dist/esm/lib/structures/api/ApiResponse.mjs +5 -6
  103. package/dist/esm/lib/structures/api/ApiResponse.mjs.map +1 -1
  104. package/dist/esm/lib/structures/api/CookieStore.mjs +1 -1
  105. package/dist/esm/lib/structures/api/CookieStore.mjs.map +1 -1
  106. package/dist/esm/lib/structures/http/Auth.mjs +1 -1
  107. package/dist/esm/lib/structures/http/Auth.mjs.map +1 -1
  108. package/dist/esm/lib/structures/http/HttpCodes.mjs +1 -1
  109. package/dist/esm/lib/structures/http/HttpCodes.mjs.map +1 -1
  110. package/dist/esm/lib/structures/http/HttpMethods.mjs +2 -1
  111. package/dist/esm/lib/structures/http/HttpMethods.mjs.map +1 -1
  112. package/dist/esm/lib/structures/http/Server.mjs +2 -9
  113. package/dist/esm/lib/structures/http/Server.mjs.map +1 -1
  114. package/dist/esm/lib/structures/router/RouterBranch.mjs +1 -1
  115. package/dist/esm/lib/structures/router/RouterBranch.mjs.map +1 -1
  116. package/dist/esm/lib/structures/router/RouterNode.mjs +1 -1
  117. package/dist/esm/lib/structures/router/RouterNode.mjs.map +1 -1
  118. package/dist/esm/lib/structures/router/RouterRoot.mjs +12 -2
  119. package/dist/esm/lib/structures/router/RouterRoot.mjs.map +1 -1
  120. package/dist/esm/lib/utils/MimeType.mjs +3 -0
  121. package/dist/esm/lib/utils/MimeType.mjs.map +1 -0
  122. package/dist/esm/lib/utils/_body/RequestHeadersProxy.mjs +95 -0
  123. package/dist/esm/lib/utils/_body/RequestHeadersProxy.mjs.map +1 -0
  124. package/dist/esm/lib/utils/_body/RequestProxy.mjs +112 -0
  125. package/dist/esm/lib/utils/_body/RequestProxy.mjs.map +1 -0
  126. package/dist/esm/lib/utils/_body/RequestURLProxy.mjs +167 -0
  127. package/dist/esm/lib/utils/_body/RequestURLProxy.mjs.map +1 -0
  128. package/dist/esm/lib/utils/constants.mjs +8 -0
  129. package/dist/esm/lib/utils/constants.mjs.map +1 -0
  130. package/dist/esm/listeners/PluginRouteError.mjs +1 -1
  131. package/dist/esm/listeners/PluginRouteError.mjs.map +1 -1
  132. package/dist/esm/listeners/PluginServerMiddlewareError.mjs +1 -1
  133. package/dist/esm/listeners/PluginServerMiddlewareError.mjs.map +1 -1
  134. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs +1 -1
  135. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs.map +1 -1
  136. package/dist/esm/listeners/PluginServerRequest.mjs +2 -2
  137. package/dist/esm/listeners/PluginServerRequest.mjs.map +1 -1
  138. package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs +1 -1
  139. package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs.map +1 -1
  140. package/dist/esm/listeners/PluginServerRouterBranchNotFound.mjs +1 -1
  141. package/dist/esm/listeners/PluginServerRouterBranchNotFound.mjs.map +1 -1
  142. package/dist/esm/listeners/PluginServerRouterFound.mjs +3 -2
  143. package/dist/esm/listeners/PluginServerRouterFound.mjs.map +1 -1
  144. package/dist/esm/listeners/_load.mjs +1 -1
  145. package/dist/esm/listeners/_load.mjs.map +1 -1
  146. package/dist/esm/middlewares/_load.mjs +1 -1
  147. package/dist/esm/middlewares/_load.mjs.map +1 -1
  148. package/dist/esm/middlewares/auth.mjs +1 -1
  149. package/dist/esm/middlewares/auth.mjs.map +1 -1
  150. package/dist/esm/middlewares/body.mjs +3 -17
  151. package/dist/esm/middlewares/body.mjs.map +1 -1
  152. package/dist/esm/middlewares/cookies.mjs +1 -1
  153. package/dist/esm/middlewares/cookies.mjs.map +1 -1
  154. package/dist/esm/middlewares/headers.mjs +1 -1
  155. package/dist/esm/middlewares/headers.mjs.map +1 -1
  156. package/dist/esm/register.d.mts +0 -1
  157. package/dist/esm/register.mjs +3 -4
  158. package/dist/esm/register.mjs.map +1 -1
  159. package/dist/esm/routes/_load.mjs +1 -1
  160. package/dist/esm/routes/_load.mjs.map +1 -1
  161. package/dist/esm/routes/oauth/callback.post.mjs +2 -2
  162. package/dist/esm/routes/oauth/callback.post.mjs.map +1 -1
  163. package/dist/esm/routes/oauth/logout.post.mjs +1 -1
  164. package/dist/esm/routes/oauth/logout.post.mjs.map +1 -1
  165. package/package.json +14 -12
  166. package/dist/cjs/lib/structures/MediaParser.cjs +0 -79
  167. package/dist/cjs/lib/structures/MediaParser.cjs.map +0 -1
  168. package/dist/cjs/lib/structures/MediaParserStore.cjs +0 -27
  169. package/dist/cjs/lib/structures/MediaParserStore.cjs.map +0 -1
  170. package/dist/cjs/lib/utils/MimeTypes.cjs +0 -26
  171. package/dist/cjs/lib/utils/MimeTypes.cjs.map +0 -1
  172. package/dist/cjs/mediaParsers/_load.cjs +0 -20
  173. package/dist/cjs/mediaParsers/_load.cjs.map +0 -1
  174. package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs +0 -23
  175. package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs.map +0 -1
  176. package/dist/cjs/mediaParsers/applicationJson.cjs +0 -22
  177. package/dist/cjs/mediaParsers/applicationJson.cjs.map +0 -1
  178. package/dist/cjs/mediaParsers/textPlain.cjs +0 -22
  179. package/dist/cjs/mediaParsers/textPlain.cjs.map +0 -1
  180. package/dist/esm/lib/structures/MediaParser.mjs +0 -76
  181. package/dist/esm/lib/structures/MediaParser.mjs.map +0 -1
  182. package/dist/esm/lib/structures/MediaParserStore.mjs +0 -24
  183. package/dist/esm/lib/structures/MediaParserStore.mjs.map +0 -1
  184. package/dist/esm/lib/utils/MimeTypes.mjs +0 -26
  185. package/dist/esm/lib/utils/MimeTypes.mjs.map +0 -1
  186. package/dist/esm/mediaParsers/_load.mjs +0 -17
  187. package/dist/esm/mediaParsers/_load.mjs.map +0 -1
  188. package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs +0 -20
  189. package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs.map +0 -1
  190. package/dist/esm/mediaParsers/applicationJson.mjs +0 -19
  191. package/dist/esm/mediaParsers/applicationJson.mjs.map +0 -1
  192. package/dist/esm/mediaParsers/textPlain.mjs +0 -19
  193. package/dist/esm/mediaParsers/textPlain.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/lib/utils/_body/RequestProxy.ts"],"names":["RequestURLProxy","RequestHeadersProxy","ReadableStream","isNullish","arrayBuffer","Blob","Response","isNullishOrEmpty"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,QAAA,EAAA,IAAA,EAAA,aAAA,EAAA,cAAA,EAAA,gBAAA,EAAA,WAAA;AAqBO,IAAM,aAAA,GAAN,MAAM,aAAgC,CAAA;AAAA,EAwBrC,YAAY,OAAqB,EAAA;AAvBxC,IAAA,aAAA,CAAA,IAAA,EAAO,OAAsB,EAAA,SAAA,CAAA;AAC7B,IAAA,aAAA,CAAA,IAAA,EAAO,aAAkC,EAAA,aAAA,CAAA;AACzC,IAAA,aAAA,CAAA,IAAA,EAAO,aAAkC,EAAA,EAAA,CAAA;AACzC,IAAA,aAAA,CAAA,IAAA,EAAO,WAAoB,EAAA,EAAA,CAAA;AAC3B,IAAA,aAAA,CAAA,IAAA,EAAO,WAAqB,EAAA,KAA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CAAc,aAAa,CAAA,IAAK,gBAAgB,CAAG,EAAA;AAC7D,MAAA,YAAA,CAAA,IAAA,EAAK,cAAiB,EAAA,IAAA,CAAA;AACtB,MAAO,OAAA,IAAA;AAAA;AAGR,IAAA,MAAM,gBAAmB,GAAA,IAAA,CAAK,OAAQ,CAAA,GAAA,CAAI,mBAAmB,CAAA;AAC7D,IAAI,IAAA,gBAAA,EAAkB,QAAS,CAAA,SAAS,CAAG,EAAA;AAC1C,MAAA,YAAA,CAAA,IAAA,EAAK,cAAiB,EAAA,IAAA,CAAA;AACtB,MAAO,OAAA,IAAA;AAAA;AAGR,IAAA,YAAA,CAAA,IAAA,EAAK,cAAiB,EAAA,KAAA,CAAA;AACtB,IAAO,OAAA,KAAA;AAAA;AAET,CAAA;AAjGU,QAAA,GAAA,IAAA,OAAA,EAAA;AACA,IAAA,GAAA,IAAA,OAAA,EAAA;AACT,aAAA,GAAA,IAAA,OAAA,EAAA;AACA,cAAA,GAAA,IAAA,OAAA,EAAA;AACA,gBAAA,GAAA,IAAA,OAAA,EAAA;AACA,WAAA,GAAA,IAAA,OAAA,EAAA;AAtB4C,MAAA,CAAA,aAAA,EAAA,cAAA,CAAA;AAAtC,IAAM,YAAN,GAAA","file":"RequestProxy.cjs","sourcesContent":["import { isNullish, isNullishOrEmpty } from '@sapphire/utilities';\nimport { Blob } from 'node:buffer';\nimport { arrayBuffer } from 'node:stream/consumers';\nimport { ReadableStream } from 'node:stream/web';\nimport {\n\tResponse,\n\ttype FormData,\n\ttype Headers,\n\ttype ReferrerPolicy,\n\ttype Request,\n\ttype RequestCache,\n\ttype RequestCredentials,\n\ttype RequestDestination,\n\ttype RequestMode,\n\ttype RequestRedirect\n} from 'undici';\nimport type { ApiRequest } from '../../structures/api/ApiRequest';\nimport type { MethodName } from '../../structures/http/HttpMethods';\nimport { RequestHeadersProxy } from './RequestHeadersProxy';\nimport { RequestURLProxy } from './RequestURLProxy';\n\nexport class RequestProxy implements Request {\n\tpublic cache: RequestCache = 'default';\n\tpublic credentials: RequestCredentials = 'same-origin';\n\tpublic destination: RequestDestination = '';\n\tpublic integrity: string = '';\n\tpublic keepalive: boolean = false;\n\n\tpublic mode: RequestMode = 'cors';\n\tpublic redirect: RequestRedirect = 'follow';\n\tpublic referrer: string = 'about:client';\n\tpublic referrerPolicy: ReferrerPolicy = '';\n\n\tpublic headers: Headers;\n\n\tpublic bodyUsed: boolean = false;\n\tpublic duplex = 'half' as const;\n\n\treadonly #request: ApiRequest;\n\treadonly #url: RequestURLProxy;\n\t#cachedMethod: MethodName | null = null;\n\t#cachedHasBody: boolean | null = null;\n\t#abortController: AbortController | null = null;\n\t#bodyStream: ReadableStream<Uint8Array> | null = null;\n\n\tpublic constructor(request: ApiRequest) {\n\t\tthis.#request = request;\n\t\tthis.#url = new RequestURLProxy(request);\n\t\tthis.headers = new RequestHeadersProxy(request);\n\t}\n\n\tpublic get url(): string {\n\t\treturn this.#url.href;\n\t}\n\n\tpublic get method(): MethodName {\n\t\tthis.#cachedMethod ??= (this.#request.method?.toUpperCase() ?? 'GET') as MethodName;\n\t\treturn this.#cachedMethod;\n\t}\n\n\tpublic get signal(): AbortSignal {\n\t\tthis.#abortController ??= new AbortController();\n\t\treturn this.#abortController.signal;\n\t}\n\n\tpublic get body(): ReadableStream<Uint8Array> | null {\n\t\tif (!this.hasBody) return null;\n\n\t\tthis.#bodyStream ??= new ReadableStream<Uint8Array>({\n\t\t\tstart: (controller) => {\n\t\t\t\tthis.#request\n\t\t\t\t\t.on('data', (chunk) => controller.enqueue(chunk))\n\t\t\t\t\t.once('error', (error) => {\n\t\t\t\t\t\tcontroller.error(error);\n\t\t\t\t\t\tthis.#abortController?.abort();\n\t\t\t\t\t})\n\t\t\t\t\t.once('close', () => {\n\t\t\t\t\t\tthis.#abortController?.abort();\n\t\t\t\t\t})\n\t\t\t\t\t.once('end', () => {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\treturn this.#bodyStream;\n\t}\n\n\tpublic async arrayBuffer(): Promise<ArrayBuffer> {\n\t\tconst { body } = this;\n\t\treturn isNullish(body) ? new ArrayBuffer(0) : arrayBuffer(body);\n\t}\n\n\tpublic async blob(): Promise<Blob> {\n\t\tconst arrayBuffer = await this.arrayBuffer();\n\t\treturn new Blob([arrayBuffer], {\n\t\t\ttype: this.headers.get('content-type') ?? ''\n\t\t});\n\t}\n\n\tpublic async formData(): Promise<FormData> {\n\t\treturn new Response(this.body, { headers: this.headers }).formData(); // NOSONAR\n\t}\n\n\tpublic async json(): Promise<unknown> {\n\t\treturn JSON.parse(await this.text());\n\t}\n\n\tpublic async text(): Promise<string> {\n\t\treturn new TextDecoder().decode(await this.arrayBuffer());\n\t}\n\n\tpublic clone(): Request {\n\t\treturn new RequestProxy(this.#request);\n\t}\n\n\tprivate get hasBody(): boolean {\n\t\tif (this.#cachedHasBody !== null) return this.#cachedHasBody;\n\n\t\tconst contentLengthString = this.headers.get('content-length');\n\t\tconst contentLength = isNullishOrEmpty(contentLengthString) ? 0 : Number(contentLengthString);\n\t\tif (Number.isSafeInteger(contentLength) && contentLength > 0) {\n\t\t\tthis.#cachedHasBody = true;\n\t\t\treturn true;\n\t\t}\n\n\t\tconst transferEncoding = this.headers.get('transfer-encoding');\n\t\tif (transferEncoding?.includes('chunked')) {\n\t\t\tthis.#cachedHasBody = true;\n\t\t\treturn true;\n\t\t}\n\n\t\tthis.#cachedHasBody = false;\n\t\treturn false;\n\t}\n}\n"]}
@@ -0,0 +1,179 @@
1
+ 'use strict';
2
+
3
+ var utilities = require('@sapphire/utilities');
4
+ var constants_cjs = require('../constants.cjs');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __typeError = (msg) => {
8
+ throw TypeError(msg);
9
+ };
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
12
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
14
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
15
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
16
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
17
+ var _protocol, _hostname, _port, _pathname, _search, _searchParams, _request;
18
+ var _RequestURLProxy = class _RequestURLProxy {
19
+ constructor(request) {
20
+ __publicField(this, "hash", "");
21
+ __publicField(this, "password", "");
22
+ __publicField(this, "username", "");
23
+ __privateAdd(this, _protocol, null);
24
+ __privateAdd(this, _hostname, null);
25
+ __privateAdd(this, _port, null);
26
+ __privateAdd(this, _pathname, null);
27
+ __privateAdd(this, _search, null);
28
+ __privateAdd(this, _searchParams, null);
29
+ __privateAdd(this, _request);
30
+ __privateSet(this, _request, request);
31
+ }
32
+ get host() {
33
+ return __privateGet(this, _request).headers.host ?? "";
34
+ }
35
+ set host(value) {
36
+ __privateSet(this, _hostname, null);
37
+ __privateSet(this, _port, null);
38
+ __privateGet(this, _request).headers.host = value;
39
+ }
40
+ get hostname() {
41
+ if (__privateGet(this, _hostname) === null) {
42
+ const [hostname, port] = parseHost(__privateGet(this, _request).headers.host);
43
+ __privateSet(this, _hostname, hostname);
44
+ __privateSet(this, _port, port === -1 ? "" : String(port));
45
+ }
46
+ return __privateGet(this, _hostname);
47
+ }
48
+ set hostname(value) {
49
+ __privateSet(this, _hostname, value);
50
+ }
51
+ get port() {
52
+ if (__privateGet(this, _port) === null) {
53
+ const [hostname, port] = parseHost(__privateGet(this, _request).headers.host);
54
+ __privateSet(this, _hostname, hostname);
55
+ __privateSet(this, _port, port === -1 ? String(__privateGet(this, _request).socket.localPort ?? "") : String(port));
56
+ }
57
+ return __privateGet(this, _port);
58
+ }
59
+ set port(value) {
60
+ __privateSet(this, _port, String(Number(value || "")));
61
+ }
62
+ get pathname() {
63
+ if (__privateGet(this, _pathname) === null) {
64
+ const [pathname, search] = parsePath(__privateGet(this, _request).url);
65
+ __privateSet(this, _pathname, pathname);
66
+ __privateGet(this, _search) ?? __privateSet(this, _search, search);
67
+ }
68
+ return __privateGet(this, _pathname);
69
+ }
70
+ set pathname(value) {
71
+ const normalized = value.startsWith("/") ? value : `/${value}`;
72
+ if (normalized === __privateGet(this, _pathname)) return;
73
+ __privateSet(this, _pathname, normalized);
74
+ __privateGet(this, _request).url = normalized + this.search;
75
+ }
76
+ get search() {
77
+ if (__privateGet(this, _search) === null) {
78
+ const [pathname, search] = parsePath(__privateGet(this, _request).url);
79
+ __privateGet(this, _pathname) ?? __privateSet(this, _pathname, pathname);
80
+ __privateSet(this, _search, search);
81
+ }
82
+ return __privateGet(this, _search);
83
+ }
84
+ set search(value) {
85
+ let normalized;
86
+ if (value === "?") {
87
+ normalized = "";
88
+ } else if (value && !value.startsWith("?")) {
89
+ normalized = `?${value}`;
90
+ } else {
91
+ normalized = value;
92
+ }
93
+ if (normalized === __privateGet(this, _search)) return;
94
+ __privateSet(this, _search, normalized);
95
+ __privateSet(this, _searchParams, null);
96
+ __privateGet(this, _request).url = this.pathname + normalized;
97
+ }
98
+ get searchParams() {
99
+ __privateGet(this, _searchParams) ?? __privateSet(this, _searchParams, new URLSearchParams(this.search));
100
+ return __privateGet(this, _searchParams);
101
+ }
102
+ set searchParams(value) {
103
+ __privateSet(this, _searchParams, value);
104
+ this.search = value.toString();
105
+ }
106
+ get protocol() {
107
+ __privateGet(this, _protocol) ?? __privateSet(this, _protocol, __privateGet(this, _request).socket.encrypted || __privateGet(this, _request).headers["x-forwarded-proto"] === "https" ? "https:" : "http:");
108
+ return __privateGet(this, _protocol);
109
+ }
110
+ set protocol(value) {
111
+ __privateSet(this, _protocol, value);
112
+ }
113
+ get origin() {
114
+ return `${this.protocol}//${this.host}`;
115
+ }
116
+ set origin(_value) {
117
+ }
118
+ get href() {
119
+ return `${this.protocol}//${this.host}${this.pathname}${this.search}`;
120
+ }
121
+ set href(value) {
122
+ const url = new URL(value);
123
+ __privateSet(this, _protocol, url.protocol);
124
+ this.username = url.username;
125
+ this.password = url.password;
126
+ __privateSet(this, _hostname, url.hostname);
127
+ __privateSet(this, _port, url.port);
128
+ __privateSet(this, _pathname, url.pathname);
129
+ __privateSet(this, _search, url.search);
130
+ this.hash = url.hash;
131
+ }
132
+ toString() {
133
+ return this.href;
134
+ }
135
+ toJSON() {
136
+ return this.href;
137
+ }
138
+ // eslint-disable-next-line @typescript-eslint/class-literal-property-style
139
+ get [Symbol.toStringTag]() {
140
+ return "URL";
141
+ }
142
+ [constants_cjs.NodeUtilInspectSymbol]() {
143
+ return this.href;
144
+ }
145
+ };
146
+ _protocol = new WeakMap();
147
+ _hostname = new WeakMap();
148
+ _port = new WeakMap();
149
+ _pathname = new WeakMap();
150
+ _search = new WeakMap();
151
+ _searchParams = new WeakMap();
152
+ _request = new WeakMap();
153
+ __name(_RequestURLProxy, "RequestURLProxy");
154
+ var RequestURLProxy = _RequestURLProxy;
155
+ function parsePath(input) {
156
+ const url = (input ?? "/").replaceAll("\\", "/");
157
+ const index = url.indexOf("?");
158
+ if (index === -1) {
159
+ return [url, ""];
160
+ }
161
+ return [url.slice(0, index), url.slice(index)];
162
+ }
163
+ __name(parsePath, "parsePath");
164
+ function parseHost(host) {
165
+ if (utilities.isNullishOrEmpty(host)) {
166
+ return ["localhost", -1];
167
+ }
168
+ const index = host.indexOf(":");
169
+ if (index === -1) {
170
+ return [host, -1];
171
+ }
172
+ const port = Number(host.slice(index));
173
+ return [host.slice(0, index), Number.isSafeInteger(port) ? port : -1];
174
+ }
175
+ __name(parseHost, "parseHost");
176
+
177
+ exports.RequestURLProxy = RequestURLProxy;
178
+ //# sourceMappingURL=RequestURLProxy.cjs.map
179
+ //# sourceMappingURL=Request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CAAA,OAAA,CAAQ,GAAG,CAAA;AAC9B,EAAA,IAAI,UAAU,CAAI,CAAA,EAAA;AACjB,IAAO,OAAA,CAAC,MAAM,CAAE,CAAA,CAAA;AAAA;AAGjB,EAAA,MAAM,IAAO,GAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACrC,EAAO,OAAA,CAAC,IAAK,CAAA,KAAA,CAAM,CAAG,EAAA,KAAK,CAAG,EAAA,MAAA,CAAO,aAAc,CAAA,IAAI,CAAI,GAAA,IAAA,GAAO,CAAE,CAAA,CAAA;AACrE;AAZS,MAAA,CAAA,SAAA,EAAA,WAAA,CAAA","file":"RequestURLProxy.cjs","sourcesContent":["import { isNullishOrEmpty } from '@sapphire/utilities';\nimport type { ApiRequest } from '../../structures/api/ApiRequest';\nimport { NodeUtilInspectSymbol } from '../constants';\n\nexport class RequestURLProxy implements URL {\n\tpublic hash: string = '';\n\tpublic password: string = '';\n\tpublic username: string = '';\n\n\t#protocol: URLProtocol | null = null;\n\t#hostname: string | null = null;\n\t#port: string | null = null;\n\n\t#pathname: string | null = null;\n\t#search: string | null = null;\n\t#searchParams: URLSearchParams | null = null;\n\n\treadonly #request: ApiRequest;\n\n\tpublic constructor(request: ApiRequest) {\n\t\tthis.#request = request;\n\t}\n\n\tpublic get host(): string {\n\t\treturn this.#request.headers.host ?? '';\n\t}\n\n\tpublic set host(value: string) {\n\t\tthis.#hostname = null;\n\t\tthis.#port = null;\n\t\tthis.#request.headers.host = value;\n\t}\n\n\tpublic get hostname(): string {\n\t\tif (this.#hostname === null) {\n\t\t\tconst [hostname, port] = parseHost(this.#request.headers.host);\n\t\t\tthis.#hostname = hostname;\n\t\t\tthis.#port = port === -1 ? '' : String(port);\n\t\t}\n\n\t\treturn this.#hostname;\n\t}\n\n\tpublic set hostname(value: string) {\n\t\tthis.#hostname = value;\n\t}\n\n\tpublic get port(): string {\n\t\tif (this.#port === null) {\n\t\t\tconst [hostname, port] = parseHost(this.#request.headers.host);\n\t\t\tthis.#hostname = hostname;\n\t\t\tthis.#port = port === -1 ? String(this.#request.socket.localPort ?? '') : String(port);\n\t\t}\n\n\t\treturn this.#port;\n\t}\n\n\tpublic set port(value: string) {\n\t\tthis.#port = String(Number(value || ''));\n\t}\n\n\tpublic get pathname(): string {\n\t\tif (this.#pathname === null) {\n\t\t\tconst [pathname, search] = parsePath(this.#request.url);\n\t\t\tthis.#pathname = pathname;\n\t\t\tthis.#search ??= search;\n\t\t}\n\n\t\treturn this.#pathname;\n\t}\n\n\tpublic set pathname(value: string) {\n\t\tconst normalized = value.startsWith('/') ? value : `/${value}`;\n\t\tif (normalized === this.#pathname) return;\n\n\t\tthis.#pathname = normalized;\n\t\tthis.#request.url = normalized + this.search;\n\t}\n\n\tpublic get search(): string {\n\t\tif (this.#search === null) {\n\t\t\tconst [pathname, search] = parsePath(this.#request.url);\n\t\t\tthis.#pathname ??= pathname;\n\t\t\tthis.#search = search;\n\t\t}\n\n\t\treturn this.#search;\n\t}\n\n\tpublic set search(value: string) {\n\t\tlet normalized: string;\n\t\tif (value === '?') {\n\t\t\tnormalized = '';\n\t\t} else if (value && !value.startsWith('?')) {\n\t\t\tnormalized = `?${value}`;\n\t\t} else {\n\t\t\tnormalized = value;\n\t\t}\n\n\t\tif (normalized === this.#search) return;\n\n\t\tthis.#search = normalized;\n\t\tthis.#searchParams = null;\n\t\tthis.#request.url = this.pathname + normalized;\n\t}\n\n\tpublic get searchParams(): URLSearchParams {\n\t\tthis.#searchParams ??= new URLSearchParams(this.search);\n\t\treturn this.#searchParams;\n\t}\n\n\tpublic set searchParams(value: URLSearchParams) {\n\t\tthis.#searchParams = value;\n\t\tthis.search = value.toString();\n\t}\n\n\tpublic get protocol(): URLProtocol {\n\t\tthis.#protocol ??= (this.#request.socket as any).encrypted || this.#request.headers['x-forwarded-proto'] === 'https' ? 'https:' : 'http:';\n\t\treturn this.#protocol;\n\t}\n\n\tpublic set protocol(value: URLProtocol) {\n\t\tthis.#protocol = value;\n\t}\n\n\tpublic get origin(): string {\n\t\treturn `${this.protocol}//${this.host}`;\n\t}\n\n\tpublic set origin(_value: string) {\n\t\t// No-op\n\t}\n\n\tpublic get href(): string {\n\t\treturn `${this.protocol}//${this.host}${this.pathname}${this.search}`;\n\t}\n\n\tpublic set href(value: string) {\n\t\tconst url = new URL(value);\n\t\tthis.#protocol = url.protocol as URLProtocol;\n\t\tthis.username = url.username;\n\t\tthis.password = url.password;\n\t\tthis.#hostname = url.hostname;\n\t\tthis.#port = url.port;\n\t\tthis.#pathname = url.pathname;\n\t\tthis.#search = url.search;\n\t\tthis.hash = url.hash;\n\t}\n\n\tpublic toString(): string {\n\t\treturn this.href;\n\t}\n\n\tpublic toJSON(): string {\n\t\treturn this.href;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/class-literal-property-style\n\tpublic get [Symbol.toStringTag]() {\n\t\treturn 'URL';\n\t}\n\n\tpublic [NodeUtilInspectSymbol]() {\n\t\treturn this.href;\n\t}\n}\n\nexport type URLProtocol = 'https:' | 'http:';\n\nfunction parsePath(input: string | undefined): [pathname: string, search: string] {\n\tconst url = (input ?? '/').replaceAll('\\\\', '/');\n\tconst index = url.indexOf('?');\n\tif (index === -1) {\n\t\treturn [url, ''];\n\t}\n\n\treturn [url.slice(0, index), url.slice(index)];\n}\n\nfunction parseHost(host: string | undefined): [hostname: string, port: number] {\n\tif (isNullishOrEmpty(host)) {\n\t\treturn ['localhost', -1];\n\t}\n\n\tconst index = host.indexOf(':');\n\tif (index === -1) {\n\t\treturn [host, -1];\n\t}\n\n\tconst port = Number(host.slice(index));\n\treturn [host.slice(0, index), Number.isSafeInteger(port) ? port : -1];\n}\n"]}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ // src/lib/utils/constants.ts
4
+ var NodeUtilInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
5
+
6
+ exports.NodeUtilInspectSymbol = NodeUtilInspectSymbol;
7
+ //# sourceMappingURL=constants.cjs.map
8
+ //# sourceMappingURL=constants.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/utils/constants.ts"],"names":[],"mappings":";;;AAAa,IAAA,qBAAA,GAAwB,MAAO,CAAA,GAAA,CAAI,4BAA4B","file":"constants.cjs","sourcesContent":["export const NodeUtilInspectSymbol = Symbol.for('nodejs.util.inspect.custom');\n"]}
@@ -19,5 +19,5 @@ __name(_PluginListener, "PluginListener");
19
19
  var PluginListener = _PluginListener;
20
20
 
21
21
  exports.PluginListener = PluginListener;
22
- //# sourceMappingURL=out.js.map
22
+ //# sourceMappingURL=PluginRouteError.cjs.map
23
23
  //# sourceMappingURL=PluginRouteError.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginRouteError.ts"],"names":[],"mappings":";;;;AAAA,SAAS,gBAAgB;AAGzB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAErB,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,YAAY,WAAW,CAAC;AAAA,EACpE;AAAA,EAEgB,IAAI,OAAc,UAAsB,UAAuB;AAE9E,SAAK,UAAU,OAAO,MAAM,KAAK;AAGjC,QAAI,CAAC,SAAS,cAAe,UAAS,OAAO,UAAU,mBAAmB,EAAE,KAAK,EAAE,OAAO,MAAM,WAAW,MAAM,CAAC;AAAA,EACnH;AACD;AAZ6C;AAAtC,IAAM,iBAAN","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouteError });\n\t}\n\n\tpublic override run(error: Error, _request: ApiRequest, response: ApiResponse) {\n\t\t// Log the error to console:\n\t\tthis.container.logger.fatal(error);\n\n\t\t// Send a response to the client if none was sent:\n\t\tif (!response.writableEnded) response.status(HttpCodes.InternalServerError).json({ error: error.message ?? error });\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/listeners/PluginRouteError.ts"],"names":["Listener","ServerEvent","HttpCodes"],"mappings":";;;;;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuBA,kBAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAAC,sBAAA,CAAY,YAAY,CAAA;AAAA;AACpE,EAEgB,GAAA,CAAI,KAAc,EAAA,QAAA,EAAsB,QAAuB,EAAA;AAE9E,IAAK,IAAA,CAAA,SAAA,CAAU,MAAO,CAAA,KAAA,CAAM,KAAK,CAAA;AAGjC,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,OAAOC,uBAAU,CAAA,mBAAmB,CAAE,CAAA,IAAA,CAAK,EAAE,KAAA,EAAO,KAAM,CAAA,OAAA,IAAW,OAAO,CAAA;AAAA;AAEpH,CAAA;AAZ6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginRouteError.cjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouteError });\n\t}\n\n\tpublic override run(error: Error, _request: ApiRequest, response: ApiResponse) {\n\t\t// Log the error to console:\n\t\tthis.container.logger.fatal(error);\n\n\t\t// Send a response to the client if none was sent:\n\t\tif (!response.writableEnded) response.status(HttpCodes.InternalServerError).json({ error: error.message ?? error });\n\t}\n}\n"]}
@@ -19,5 +19,5 @@ __name(_PluginListener, "PluginListener");
19
19
  var PluginListener = _PluginListener;
20
20
 
21
21
  exports.PluginListener = PluginListener;
22
- //# sourceMappingURL=out.js.map
22
+ //# sourceMappingURL=PluginServerMiddlewareError.cjs.map
23
23
  //# sourceMappingURL=PluginServerMiddlewareError.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareError.ts"],"names":[],"mappings":";;;;AAAA,SAAS,gBAAgB;AAGzB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAErB,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,YAAY,gBAAgB,CAAC;AAAA,EACzE;AAAA,EAEgB,IAAI,OAAc,UAAsB,UAAuB;AAE9E,SAAK,UAAU,OAAO,MAAM,KAAK;AAGjC,QAAI,CAAC,SAAS,cAAe,UAAS,OAAO,UAAU,mBAAmB,EAAE,KAAK,EAAE,OAAO,MAAM,WAAW,MAAM,CAAC;AAAA,EACnH;AACD;AAZ6C;AAAtC,IAAM,iBAAN","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.MiddlewareError });\n\t}\n\n\tpublic override run(error: Error, _request: ApiRequest, response: ApiResponse) {\n\t\t// Log the error to console:\n\t\tthis.container.logger.fatal(error);\n\n\t\t// Send a response to the client if none was sent:\n\t\tif (!response.writableEnded) response.status(HttpCodes.InternalServerError).json({ error: error.message ?? error });\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareError.ts"],"names":["Listener","ServerEvent","HttpCodes"],"mappings":";;;;;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuBA,kBAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAAC,sBAAA,CAAY,iBAAiB,CAAA;AAAA;AACzE,EAEgB,GAAA,CAAI,KAAc,EAAA,QAAA,EAAsB,QAAuB,EAAA;AAE9E,IAAK,IAAA,CAAA,SAAA,CAAU,MAAO,CAAA,KAAA,CAAM,KAAK,CAAA;AAGjC,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,OAAOC,uBAAU,CAAA,mBAAmB,CAAE,CAAA,IAAA,CAAK,EAAE,KAAA,EAAO,KAAM,CAAA,OAAA,IAAW,OAAO,CAAA;AAAA;AAEpH,CAAA;AAZ6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerMiddlewareError.cjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.MiddlewareError });\n\t}\n\n\tpublic override run(error: Error, _request: ApiRequest, response: ApiResponse) {\n\t\t// Log the error to console:\n\t\tthis.container.logger.fatal(error);\n\n\t\t// Send a response to the client if none was sent:\n\t\tif (!response.writableEnded) response.status(HttpCodes.InternalServerError).json({ error: error.message ?? error });\n\t}\n}\n"]}
@@ -21,5 +21,5 @@ __name(_PluginListener, "PluginListener");
21
21
  var PluginListener = _PluginListener;
22
22
 
23
23
  exports.PluginListener = PluginListener;
24
- //# sourceMappingURL=out.js.map
24
+ //# sourceMappingURL=PluginServerMiddlewareSuccess.cjs.map
25
25
  //# sourceMappingURL=PluginServerMiddlewareSuccess.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareSuccess.ts"],"names":[],"mappings":";;;;AAAA,SAAS,gBAAgB;AAGzB,SAAS,mBAAmB;AAErB,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,YAAY,kBAAkB,CAAC;AAAA,EAC3E;AAAA,EAEA,MAAsB,IAAI,SAAqB,UAAuB;AACrE,QAAI;AACH,YAAM,QAAQ,MAAO,IAAI,SAAS,QAAQ;AAAA,IAC3C,SAAS,OAAO;AACf,WAAK,UAAU,OAAO,KAAK,YAAY,YAAY,OAAO,SAAS,QAAQ;AAAA,IAC5E;AAAA,EACD;AACD;AAZ6C;AAAtC,IAAM,iBAAN","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.MiddlewareSuccess });\n\t}\n\n\tpublic override async run(request: ApiRequest, response: ApiResponse) {\n\t\ttry {\n\t\t\tawait request.route!.run(request, response);\n\t\t} catch (error) {\n\t\t\tthis.container.server.emit(ServerEvent.RouteError, error, request, response);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareSuccess.ts"],"names":["Listener","ServerEvent"],"mappings":";;;;;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuBA,kBAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAAC,sBAAA,CAAY,mBAAmB,CAAA;AAAA;AAC3E,EAEA,MAAsB,GAAI,CAAA,OAAA,EAAqB,QAAuB,EAAA;AACrE,IAAI,IAAA;AACH,MAAA,MAAM,OAAQ,CAAA,KAAA,CAAO,GAAI,CAAA,OAAA,EAAS,QAAQ,CAAA;AAAA,aAClC,KAAO,EAAA;AACf,MAAA,IAAA,CAAK,UAAU,MAAO,CAAA,IAAA,CAAKA,uBAAY,UAAY,EAAA,KAAA,EAAgB,SAAS,QAAQ,CAAA;AAAA;AACrF;AAEF,CAAA;AAZ6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerMiddlewareSuccess.cjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.MiddlewareSuccess });\n\t}\n\n\tpublic override async run(request: ApiRequest, response: ApiResponse) {\n\t\ttry {\n\t\t\tawait request.route!.run(request, response);\n\t\t} catch (error) {\n\t\t\tthis.container.server.emit(ServerEvent.RouteError, error as Error, request, response);\n\t\t}\n\t}\n}\n"]}
@@ -38,7 +38,7 @@ var _PluginListener = class _PluginListener extends framework.Listener {
38
38
  if (branch === null) {
39
39
  this.container.server.emit(Server_cjs.ServerEvent.RouterBranchNotFound, request, response);
40
40
  } else if (route === null) {
41
- this.container.server.emit(Server_cjs.ServerEvent.RouterBranchMethodNotAllowed, request, response);
41
+ this.container.server.emit(Server_cjs.ServerEvent.RouterBranchMethodNotAllowed, request, response, branch);
42
42
  } else {
43
43
  this.container.server.emit(Server_cjs.ServerEvent.RouterFound, request, response);
44
44
  }
@@ -62,5 +62,5 @@ __name(_PluginListener, "PluginListener");
62
62
  var PluginListener = _PluginListener;
63
63
 
64
64
  exports.PluginListener = PluginListener;
65
- //# sourceMappingURL=out.js.map
65
+ //# sourceMappingURL=PluginServerRequest.cjs.map
66
66
  //# sourceMappingURL=PluginServerRequest.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginServerRequest.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,SAAS,gBAAgB;AAIzB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAL3B;AAOO,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,YAAY,QAAQ,CAAC;AAF3D;AAAA,EAGN;AAAA,EAEA,MAAsB,IAAI,SAAqB,UAAuB;AACrE,UAAM,EAAE,OAAO,YAAY,IAAI,sBAAK,wCAAL,WAAe,QAAQ;AACtD,YAAQ,QAAQ,OAAO,YAAY,IAAI,gBAAgB,WAAW,EAAE,QAAQ,CAAC;AAE7E,UAAM,SAAS,KAAK,UAAU,OAAO,OAAO,OAAO,KAAK,KAAK;AAC7D,UAAM,OAAO,SAAS,OAAO,OAAO;AACpC,UAAM,QAAQ,OAAO,KAAK,IAAK,QAAQ,UAAU,KAAoB,IAAI;AAEzE,QAAI,SAAS,MAAM;AAClB,cAAQ,SAAS,KAAM,kBAAkB,KAAK;AAAA,IAC/C;AAEA,YAAQ,aAAa;AACrB,YAAQ,QAAQ;AAEhB,QAAI;AAEH,YAAM,KAAK,UAAU,OAAO,YAAY,IAAI,SAAS,QAAQ;AAAA,IAC9D,SAAS,OAAO;AACf,WAAK,UAAU,OAAO,KAAK,YAAY,iBAAiB,OAAO,SAAS,QAAQ;AAGhF;AAAA,IACD;AAEA,QAAI,WAAW,MAAM;AACpB,WAAK,UAAU,OAAO,KAAK,YAAY,sBAAsB,SAAS,QAAQ;AAAA,IAC/E,WAAW,UAAU,MAAM;AAC1B,WAAK,UAAU,OAAO,KAAK,YAAY,8BAA8B,SAAS,QAAQ;AAAA,IACvF,OAAO;AACN,WAAK,UAAU,OAAO,KAAK,YAAY,aAAa,SAAS,QAAQ;AAAA,IACtE;AAAA,EACD;AAiBD;AAtDO;AAuCN,cAAS,gCAAC,MAAM,IAAI;AACnB,QAAM,QAAQ,IAAI,QAAQ,GAAG;AAE7B,MAAI;AACJ,MAAI;AACJ,MAAI,UAAU,IAAI;AACjB,eAAW;AACX,kBAAc;AAAA,EACf,OAAO;AACN,eAAW,IAAI,UAAU,GAAG,KAAK;AACjC,kBAAc,IAAI,UAAU,QAAQ,CAAC;AAAA,EACtC;AAEA,SAAO,EAAE,OAAO,WAAW,UAAU,QAAQ,GAAG,YAAY;AAC7D,GAdS;AAvCmC;AAAtC,IAAM,iBAAN","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport type { MethodName } from '../lib/structures/http/HttpMethods';\nimport { ServerEvent } from '../lib/structures/http/Server';\nimport { RouterRoot } from '../lib/structures/router/RouterRoot';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.Request });\n\t}\n\n\tpublic override async run(request: ApiRequest, response: ApiResponse) {\n\t\tconst { parts, querystring } = this.#parseURL(request.url);\n\t\trequest.query = Object.fromEntries(new URLSearchParams(querystring).entries());\n\n\t\tconst branch = this.container.server.routes.router.find(parts);\n\t\tconst node = branch ? branch.node : null;\n\t\tconst route = node ? node.get((request.method ?? 'GET') as MethodName) : null;\n\n\t\tif (node !== null) {\n\t\t\trequest.params = node!.extractParameters(parts);\n\t\t}\n\n\t\trequest.routerNode = node;\n\t\trequest.route = route;\n\n\t\ttry {\n\t\t\t// Middlewares need to be run regardless of the match, specially since browsers do an OPTIONS request first.\n\t\t\tawait this.container.server.middlewares.run(request, response);\n\t\t} catch (error) {\n\t\t\tthis.container.server.emit(ServerEvent.MiddlewareError, error, request, response);\n\n\t\t\t// If a middleware errored, it might cause undefined behavior in the routes, so we will return early.\n\t\t\treturn;\n\t\t}\n\n\t\tif (branch === null) {\n\t\t\tthis.container.server.emit(ServerEvent.RouterBranchNotFound, request, response);\n\t\t} else if (route === null) {\n\t\t\tthis.container.server.emit(ServerEvent.RouterBranchMethodNotAllowed, request, response);\n\t\t} else {\n\t\t\tthis.container.server.emit(ServerEvent.RouterFound, request, response);\n\t\t}\n\t}\n\n\t#parseURL(url = '') {\n\t\tconst index = url.indexOf('?');\n\n\t\tlet pathname: string;\n\t\tlet querystring: string;\n\t\tif (index === -1) {\n\t\t\tpathname = url;\n\t\t\tquerystring = '';\n\t\t} else {\n\t\t\tpathname = url.substring(0, index);\n\t\t\tquerystring = url.substring(index + 1);\n\t\t}\n\n\t\treturn { parts: RouterRoot.normalize(pathname), querystring };\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/listeners/PluginServerRequest.ts"],"names":["Listener","ServerEvent","RouterRoot"],"mappings":";;;;;;;;;;;;;;AAAA,IAAA,yBAAA,EAAA,WAAA;AAOO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuBA,kBAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAAC,sBAAA,CAAY,SAAS,CAAA;AAF3D,IAAA,YAAA,CAAA,IAAA,EAAA,yBAAA,CAAA;AAAA;AAGN,EAEA,MAAsB,GAAI,CAAA,OAAA,EAAqB,QAAuB,EAAA;AACrE,IAAA,MAAM,EAAE,KAAO,EAAA,WAAA,KAAgB,eAAK,CAAA,IAAA,EAAA,yBAAA,EAAA,WAAA,CAAA,CAAL,WAAe,OAAQ,CAAA,GAAA,CAAA;AACtD,IAAQ,OAAA,CAAA,KAAA,GAAQ,OAAO,WAAY,CAAA,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AAA,GAAA,IAAA,OAAA,EAAA;AAuCN,WAAS,mBAAA,MAAA,CAAA,SAAC,MAAM,EAAI,EAAA;AACnB,EAAM,MAAA,KAAA,GAAQ,GAAI,CAAA,OAAA,CAAQ,GAAG,CAAA;AAE7B,EAAI,IAAA,QAAA;AACJ,EAAI,IAAA,WAAA;AACJ,EAAA,IAAI,UAAU,CAAI,CAAA,EAAA;AACjB,IAAW,QAAA,GAAA,GAAA;AACX,IAAc,WAAA,GAAA,EAAA;AAAA,GACR,MAAA;AACN,IAAW,QAAA,GAAA,GAAA,CAAI,SAAU,CAAA,CAAA,EAAG,KAAK,CAAA;AACjC,IAAc,WAAA,GAAA,GAAA,CAAI,SAAU,CAAA,KAAA,GAAQ,CAAC,CAAA;AAAA;AAGtC,EAAA,OAAO,EAAE,KAAO,EAAAC,yBAAA,CAAW,SAAU,CAAA,QAAQ,GAAG,WAAY,EAAA;AAC7D,CAdS,EAAA,WAAA,CAAA;AAvCmC,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRequest.cjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport type { MethodName } from '../lib/structures/http/HttpMethods';\nimport { ServerEvent } from '../lib/structures/http/Server';\nimport { RouterRoot } from '../lib/structures/router/RouterRoot';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.Request });\n\t}\n\n\tpublic override async run(request: ApiRequest, response: ApiResponse) {\n\t\tconst { parts, querystring } = this.#parseURL(request.url);\n\t\trequest.query = Object.fromEntries(new URLSearchParams(querystring).entries());\n\n\t\tconst branch = this.container.server.routes.router.find(parts);\n\t\tconst node = branch ? branch.node : null;\n\t\tconst route = node ? node.get((request.method ?? 'GET') as MethodName) : null;\n\n\t\tif (node !== null) {\n\t\t\trequest.params = node!.extractParameters(parts);\n\t\t}\n\n\t\trequest.routerNode = node;\n\t\trequest.route = route;\n\n\t\ttry {\n\t\t\t// Middlewares need to be run regardless of the match, specially since browsers do an OPTIONS request first.\n\t\t\tawait this.container.server.middlewares.run(request, response);\n\t\t} catch (error) {\n\t\t\tthis.container.server.emit(ServerEvent.MiddlewareError, error as Error, request, response);\n\n\t\t\t// If a middleware errored, it might cause undefined behavior in the routes, so we will return early.\n\t\t\treturn;\n\t\t}\n\n\t\tif (branch === null) {\n\t\t\tthis.container.server.emit(ServerEvent.RouterBranchNotFound, request, response);\n\t\t} else if (route === null) {\n\t\t\tthis.container.server.emit(ServerEvent.RouterBranchMethodNotAllowed, request, response, branch);\n\t\t} else {\n\t\t\tthis.container.server.emit(ServerEvent.RouterFound, request, response);\n\t\t}\n\t}\n\n\t#parseURL(url = '') {\n\t\tconst index = url.indexOf('?');\n\n\t\tlet pathname: string;\n\t\tlet querystring: string;\n\t\tif (index === -1) {\n\t\t\tpathname = url;\n\t\t\tquerystring = '';\n\t\t} else {\n\t\t\tpathname = url.substring(0, index);\n\t\t\tquerystring = url.substring(index + 1);\n\t\t}\n\n\t\treturn { parts: RouterRoot.normalize(pathname), querystring };\n\t}\n}\n"]}
@@ -17,5 +17,5 @@ __name(_PluginListener, "PluginListener");
17
17
  var PluginListener = _PluginListener;
18
18
 
19
19
  exports.PluginListener = PluginListener;
20
- //# sourceMappingURL=out.js.map
20
+ //# sourceMappingURL=PluginServerRouterBranchMethodNotAllowed.cjs.map
21
21
  //# sourceMappingURL=PluginServerRouterBranchMethodNotAllowed.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginServerRouterBranchMethodNotAllowed.ts"],"names":[],"mappings":";;;;AAAA,SAAS,gBAAgB;AAGzB,SAAS,mBAAmB;AAErB,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,YAAY,6BAA6B,CAAC;AAAA,EACtF;AAAA,EAEgB,IAAI,GAAe,UAAuB;AACzD,QAAI,CAAC,SAAS,cAAe,UAAS,iBAAiB;AAAA,EACxD;AACD;AAR6C;AAAtC,IAAM,iBAAN","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouterBranchMethodNotAllowed });\n\t}\n\n\tpublic override run(_: ApiRequest, response: ApiResponse) {\n\t\tif (!response.writableEnded) response.methodNotAllowed();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/listeners/PluginServerRouterBranchMethodNotAllowed.ts"],"names":["Listener","ServerEvent"],"mappings":";;;;;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuBA,kBAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAAC,sBAAA,CAAY,8BAA8B,CAAA;AAAA;AACtF,EAEgB,GAAA,CAAI,GAAe,QAAuB,EAAA;AACzD,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,gBAAiB,EAAA;AAAA;AAEzD,CAAA;AAR6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRouterBranchMethodNotAllowed.cjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouterBranchMethodNotAllowed });\n\t}\n\n\tpublic override run(_: ApiRequest, response: ApiResponse) {\n\t\tif (!response.writableEnded) response.methodNotAllowed();\n\t}\n}\n"]}
@@ -17,5 +17,5 @@ __name(_PluginListener, "PluginListener");
17
17
  var PluginListener = _PluginListener;
18
18
 
19
19
  exports.PluginListener = PluginListener;
20
- //# sourceMappingURL=out.js.map
20
+ //# sourceMappingURL=PluginServerRouterBranchNotFound.cjs.map
21
21
  //# sourceMappingURL=PluginServerRouterBranchNotFound.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginServerRouterBranchNotFound.ts"],"names":[],"mappings":";;;;AAAA,SAAS,gBAAgB;AAGzB,SAAS,mBAAmB;AAErB,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,YAAY,qBAAqB,CAAC;AAAA,EAC9E;AAAA,EAEgB,IAAI,GAAe,UAAuB;AACzD,QAAI,CAAC,SAAS,cAAe,UAAS,SAAS;AAAA,EAChD;AACD;AAR6C;AAAtC,IAAM,iBAAN","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouterBranchNotFound });\n\t}\n\n\tpublic override run(_: ApiRequest, response: ApiResponse) {\n\t\tif (!response.writableEnded) response.notFound();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/listeners/PluginServerRouterBranchNotFound.ts"],"names":["Listener","ServerEvent"],"mappings":";;;;;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuBA,kBAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAAC,sBAAA,CAAY,sBAAsB,CAAA;AAAA;AAC9E,EAEgB,GAAA,CAAI,GAAe,QAAuB,EAAA;AACzD,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,QAAS,EAAA;AAAA;AAEjD,CAAA;AAR6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRouterBranchNotFound.cjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouterBranchNotFound });\n\t}\n\n\tpublic override run(_: ApiRequest, response: ApiResponse) {\n\t\tif (!response.writableEnded) response.notFound();\n\t}\n}\n"]}
@@ -10,12 +10,13 @@ var _PluginListener = class _PluginListener extends framework.Listener {
10
10
  super(context, { emitter: "server", event: Server_cjs.ServerEvent.RouterFound });
11
11
  }
12
12
  run(request, response) {
13
- this.container.server.emit(response.writableEnded ? Server_cjs.ServerEvent.MiddlewareFailure : Server_cjs.ServerEvent.MiddlewareSuccess, request, response);
13
+ const event = response.writableEnded ? Server_cjs.ServerEvent.MiddlewareFailure : Server_cjs.ServerEvent.MiddlewareSuccess;
14
+ this.container.server.emit(event, request, response);
14
15
  }
15
16
  };
16
17
  __name(_PluginListener, "PluginListener");
17
18
  var PluginListener = _PluginListener;
18
19
 
19
20
  exports.PluginListener = PluginListener;
20
- //# sourceMappingURL=out.js.map
21
+ //# sourceMappingURL=PluginServerRouterFound.cjs.map
21
22
  //# sourceMappingURL=PluginServerRouterFound.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginServerRouterFound.ts"],"names":[],"mappings":";;;;AAAA,SAAS,gBAAgB;AAGzB,SAAS,mBAAmB;AAErB,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,YAAY,YAAY,CAAC;AAAA,EACrE;AAAA,EAEgB,IAAI,SAAqB,UAAuB;AAC/D,SAAK,UAAU,OAAO,KAAK,SAAS,gBAAgB,YAAY,oBAAoB,YAAY,mBAAmB,SAAS,QAAQ;AAAA,EACrI;AACD;AAR6C;AAAtC,IAAM,iBAAN","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouterFound });\n\t}\n\n\tpublic override run(request: ApiRequest, response: ApiResponse) {\n\t\tthis.container.server.emit(response.writableEnded ? ServerEvent.MiddlewareFailure : ServerEvent.MiddlewareSuccess, request, response);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/listeners/PluginServerRouterFound.ts"],"names":["Listener","ServerEvent"],"mappings":";;;;;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuBA,kBAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAAC,sBAAA,CAAY,aAAa,CAAA;AAAA;AACrE,EAEgB,GAAA,CAAI,SAAqB,QAAuB,EAAA;AAC/D,IAAA,MAAM,KAAQ,GAAA,QAAA,CAAS,aAAgB,GAAAA,sBAAA,CAAY,oBAAoBA,sBAAY,CAAA,iBAAA;AACnF,IAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,IAAK,CAAA,KAAA,EAAO,SAAS,QAAQ,CAAA;AAAA;AAErD,CAAA;AAT6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRouterFound.cjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvent } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvent.RouterFound });\n\t}\n\n\tpublic override run(request: ApiRequest, response: ApiResponse) {\n\t\tconst event = response.writableEnded ? ServerEvent.MiddlewareFailure : ServerEvent.MiddlewareSuccess;\n\t\tthis.container.server.emit(event, request, response);\n\t}\n}\n"]}
@@ -24,5 +24,5 @@ function loadListeners() {
24
24
  __name(loadListeners, "loadListeners");
25
25
 
26
26
  exports.loadListeners = loadListeners;
27
- //# sourceMappingURL=out.js.map
27
+ //# sourceMappingURL=_load.cjs.map
28
28
  //# sourceMappingURL=_load.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/_load.ts"],"names":[],"mappings":";;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB,wBAAwB;AACnD,SAAS,kBAAkB,mCAAmC;AAC9D,SAAS,kBAAkB,qCAAqC;AAChE,SAAS,kBAAkB,2BAA2B;AACtD,SAAS,kBAAkB,gDAAgD;AAC3E,SAAS,kBAAkB,wCAAwC;AACnE,SAAS,kBAAkB,+BAA+B;AAEnD,SAAS,gBAAgB;AAC/B,QAAM,QAAQ;AACd,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,oBAAoB,OAAO,kBAAkB,MAAM,CAAC;AAC5F,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,+BAA+B,OAAO,6BAA6B,MAAM,CAAC;AAClH,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,iCAAiC,OAAO,+BAA+B,MAAM,CAAC;AACtH,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,uBAAuB,OAAO,qBAAqB,MAAM,CAAC;AAClG,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,4CAA4C,OAAO,0CAA0C,MAAM,CAAC;AAC5I,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,oCAAoC,OAAO,kCAAkC,MAAM,CAAC;AAC5H,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,2BAA2B,OAAO,yBAAyB,MAAM,CAAC;AAC3G;AATgB","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginListener as PluginRouteError } from './PluginRouteError';\nimport { PluginListener as PluginServerMiddlewareError } from './PluginServerMiddlewareError';\nimport { PluginListener as PluginServerMiddlewareSuccess } from './PluginServerMiddlewareSuccess';\nimport { PluginListener as PluginServerRequest } from './PluginServerRequest';\nimport { PluginListener as PluginServerRouterBranchMethodNotAllowed } from './PluginServerRouterBranchMethodNotAllowed';\nimport { PluginListener as PluginServerRouterBranchNotFound } from './PluginServerRouterBranchNotFound';\nimport { PluginListener as PluginServerRouterFound } from './PluginServerRouterFound';\n\nexport function loadListeners() {\n\tconst store = 'listeners' as const;\n\tvoid container.stores.loadPiece({ name: 'PluginRouteError', piece: PluginRouteError, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerMiddlewareError', piece: PluginServerMiddlewareError, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerMiddlewareSuccess', piece: PluginServerMiddlewareSuccess, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRequest', piece: PluginServerRequest, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRouterBranchMethodNotAllowed', piece: PluginServerRouterBranchMethodNotAllowed, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRouterBranchNotFound', piece: PluginServerRouterBranchNotFound, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRouterFound', piece: PluginServerRouterFound, store });\n}\n"]}
1
+ {"version":3,"sources":["../../../src/listeners/_load.ts"],"names":["container","PluginRouteError","PluginServerMiddlewareError","PluginServerMiddlewareSuccess","PluginServerRequest","PluginServerRouterBranchMethodNotAllowed","PluginServerRouterBranchNotFound","PluginServerRouterFound"],"mappings":";;;;;;;;;;;;;AASO,SAAS,aAAgB,GAAA;AAC/B,EAAA,MAAM,KAAQ,GAAA,WAAA;AACd,EAAK,KAAAA,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,kBAAoB,EAAA,KAAA,EAAOC,mCAAkB,EAAA,KAAA,EAAO,CAAA;AAC5F,EAAK,KAAAD,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,6BAA+B,EAAA,KAAA,EAAOE,8CAA6B,EAAA,KAAA,EAAO,CAAA;AAClH,EAAK,KAAAF,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,+BAAiC,EAAA,KAAA,EAAOG,gDAA+B,EAAA,KAAA,EAAO,CAAA;AACtH,EAAK,KAAAH,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,qBAAuB,EAAA,KAAA,EAAOI,sCAAqB,EAAA,KAAA,EAAO,CAAA;AAClG,EAAK,KAAAJ,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,0CAA4C,EAAA,KAAA,EAAOK,2DAA0C,EAAA,KAAA,EAAO,CAAA;AAC5I,EAAK,KAAAL,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,kCAAoC,EAAA,KAAA,EAAOM,mDAAkC,EAAA,KAAA,EAAO,CAAA;AAC5H,EAAK,KAAAN,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,yBAA2B,EAAA,KAAA,EAAOO,0CAAyB,EAAA,KAAA,EAAO,CAAA;AAC3G;AATgB,MAAA,CAAA,aAAA,EAAA,eAAA,CAAA","file":"_load.cjs","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginListener as PluginRouteError } from './PluginRouteError';\nimport { PluginListener as PluginServerMiddlewareError } from './PluginServerMiddlewareError';\nimport { PluginListener as PluginServerMiddlewareSuccess } from './PluginServerMiddlewareSuccess';\nimport { PluginListener as PluginServerRequest } from './PluginServerRequest';\nimport { PluginListener as PluginServerRouterBranchMethodNotAllowed } from './PluginServerRouterBranchMethodNotAllowed';\nimport { PluginListener as PluginServerRouterBranchNotFound } from './PluginServerRouterBranchNotFound';\nimport { PluginListener as PluginServerRouterFound } from './PluginServerRouterFound';\n\nexport function loadListeners() {\n\tconst store = 'listeners';\n\tvoid container.stores.loadPiece({ name: 'PluginRouteError', piece: PluginRouteError, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerMiddlewareError', piece: PluginServerMiddlewareError, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerMiddlewareSuccess', piece: PluginServerMiddlewareSuccess, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRequest', piece: PluginServerRequest, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRouterBranchMethodNotAllowed', piece: PluginServerRouterBranchMethodNotAllowed, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRouterBranchNotFound', piece: PluginServerRouterBranchNotFound, store });\n\tvoid container.stores.loadPiece({ name: 'PluginServerRouterFound', piece: PluginServerRouterFound, store });\n}\n"]}
@@ -18,5 +18,5 @@ function loadMiddlewares() {
18
18
  __name(loadMiddlewares, "loadMiddlewares");
19
19
 
20
20
  exports.loadMiddlewares = loadMiddlewares;
21
- //# sourceMappingURL=out.js.map
21
+ //# sourceMappingURL=_load.cjs.map
22
22
  //# sourceMappingURL=_load.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/_load.ts"],"names":[],"mappings":";;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB,kBAAkB;AAC/C,SAAS,oBAAoB,kBAAkB;AAC/C,SAAS,oBAAoB,qBAAqB;AAClD,SAAS,oBAAoB,qBAAqB;AAE3C,SAAS,kBAAkB;AACjC,QAAM,QAAQ;AACd,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,QAAQ,OAAO,YAAY,MAAM,CAAC;AAC1E,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,QAAQ,OAAO,YAAY,MAAM,CAAC;AAC1E,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,WAAW,OAAO,eAAe,MAAM,CAAC;AAChF,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,WAAW,OAAO,eAAe,MAAM,CAAC;AACjF;AANgB","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginMiddleware as PluginAuth } from './auth';\nimport { PluginMiddleware as PluginBody } from './body';\nimport { PluginMiddleware as PluginCookies } from './cookies';\nimport { PluginMiddleware as PluginHeaders } from './headers';\n\nexport function loadMiddlewares() {\n\tconst store = 'middlewares' as const;\n\tvoid container.stores.loadPiece({ name: 'auth', piece: PluginAuth, store });\n\tvoid container.stores.loadPiece({ name: 'body', piece: PluginBody, store });\n\tvoid container.stores.loadPiece({ name: 'cookies', piece: PluginCookies, store });\n\tvoid container.stores.loadPiece({ name: 'headers', piece: PluginHeaders, store });\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/_load.ts"],"names":["container","PluginAuth","PluginBody","PluginCookies","PluginHeaders"],"mappings":";;;;;;;;;;AAMO,SAAS,eAAkB,GAAA;AACjC,EAAA,MAAM,KAAQ,GAAA,aAAA;AACd,EAAK,KAAAA,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,MAAQ,EAAA,KAAA,EAAOC,yBAAY,EAAA,KAAA,EAAO,CAAA;AAC1E,EAAK,KAAAD,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,MAAQ,EAAA,KAAA,EAAOE,yBAAY,EAAA,KAAA,EAAO,CAAA;AAC1E,EAAK,KAAAF,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,SAAW,EAAA,KAAA,EAAOG,4BAAe,EAAA,KAAA,EAAO,CAAA;AAChF,EAAK,KAAAH,gBAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,SAAW,EAAA,KAAA,EAAOI,4BAAe,EAAA,KAAA,EAAO,CAAA;AACjF;AANgB,MAAA,CAAA,eAAA,EAAA,iBAAA,CAAA","file":"_load.cjs","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginMiddleware as PluginAuth } from './auth';\nimport { PluginMiddleware as PluginBody } from './body';\nimport { PluginMiddleware as PluginCookies } from './cookies';\nimport { PluginMiddleware as PluginHeaders } from './headers';\n\nexport function loadMiddlewares() {\n\tconst store = 'middlewares';\n\tvoid container.stores.loadPiece({ name: 'auth', piece: PluginAuth, store });\n\tvoid container.stores.loadPiece({ name: 'body', piece: PluginBody, store });\n\tvoid container.stores.loadPiece({ name: 'cookies', piece: PluginCookies, store });\n\tvoid container.stores.loadPiece({ name: 'headers', piece: PluginHeaders, store });\n}\n"]}
@@ -5,7 +5,7 @@ var Middleware_cjs = require('../lib/structures/Middleware.cjs');
5
5
  var __defProp = Object.defineProperty;
6
6
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
9
9
  var _PluginMiddleware = class _PluginMiddleware extends Middleware_cjs.Middleware {
10
10
  constructor(context) {
11
11
  super(context, { position: 40 });
@@ -28,5 +28,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
28
28
  var PluginMiddleware = _PluginMiddleware;
29
29
 
30
30
  exports.PluginMiddleware = PluginMiddleware;
31
- //# sourceMappingURL=out.js.map
31
+ //# sourceMappingURL=auth.cjs.map
32
32
  //# sourceMappingURL=auth.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/auth.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAEpB,IAAM,oBAAN,MAAM,0BAAyB,WAAW;AAAA,EAGzC,YAAY,SAAmC;AACrD,UAAM,SAAS,EAAE,UAAU,GAAG,CAAC;AAHhC,wBAAiB;AAKhB,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,SAAK,aAAa,OAAO,MAAM,UAAU;AACzC,SAAK,UAAU,OAAO,SAAS;AAAA,EAChC;AAAA,EAEgB,IAAI,SAA6B,UAA+B;AAE/E,UAAM,gBAAgB,SAAS,QAAQ,IAAI,KAAK,UAAU;AAC1D,QAAI,CAAC,eAAe;AACnB,cAAQ,OAAO;AACf;AAAA,IACD;AAGA,YAAQ,OAAO,KAAK,UAAU,OAAO,KAAM,QAAQ,aAAa;AAChE,QAAI,QAAQ,SAAS,KAAM,UAAS,QAAQ,OAAO,KAAK,UAAU;AAAA,EACnE;AACD;AAvBiD;AAA1C,IAAM,mBAAN","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly cookieName: string;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 40 });\n\n\t\tconst { server } = this.container;\n\t\tthis.cookieName = server.auth?.cookie ?? 'SAPPHIRE_AUTH';\n\t\tthis.enabled = server.auth !== null;\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\t// If there are no cookies, set auth as null:\n\t\tconst authorization = response.cookies.get(this.cookieName);\n\t\tif (!authorization) {\n\t\t\trequest.auth = null;\n\t\t\treturn;\n\t\t}\n\n\t\t// Decrypt the cookie, and if the token is invalid, remove the cookie:\n\t\trequest.auth = this.container.server.auth!.decrypt(authorization);\n\t\tif (request.auth === null) response.cookies.remove(this.cookieName);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/auth.ts"],"names":["Middleware"],"mappings":";;;;;;;;AAEO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyBA,yBAAW,CAAA;AAAA,EAGzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAHhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,CAAA;AAKhB,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA;AACxB,IAAK,IAAA,CAAA,UAAA,GAAa,MAAO,CAAA,IAAA,EAAM,MAAU,IAAA,eAAA;AACzC,IAAK,IAAA,CAAA,OAAA,GAAU,OAAO,IAAS,KAAA,IAAA;AAAA;AAChC,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAE/E,IAAA,MAAM,aAAgB,GAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,CAAI,KAAK,UAAU,CAAA;AAC1D,IAAA,IAAI,CAAC,aAAe,EAAA;AACnB,MAAA,OAAA,CAAQ,IAAO,GAAA,IAAA;AACf,MAAA;AAAA;AAID,IAAA,OAAA,CAAQ,OAAO,IAAK,CAAA,SAAA,CAAU,MAAO,CAAA,IAAA,CAAM,QAAQ,aAAa,CAAA;AAChE,IAAA,IAAI,QAAQ,IAAS,KAAA,IAAA,WAAe,OAAQ,CAAA,MAAA,CAAO,KAAK,UAAU,CAAA;AAAA;AAEpE,CAAA;AAvBiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"auth.cjs","sourcesContent":["import { Middleware } from '../lib/structures/Middleware';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly cookieName: string;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 40 });\n\n\t\tconst { server } = this.container;\n\t\tthis.cookieName = server.auth?.cookie ?? 'SAPPHIRE_AUTH';\n\t\tthis.enabled = server.auth !== null;\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\t// If there are no cookies, set auth as null:\n\t\tconst authorization = response.cookies.get(this.cookieName);\n\t\tif (!authorization) {\n\t\t\trequest.auth = null;\n\t\t\treturn;\n\t\t}\n\n\t\t// Decrypt the cookie, and if the token is invalid, remove the cookie:\n\t\trequest.auth = this.container.server.auth!.decrypt(authorization);\n\t\tif (request.auth === null) response.cookies.remove(this.cookieName);\n\t}\n}\n"]}
@@ -4,16 +4,12 @@ var HttpCodes_cjs = require('../lib/structures/http/HttpCodes.cjs');
4
4
  var Middleware_cjs = require('../lib/structures/Middleware.cjs');
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
10
8
  var _PluginMiddleware = class _PluginMiddleware extends Middleware_cjs.Middleware {
11
9
  constructor(context) {
12
10
  super(context, { position: 20 });
13
- __publicField(this, "mediaParsers");
14
- this.mediaParsers = this.container.server.mediaParsers;
15
11
  }
16
- async run(request, response) {
12
+ run(request, response) {
17
13
  if (!request.route) return;
18
14
  const contentType = request.headers["content-type"];
19
15
  if (typeof contentType !== "string") return;
@@ -23,18 +19,6 @@ var _PluginMiddleware = class _PluginMiddleware extends Middleware_cjs.Middlewar
23
19
  const maximumLength = request.route.maximumBodyLength;
24
20
  if (length > maximumLength) {
25
21
  response.status(HttpCodes_cjs.HttpCodes.PayloadTooLarge).json({ error: "Exceeded maximum content length." });
26
- return;
27
- }
28
- const type = this.mediaParsers.parseContentType(contentType);
29
- const parser = this.mediaParsers.get(type);
30
- if (!parser || !parser.accepts(request.route)) {
31
- response.status(HttpCodes_cjs.HttpCodes.UnsupportedMediaType).json({ error: `Unsupported type ${type}.` });
32
- return;
33
- }
34
- try {
35
- request.body = await parser.run(request);
36
- } catch {
37
- response.status(HttpCodes_cjs.HttpCodes.BadRequest).json({ error: `Cannot parse ${type} data.` });
38
22
  }
39
23
  }
40
24
  };
@@ -42,5 +26,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
42
26
  var PluginMiddleware = _PluginMiddleware;
43
27
 
44
28
  exports.PluginMiddleware = PluginMiddleware;
45
- //# sourceMappingURL=out.js.map
29
+ //# sourceMappingURL=body.cjs.map
46
30
  //# sourceMappingURL=body.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/body.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,iBAAiB;AAE1B,SAAS,kBAAkB;AAEpB,IAAM,oBAAN,MAAM,0BAAyB,WAAW;AAAA,EAGzC,YAAY,SAAmC;AACrD,UAAM,SAAS,EAAE,UAAU,GAAG,CAAC;AAHhC,wBAAiB;AAIhB,SAAK,eAAe,KAAK,UAAU,OAAO;AAAA,EAC3C;AAAA,EAEA,MAAsB,IAAI,SAA6B,UAA+B;AACrF,QAAI,CAAC,QAAQ,MAAO;AAGpB,UAAM,cAAc,QAAQ,QAAQ,cAAc;AAClD,QAAI,OAAO,gBAAgB,SAAU;AAGrC,UAAM,eAAe,QAAQ,QAAQ,gBAAgB;AACrD,QAAI,OAAO,iBAAiB,SAAU;AAGtC,UAAM,SAAS,OAAO,YAAY;AAClC,UAAM,gBAAgB,QAAQ,MAAM;AACpC,QAAI,SAAS,eAAe;AAC3B,eAAS,OAAO,UAAU,eAAe,EAAE,KAAK,EAAE,OAAO,mCAAmC,CAAC;AAC7F;AAAA,IACD;AAGA,UAAM,OAAO,KAAK,aAAa,iBAAiB,WAAW;AAC3D,UAAM,SAAS,KAAK,aAAa,IAAI,IAAI;AACzC,QAAI,CAAC,UAAU,CAAC,OAAO,QAAQ,QAAQ,KAAK,GAAG;AAC9C,eAAS,OAAO,UAAU,oBAAoB,EAAE,KAAK,EAAE,OAAO,oBAAoB,IAAI,IAAI,CAAC;AAC3F;AAAA,IACD;AAEA,QAAI;AAEH,cAAQ,OAAO,MAAM,OAAO,IAAI,OAAO;AAAA,IACxC,QAAQ;AACP,eAAS,OAAO,UAAU,UAAU,EAAE,KAAK,EAAE,OAAO,gBAAgB,IAAI,SAAS,CAAC;AAAA,IACnF;AAAA,EACD;AACD;AA1CiD;AAA1C,IAAM,mBAAN","sourcesContent":["import { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport type { MediaParserStore } from '../lib/structures/MediaParserStore';\nimport { Middleware } from '../lib/structures/Middleware';\n\nexport class PluginMiddleware extends Middleware {\n\tprivate readonly mediaParsers: MediaParserStore;\n\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 20 });\n\t\tthis.mediaParsers = this.container.server.mediaParsers;\n\t}\n\n\tpublic override async run(request: Middleware.Request, response: Middleware.Response) {\n\t\tif (!request.route) return;\n\n\t\t// RFC 1341 4.\n\t\tconst contentType = request.headers['content-type'];\n\t\tif (typeof contentType !== 'string') return;\n\n\t\t// RFC 7230 3.3.2.\n\t\tconst lengthString = request.headers['content-length'];\n\t\tif (typeof lengthString !== 'string') return;\n\n\t\t// Verify if the content length is lower than accepted:\n\t\tconst length = Number(lengthString);\n\t\tconst maximumLength = request.route.maximumBodyLength;\n\t\tif (length > maximumLength) {\n\t\t\tresponse.status(HttpCodes.PayloadTooLarge).json({ error: 'Exceeded maximum content length.' });\n\t\t\treturn;\n\t\t}\n\n\t\t// Verify if the content type is supported by the parser:\n\t\tconst type = this.mediaParsers.parseContentType(contentType);\n\t\tconst parser = this.mediaParsers.get(type);\n\t\tif (!parser || !parser.accepts(request.route)) {\n\t\t\tresponse.status(HttpCodes.UnsupportedMediaType).json({ error: `Unsupported type ${type}.` });\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Parse the content body:\n\t\t\trequest.body = await parser.run(request);\n\t\t} catch {\n\t\t\tresponse.status(HttpCodes.BadRequest).json({ error: `Cannot parse ${type} data.` });\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/middlewares/body.ts"],"names":["Middleware","HttpCodes"],"mappings":";;;;;;;AAGO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyBA,yBAAW,CAAA;AAAA,EACzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA;AAAA;AAChC,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAC/E,IAAI,IAAA,CAAC,QAAQ,KAAO,EAAA;AAGpB,IAAM,MAAA,WAAA,GAAc,OAAQ,CAAA,OAAA,CAAQ,cAAc,CAAA;AAClD,IAAI,IAAA,OAAO,gBAAgB,QAAU,EAAA;AAGrC,IAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,gBAAgB,CAAA;AACrD,IAAI,IAAA,OAAO,iBAAiB,QAAU,EAAA;AAGtC,IAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA;AAClC,IAAM,MAAA,aAAA,GAAgB,QAAQ,KAAM,CAAA,iBAAA;AACpC,IAAA,IAAI,SAAS,aAAe,EAAA;AAC3B,MAAS,QAAA,CAAA,MAAA,CAAOC,wBAAU,eAAe,CAAA,CAAE,KAAK,EAAE,KAAA,EAAO,oCAAoC,CAAA;AAAA;AAC9F;AAEF,CAAA;AAvBiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"body.cjs","sourcesContent":["import { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { Middleware } from '../lib/structures/Middleware';\n\nexport class PluginMiddleware extends Middleware {\n\tpublic constructor(context: Middleware.LoaderContext) {\n\t\tsuper(context, { position: 20 });\n\t}\n\n\tpublic override run(request: Middleware.Request, response: Middleware.Response) {\n\t\tif (!request.route) return;\n\n\t\t// RFC 1341 4.\n\t\tconst contentType = request.headers['content-type'];\n\t\tif (typeof contentType !== 'string') return;\n\n\t\t// RFC 7230 3.3.2.\n\t\tconst lengthString = request.headers['content-length'];\n\t\tif (typeof lengthString !== 'string') return;\n\n\t\t// Verify if the content length is lower than accepted:\n\t\tconst length = Number(lengthString);\n\t\tconst maximumLength = request.route.maximumBodyLength;\n\t\tif (length > maximumLength) {\n\t\t\tresponse.status(HttpCodes.PayloadTooLarge).json({ error: 'Exceeded maximum content length.' });\n\t\t}\n\t}\n}\n"]}
@@ -23,5 +23,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
23
23
  var PluginMiddleware = _PluginMiddleware;
24
24
 
25
25
  exports.PluginMiddleware = PluginMiddleware;
26
- //# sourceMappingURL=out.js.map
26
+ //# sourceMappingURL=cookies.cjs.map
27
27
  //# sourceMappingURL=cookies.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/cookies.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAErB,IAAM,oBAAN,MAAM,0BAAyB,WAAW;AAAA,EAIzC,YAAY,SAAmC;AACrD,UAAM,SAAS,EAAE,UAAU,GAAG,CAAC;AAJhC,wBAAiB,cAAsB,QAAQ,IAAI,aAAa;AAChE,wBAAQ,mBAAiC;AAKxC,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,SAAK,kBAAkB,OAAO,MAAM,mBAAmB;AAAA,EACxD;AAAA,EAEgB,IAAI,SAA6B,UAA+B;AAC/E,aAAS,UAAU,IAAI,YAAY,SAAS,UAAU,KAAK,YAAY,KAAK,eAAe;AAAA,EAC5F;AACD;AAdiD;AAA1C,IAAM,mBAAN","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,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"]}
@@ -62,5 +62,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
62
62
  var PluginMiddleware = _PluginMiddleware;
63
63
 
64
64
  exports.PluginMiddleware = PluginMiddleware;
65
- //# sourceMappingURL=out.js.map
65
+ //# sourceMappingURL=headers.cjs.map
66
66
  //# sourceMappingURL=headers.cjs.map