@sapphire/plugin-api 7.0.0-next.a34a933 → 7.0.0-next.c2464a5

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 (174) hide show
  1. package/README.md +0 -1
  2. package/dist/cjs/index.cjs +2 -9
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.d.cts +17 -33
  5. package/dist/cjs/lib/structures/Augmentations.d.cjs +1 -1
  6. package/dist/cjs/lib/structures/Augmentations.d.cjs.map +1 -1
  7. package/dist/cjs/lib/structures/MediaParser.cjs +1 -1
  8. package/dist/cjs/lib/structures/MediaParser.cjs.map +1 -1
  9. package/dist/cjs/lib/structures/MediaParserStore.cjs +1 -1
  10. package/dist/cjs/lib/structures/MediaParserStore.cjs.map +1 -1
  11. package/dist/cjs/lib/structures/Middleware.cjs +2 -2
  12. package/dist/cjs/lib/structures/Middleware.cjs.map +1 -1
  13. package/dist/cjs/lib/structures/MiddlewareStore.cjs +2 -2
  14. package/dist/cjs/lib/structures/MiddlewareStore.cjs.map +1 -1
  15. package/dist/cjs/lib/structures/Route.cjs +1 -1
  16. package/dist/cjs/lib/structures/Route.cjs.map +1 -1
  17. package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs +1 -1
  18. package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs.map +1 -1
  19. package/dist/cjs/lib/structures/RouteStore.cjs +2 -2
  20. package/dist/cjs/lib/structures/RouteStore.cjs.map +1 -1
  21. package/dist/cjs/lib/structures/api/ApiRequest.cjs +1 -1
  22. package/dist/cjs/lib/structures/api/ApiRequest.cjs.map +1 -1
  23. package/dist/cjs/lib/structures/api/ApiResponse.cjs +6 -7
  24. package/dist/cjs/lib/structures/api/ApiResponse.cjs.map +1 -1
  25. package/dist/cjs/lib/structures/api/CookieStore.cjs +1 -1
  26. package/dist/cjs/lib/structures/api/CookieStore.cjs.map +1 -1
  27. package/dist/cjs/lib/structures/http/Auth.cjs +2 -2
  28. package/dist/cjs/lib/structures/http/Auth.cjs.map +1 -1
  29. package/dist/cjs/lib/structures/http/HttpCodes.cjs +1 -1
  30. package/dist/cjs/lib/structures/http/HttpCodes.cjs.map +1 -1
  31. package/dist/cjs/lib/structures/http/HttpMethods.cjs +1 -1
  32. package/dist/cjs/lib/structures/http/HttpMethods.cjs.map +1 -1
  33. package/dist/cjs/lib/structures/http/Server.cjs +1 -1
  34. package/dist/cjs/lib/structures/http/Server.cjs.map +1 -1
  35. package/dist/cjs/lib/structures/router/RouterBranch.cjs +1 -1
  36. package/dist/cjs/lib/structures/router/RouterBranch.cjs.map +1 -1
  37. package/dist/cjs/lib/structures/router/RouterNode.cjs +2 -2
  38. package/dist/cjs/lib/structures/router/RouterNode.cjs.map +1 -1
  39. package/dist/cjs/lib/structures/router/RouterRoot.cjs +1 -1
  40. package/dist/cjs/lib/structures/router/RouterRoot.cjs.map +1 -1
  41. package/dist/cjs/lib/utils/MimeType.cjs +4 -0
  42. package/dist/cjs/lib/utils/MimeType.cjs.map +1 -0
  43. package/dist/cjs/listeners/PluginRouteError.cjs +1 -1
  44. package/dist/cjs/listeners/PluginRouteError.cjs.map +1 -1
  45. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs +1 -1
  46. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs.map +1 -1
  47. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs +1 -1
  48. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs.map +1 -1
  49. package/dist/cjs/listeners/PluginServerRequest.cjs +2 -2
  50. package/dist/cjs/listeners/PluginServerRequest.cjs.map +1 -1
  51. package/dist/cjs/listeners/PluginServerRouterBranchMethodNotAllowed.cjs +1 -1
  52. package/dist/cjs/listeners/PluginServerRouterBranchMethodNotAllowed.cjs.map +1 -1
  53. package/dist/cjs/listeners/PluginServerRouterBranchNotFound.cjs +1 -1
  54. package/dist/cjs/listeners/PluginServerRouterBranchNotFound.cjs.map +1 -1
  55. package/dist/cjs/listeners/PluginServerRouterFound.cjs +3 -2
  56. package/dist/cjs/listeners/PluginServerRouterFound.cjs.map +1 -1
  57. package/dist/cjs/listeners/_load.cjs +1 -1
  58. package/dist/cjs/listeners/_load.cjs.map +1 -1
  59. package/dist/cjs/mediaParsers/_load.cjs +1 -1
  60. package/dist/cjs/mediaParsers/_load.cjs.map +1 -1
  61. package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs +2 -3
  62. package/dist/cjs/mediaParsers/applicationFormUrlEncoded.cjs.map +1 -1
  63. package/dist/cjs/mediaParsers/applicationJson.cjs +2 -3
  64. package/dist/cjs/mediaParsers/applicationJson.cjs.map +1 -1
  65. package/dist/cjs/mediaParsers/textPlain.cjs +2 -3
  66. package/dist/cjs/mediaParsers/textPlain.cjs.map +1 -1
  67. package/dist/cjs/middlewares/_load.cjs +1 -1
  68. package/dist/cjs/middlewares/_load.cjs.map +1 -1
  69. package/dist/cjs/middlewares/auth.cjs +2 -2
  70. package/dist/cjs/middlewares/auth.cjs.map +1 -1
  71. package/dist/cjs/middlewares/body.cjs +2 -2
  72. package/dist/cjs/middlewares/body.cjs.map +1 -1
  73. package/dist/cjs/middlewares/cookies.cjs +1 -1
  74. package/dist/cjs/middlewares/cookies.cjs.map +1 -1
  75. package/dist/cjs/middlewares/headers.cjs +1 -1
  76. package/dist/cjs/middlewares/headers.cjs.map +1 -1
  77. package/dist/cjs/register.cjs +1 -1
  78. package/dist/cjs/register.cjs.map +1 -1
  79. package/dist/cjs/routes/_load.cjs +1 -1
  80. package/dist/cjs/routes/_load.cjs.map +1 -1
  81. package/dist/cjs/routes/oauth/callback.post.cjs +2 -2
  82. package/dist/cjs/routes/oauth/callback.post.cjs.map +1 -1
  83. package/dist/cjs/routes/oauth/logout.post.cjs +1 -1
  84. package/dist/cjs/routes/oauth/logout.post.cjs.map +1 -1
  85. package/dist/esm/chunk-S573YWRP.mjs +1 -1
  86. package/dist/esm/chunk-S573YWRP.mjs.map +1 -1
  87. package/dist/esm/index.d.mts +17 -33
  88. package/dist/esm/index.mjs +2 -3
  89. package/dist/esm/index.mjs.map +1 -1
  90. package/dist/esm/lib/structures/Augmentations.d.mjs +1 -1
  91. package/dist/esm/lib/structures/Augmentations.d.mjs.map +1 -1
  92. package/dist/esm/lib/structures/MediaParser.mjs +1 -1
  93. package/dist/esm/lib/structures/MediaParser.mjs.map +1 -1
  94. package/dist/esm/lib/structures/MediaParserStore.mjs +1 -1
  95. package/dist/esm/lib/structures/MediaParserStore.mjs.map +1 -1
  96. package/dist/esm/lib/structures/Middleware.mjs +1 -1
  97. package/dist/esm/lib/structures/Middleware.mjs.map +1 -1
  98. package/dist/esm/lib/structures/MiddlewareStore.mjs +1 -1
  99. package/dist/esm/lib/structures/MiddlewareStore.mjs.map +1 -1
  100. package/dist/esm/lib/structures/Route.mjs +1 -1
  101. package/dist/esm/lib/structures/Route.mjs.map +1 -1
  102. package/dist/esm/lib/structures/RouteLoaderStrategy.mjs +1 -1
  103. package/dist/esm/lib/structures/RouteLoaderStrategy.mjs.map +1 -1
  104. package/dist/esm/lib/structures/RouteStore.mjs +1 -1
  105. package/dist/esm/lib/structures/RouteStore.mjs.map +1 -1
  106. package/dist/esm/lib/structures/api/ApiRequest.mjs +1 -1
  107. package/dist/esm/lib/structures/api/ApiRequest.mjs.map +1 -1
  108. package/dist/esm/lib/structures/api/ApiResponse.mjs +5 -6
  109. package/dist/esm/lib/structures/api/ApiResponse.mjs.map +1 -1
  110. package/dist/esm/lib/structures/api/CookieStore.mjs +1 -1
  111. package/dist/esm/lib/structures/api/CookieStore.mjs.map +1 -1
  112. package/dist/esm/lib/structures/http/Auth.mjs +1 -1
  113. package/dist/esm/lib/structures/http/Auth.mjs.map +1 -1
  114. package/dist/esm/lib/structures/http/HttpCodes.mjs +1 -1
  115. package/dist/esm/lib/structures/http/HttpCodes.mjs.map +1 -1
  116. package/dist/esm/lib/structures/http/HttpMethods.mjs +1 -1
  117. package/dist/esm/lib/structures/http/HttpMethods.mjs.map +1 -1
  118. package/dist/esm/lib/structures/http/Server.mjs +1 -1
  119. package/dist/esm/lib/structures/http/Server.mjs.map +1 -1
  120. package/dist/esm/lib/structures/router/RouterBranch.mjs +1 -1
  121. package/dist/esm/lib/structures/router/RouterBranch.mjs.map +1 -1
  122. package/dist/esm/lib/structures/router/RouterNode.mjs +1 -1
  123. package/dist/esm/lib/structures/router/RouterNode.mjs.map +1 -1
  124. package/dist/esm/lib/structures/router/RouterRoot.mjs +1 -1
  125. package/dist/esm/lib/structures/router/RouterRoot.mjs.map +1 -1
  126. package/dist/esm/lib/utils/MimeType.mjs +3 -0
  127. package/dist/esm/lib/utils/MimeType.mjs.map +1 -0
  128. package/dist/esm/listeners/PluginRouteError.mjs +1 -1
  129. package/dist/esm/listeners/PluginRouteError.mjs.map +1 -1
  130. package/dist/esm/listeners/PluginServerMiddlewareError.mjs +1 -1
  131. package/dist/esm/listeners/PluginServerMiddlewareError.mjs.map +1 -1
  132. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs +1 -1
  133. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs.map +1 -1
  134. package/dist/esm/listeners/PluginServerRequest.mjs +2 -2
  135. package/dist/esm/listeners/PluginServerRequest.mjs.map +1 -1
  136. package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs +1 -1
  137. package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs.map +1 -1
  138. package/dist/esm/listeners/PluginServerRouterBranchNotFound.mjs +1 -1
  139. package/dist/esm/listeners/PluginServerRouterBranchNotFound.mjs.map +1 -1
  140. package/dist/esm/listeners/PluginServerRouterFound.mjs +3 -2
  141. package/dist/esm/listeners/PluginServerRouterFound.mjs.map +1 -1
  142. package/dist/esm/listeners/_load.mjs +1 -1
  143. package/dist/esm/listeners/_load.mjs.map +1 -1
  144. package/dist/esm/mediaParsers/_load.mjs +1 -1
  145. package/dist/esm/mediaParsers/_load.mjs.map +1 -1
  146. package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs +2 -3
  147. package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs.map +1 -1
  148. package/dist/esm/mediaParsers/applicationJson.mjs +2 -3
  149. package/dist/esm/mediaParsers/applicationJson.mjs.map +1 -1
  150. package/dist/esm/mediaParsers/textPlain.mjs +2 -3
  151. package/dist/esm/mediaParsers/textPlain.mjs.map +1 -1
  152. package/dist/esm/middlewares/_load.mjs +1 -1
  153. package/dist/esm/middlewares/_load.mjs.map +1 -1
  154. package/dist/esm/middlewares/auth.mjs +1 -1
  155. package/dist/esm/middlewares/auth.mjs.map +1 -1
  156. package/dist/esm/middlewares/body.mjs +1 -1
  157. package/dist/esm/middlewares/body.mjs.map +1 -1
  158. package/dist/esm/middlewares/cookies.mjs +1 -1
  159. package/dist/esm/middlewares/cookies.mjs.map +1 -1
  160. package/dist/esm/middlewares/headers.mjs +1 -1
  161. package/dist/esm/middlewares/headers.mjs.map +1 -1
  162. package/dist/esm/register.mjs +1 -1
  163. package/dist/esm/register.mjs.map +1 -1
  164. package/dist/esm/routes/_load.mjs +1 -1
  165. package/dist/esm/routes/_load.mjs.map +1 -1
  166. package/dist/esm/routes/oauth/callback.post.mjs +1 -1
  167. package/dist/esm/routes/oauth/callback.post.mjs.map +1 -1
  168. package/dist/esm/routes/oauth/logout.post.mjs +1 -1
  169. package/dist/esm/routes/oauth/logout.post.mjs.map +1 -1
  170. package/package.json +9 -8
  171. package/dist/cjs/lib/utils/MimeTypes.cjs +0 -26
  172. package/dist/cjs/lib/utils/MimeTypes.cjs.map +0 -1
  173. package/dist/esm/lib/utils/MimeTypes.mjs +0 -26
  174. package/dist/esm/lib/utils/MimeTypes.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/structures/router/RouterBranch.ts"],"names":["branch"],"mappings":";;;;;;AAAA,SAAS,iBAAiB;AAE1B,SAAS,kBAAkB;AAEpB,IAAM,gBAAN,MAAM,cAAa;AAAA,EA6BlB,YAAY,MAAc,SAAkB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["import { isNullish } from '@sapphire/utilities';\nimport type { Route } from '../Route';\nimport { RouterNode } from './RouterNode';\n\nexport class RouterBranch {\n\t/**\n\t * The name of the branch.\n\t */\n\tpublic readonly name: string;\n\n\t/**\n\t * Whether or not the branch is dynamic.\n\t */\n\tpublic readonly dynamic: boolean;\n\n\t/**\n\t * The parent branch, if any.\n\t */\n\tpublic readonly parent: RouterBranch | null;\n\n\t/**\n\t * The node this branch is associated with.\n\t */\n\tpublic readonly node = new RouterNode(this);\n\n\t/**\n\t * The methods supported by the branch's node or any of its children.\n\t */\n\tpublic supportedMethods: readonly string[] = [];\n\n\tprivate _staticChildren: RouterBranch[] = [];\n\tprivate _dynamicChild: RouterBranch | null = null;\n\n\tpublic constructor(name: string, dynamic: boolean, parent: RouterBranch | null) {\n\t\tthis.name = name;\n\t\tthis.dynamic = dynamic;\n\t\tthis.parent = parent;\n\t}\n\n\t/**\n\t * The path representing this branch\n\t * @version 7.0.0\n\t */\n\tpublic get path(): string {\n\t\treturn this.parent ? `${this.parent}/${this}` : `${this}`;\n\t}\n\n\t/**\n\t * The branches the branch is associated with\n\t * @version 7.0.0\n\t */\n\tpublic get children(): RouterBranch[] {\n\t\treturn this._staticChildren.concat(this._dynamicChild ?? []);\n\t}\n\n\t/**\n\t * Whether or not the branch is empty\n\t * @version 7.0.0\n\t */\n\tpublic get empty(): boolean {\n\t\treturn this._staticChildren.length === 0 && this._dynamicChild === null;\n\t}\n\n\t/**\n\t * Tries to find a branch given a path\n\t * @version 7.0.0\n\t *\n\t * @param parts The parts of a path to find a node from\n\t * @returns The branch found, or null if not found\n\t */\n\tpublic find(parts: readonly string[]): RouterBranch | null {\n\t\treturn this._find(parts, 0);\n\t}\n\n\t/**\n\t * Checks if the given name matches the branch\n\t * @version 7.0.0\n\t *\n\t * @param name The name to match\n\t * @returns Whether or not the branch matches the name\n\t */\n\tpublic matches(name: string): boolean {\n\t\treturn this.dynamic || this.name === name;\n\t}\n\n\t/**\n\t * Returns the string representation of the branch\n\t * @version 7.0.0\n\t *\n\t * @returns The string representation of the branch\n\t */\n\tpublic toString(): string {\n\t\treturn this.dynamic ? `[${this.name}]` : this.name;\n\t}\n\n\tpublic *nodes(): IterableIterator<RouterNode> {\n\t\tyield this.node;\n\t\tfor (const child of this._staticChildren) {\n\t\t\tyield* child.nodes();\n\t\t}\n\n\t\tif (this._dynamicChild) {\n\t\t\tyield* this._dynamicChild.nodes();\n\t\t}\n\t}\n\n\tprotected _add(parts: readonly string[], index: number, route: Route): RouterNode {\n\t\tconst result = this._performAdd(parts, index, route);\n\t\tthis._updateSupportedChildrenMethods();\n\t\treturn result;\n\t}\n\n\tprotected _remove(parts: readonly string[], index: number, route: Route): boolean {\n\t\tconst result = this._performRemove(parts, index, route);\n\t\tif (result) this._updateSupportedChildrenMethods();\n\t\treturn result;\n\t}\n\n\tprotected _performAdd(parts: readonly string[], index: number, route: Route): RouterNode {\n\t\tif (index >= parts.length) {\n\t\t\tfor (const method of route.methods) {\n\t\t\t\tthis.node.set(method, route);\n\t\t\t}\n\n\t\t\treturn this.node;\n\t\t}\n\n\t\tconst part = parts[index];\n\t\tconst child = this._staticChildren.find((branch) => branch.matches(part));\n\t\tif (child) {\n\t\t\treturn child._add(parts, index + 1, route);\n\t\t}\n\n\t\tif (this._dynamicChild) {\n\t\t\treturn this._dynamicChild._add(parts, index + 1, route);\n\t\t}\n\n\t\tconst dynamic = part.startsWith('[') && part.endsWith(']');\n\t\tlet branch: RouterBranch;\n\t\tif (dynamic) {\n\t\t\tbranch = new RouterBranch(part.slice(1, -1), true, this);\n\t\t\tthis._dynamicChild = branch;\n\t\t} else {\n\t\t\tbranch = new RouterBranch(part, false, this);\n\t\t\tthis._staticChildren.push(branch);\n\t\t}\n\n\t\treturn branch._add(parts, index + 1, route);\n\t}\n\n\tprotected _performRemove(parts: readonly string[], index: number, route: Route): boolean {\n\t\tif (index >= parts.length) {\n\t\t\tlet success = false;\n\t\t\tfor (const method of route.methods) {\n\t\t\t\tif (this.node.delete(method, route)) {\n\t\t\t\t\tsuccess = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn success;\n\t\t}\n\n\t\tconst part = parts[index];\n\t\tconst staticChildIndex = this._staticChildren.findIndex((branch) => branch.matches(part));\n\t\tif (staticChildIndex === -1) {\n\t\t\tconst child = this._staticChildren[index];\n\t\t\tconst removed = child._remove(parts, index + 1, route);\n\t\t\tif (removed && child.empty) {\n\t\t\t\tthis._staticChildren = this._staticChildren.filter((branch) => branch !== child);\n\t\t\t}\n\n\t\t\treturn removed;\n\t\t}\n\n\t\tif (this._dynamicChild) {\n\t\t\tconst removed = this._dynamicChild._remove(parts, index + 1, route);\n\t\t\tif (removed && this._dynamicChild.empty) {\n\t\t\t\tthis._dynamicChild = null;\n\t\t\t}\n\n\t\t\treturn removed;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprotected _find(parts: readonly string[], index: number): RouterBranch | null {\n\t\tif (index >= parts.length) return this;\n\n\t\tconst part = parts[index];\n\t\tconst child = this._staticChildren.find((branch) => branch.matches(part)) ?? this._dynamicChild;\n\n\t\t// If a child is not found, return null:\n\t\tif (isNullish(child)) return null;\n\n\t\t// Continue the search:\n\t\treturn child._find(parts, index + 1);\n\t}\n\n\tprotected _updateSupportedChildrenMethods(): void {\n\t\tconst methods = new Set(this.node.methods());\n\t\tfor (const child of this.children) {\n\t\t\tfor (const method of child.node.methods()) {\n\t\t\t\tmethods.add(method);\n\t\t\t}\n\t\t}\n\n\t\tthis.supportedMethods = [...methods];\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../../../src/lib/structures/router/RouterBranch.ts"],"names":["branch"],"mappings":";;;;AAIO,IAAM,aAAA,GAAN,MAAM,aAAa,CAAA;AAAA,EA6BlB,WAAA,CAAY,IAAc,EAAA,OAAA,EAAkB,MAA6B,EAAA;AAzBhF;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA,CAAA;AAKhB;AAAA;AAAA;AAAA,IAA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ch.mjs","sourcesContent":["import { isNullish } from '@sapphire/utilities';\nimport type { Route } from '../Route';\nimport { RouterNode } from './RouterNode';\n\nexport class RouterBranch {\n\t/**\n\t * The name of the branch.\n\t */\n\tpublic readonly name: string;\n\n\t/**\n\t * Whether or not the branch is dynamic.\n\t */\n\tpublic readonly dynamic: boolean;\n\n\t/**\n\t * The parent branch, if any.\n\t */\n\tpublic readonly parent: RouterBranch | null;\n\n\t/**\n\t * The node this branch is associated with.\n\t */\n\tpublic readonly node = new RouterNode(this);\n\n\t/**\n\t * The methods supported by the branch's node or any of its children.\n\t */\n\tpublic supportedMethods: readonly string[] = [];\n\n\tprivate _staticChildren: RouterBranch[] = [];\n\tprivate _dynamicChild: RouterBranch | null = null;\n\n\tpublic constructor(name: string, dynamic: boolean, parent: RouterBranch | null) {\n\t\tthis.name = name;\n\t\tthis.dynamic = dynamic;\n\t\tthis.parent = parent;\n\t}\n\n\t/**\n\t * The path representing this branch\n\t * @version 7.0.0\n\t */\n\tpublic get path(): string {\n\t\treturn this.parent ? `${this.parent}/${this}` : `${this}`;\n\t}\n\n\t/**\n\t * The branches the branch is associated with\n\t * @version 7.0.0\n\t */\n\tpublic get children(): RouterBranch[] {\n\t\treturn this._staticChildren.concat(this._dynamicChild ?? []);\n\t}\n\n\t/**\n\t * Whether or not the branch is empty\n\t * @version 7.0.0\n\t */\n\tpublic get empty(): boolean {\n\t\treturn this._staticChildren.length === 0 && this._dynamicChild === null;\n\t}\n\n\t/**\n\t * Tries to find a branch given a path\n\t * @version 7.0.0\n\t *\n\t * @param parts The parts of a path to find a node from\n\t * @returns The branch found, or null if not found\n\t */\n\tpublic find(parts: readonly string[]): RouterBranch | null {\n\t\treturn this._find(parts, 0);\n\t}\n\n\t/**\n\t * Checks if the given name matches the branch\n\t * @version 7.0.0\n\t *\n\t * @param name The name to match\n\t * @returns Whether or not the branch matches the name\n\t */\n\tpublic matches(name: string): boolean {\n\t\treturn this.dynamic || this.name === name;\n\t}\n\n\t/**\n\t * Returns the string representation of the branch\n\t * @version 7.0.0\n\t *\n\t * @returns The string representation of the branch\n\t */\n\tpublic toString(): string {\n\t\treturn this.dynamic ? `[${this.name}]` : this.name;\n\t}\n\n\tpublic *nodes(): IterableIterator<RouterNode> {\n\t\tyield this.node;\n\t\tfor (const child of this._staticChildren) {\n\t\t\tyield* child.nodes();\n\t\t}\n\n\t\tif (this._dynamicChild) {\n\t\t\tyield* this._dynamicChild.nodes();\n\t\t}\n\t}\n\n\tprotected _add(parts: readonly string[], index: number, route: Route): RouterNode {\n\t\tconst result = this._performAdd(parts, index, route);\n\t\tthis._updateSupportedChildrenMethods();\n\t\treturn result;\n\t}\n\n\tprotected _remove(parts: readonly string[], index: number, route: Route): boolean {\n\t\tconst result = this._performRemove(parts, index, route);\n\t\tif (result) this._updateSupportedChildrenMethods();\n\t\treturn result;\n\t}\n\n\tprotected _performAdd(parts: readonly string[], index: number, route: Route): RouterNode {\n\t\tif (index >= parts.length) {\n\t\t\tfor (const method of route.methods) {\n\t\t\t\tthis.node.set(method, route);\n\t\t\t}\n\n\t\t\treturn this.node;\n\t\t}\n\n\t\tconst part = parts[index];\n\t\tconst child = this._staticChildren.find((branch) => branch.matches(part));\n\t\tif (child) {\n\t\t\treturn child._add(parts, index + 1, route);\n\t\t}\n\n\t\tif (this._dynamicChild) {\n\t\t\treturn this._dynamicChild._add(parts, index + 1, route);\n\t\t}\n\n\t\tconst dynamic = part.startsWith('[') && part.endsWith(']');\n\t\tlet branch: RouterBranch;\n\t\tif (dynamic) {\n\t\t\tbranch = new RouterBranch(part.slice(1, -1), true, this);\n\t\t\tthis._dynamicChild = branch;\n\t\t} else {\n\t\t\tbranch = new RouterBranch(part, false, this);\n\t\t\tthis._staticChildren.push(branch);\n\t\t}\n\n\t\treturn branch._add(parts, index + 1, route);\n\t}\n\n\tprotected _performRemove(parts: readonly string[], index: number, route: Route): boolean {\n\t\tif (index >= parts.length) {\n\t\t\tlet success = false;\n\t\t\tfor (const method of route.methods) {\n\t\t\t\tif (this.node.delete(method, route)) {\n\t\t\t\t\tsuccess = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn success;\n\t\t}\n\n\t\tconst part = parts[index];\n\t\tconst staticChildIndex = this._staticChildren.findIndex((branch) => branch.matches(part));\n\t\tif (staticChildIndex === -1) {\n\t\t\tconst child = this._staticChildren[index];\n\t\t\tconst removed = child._remove(parts, index + 1, route);\n\t\t\tif (removed && child.empty) {\n\t\t\t\tthis._staticChildren = this._staticChildren.filter((branch) => branch !== child);\n\t\t\t}\n\n\t\t\treturn removed;\n\t\t}\n\n\t\tif (this._dynamicChild) {\n\t\t\tconst removed = this._dynamicChild._remove(parts, index + 1, route);\n\t\t\tif (removed && this._dynamicChild.empty) {\n\t\t\t\tthis._dynamicChild = null;\n\t\t\t}\n\n\t\t\treturn removed;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprotected _find(parts: readonly string[], index: number): RouterBranch | null {\n\t\tif (index >= parts.length) return this;\n\n\t\tconst part = parts[index];\n\t\tconst child = this._staticChildren.find((branch) => branch.matches(part)) ?? this._dynamicChild;\n\n\t\t// If a child is not found, return null:\n\t\tif (isNullish(child)) return null;\n\n\t\t// Continue the search:\n\t\treturn child._find(parts, index + 1);\n\t}\n\n\tprotected _updateSupportedChildrenMethods(): void {\n\t\tconst methods = new Set(this.node.methods());\n\t\tfor (const child of this.children) {\n\t\t\tfor (const method of child.node.methods()) {\n\t\t\t\tmethods.add(method);\n\t\t\t}\n\t\t}\n\n\t\tthis.supportedMethods = [...methods];\n\t}\n}\n"]}
@@ -52,5 +52,5 @@ __name(_RouterNode, "RouterNode");
52
52
  var RouterNode = _RouterNode;
53
53
 
54
54
  export { RouterNode };
55
- //# sourceMappingURL=out.js.map
55
+ //# sourceMappingURL=RouterNode.mjs.map
56
56
  //# sourceMappingURL=RouterNode.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/structures/router/RouterNode.ts"],"names":[],"mappings":";;;;;;;;AAAA,SAAS,kBAAkB;AAA3B;AAKO,IAAM,cAAN,MAAM,YAAW;AAAA,EAWhB,YAAY,QAAsB;AAPzC;AAAA;AAAA;AAAA,wBAAgB;AAKhB;AAAA;AAAA;AAAA,iCAAW,IAAI,WAA8B;AAG5C,SAAK,SAAS;AAAA,EACf;AAAA,EAEA,IAAW,OAAO;AACjB,WAAO,KAAK,OAAO;AAAA,EACpB;AAAA,EAEO,kBAAkB,OAAkD;AAC1E,UAAM,aAAqC,CAAC;AAE5C,QAAI,SAA8B,KAAK;AACvC,QAAI,QAAQ,MAAM,SAAS;AAC3B,OAAG;AACF,UAAI,OAAO,QAAS,YAAW,OAAO,IAAI,IAAI,MAAM,KAAK;AAEzD,eAAS,OAAO;AAChB,QAAE;AAAA,IACH,SAAS;AAET,WAAO;AAAA,EACR;AAAA,EAEO,IAAI,QAAkC;AAC5C,WAAO,mBAAK,UAAS,IAAI,MAAM,KAAK;AAAA,EACrC;AAAA,EAEO,IAAI,QAAoB,OAAoB;AAClD,uBAAK,UAAS,IAAI,QAAQ,KAAK;AAC/B,WAAO;AAAA,EACR;AAAA,EAEO,OAAO,QAAoB,OAAuB;AACxD,UAAM,WAAW,mBAAK,UAAS,IAAI,MAAM;AACzC,QAAI,aAAa,OAAO;AACvB,yBAAK,UAAS,OAAO,MAAM;AAC3B,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR;AAAA,EAEO,UAAwC;AAC9C,WAAO,mBAAK,UAAS,KAAK;AAAA,EAC3B;AACD;AA/CC;AATuB;AAAjB,IAAM,aAAN","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,CAAA;AAKO,IAAM,WAAA,GAAN,MAAM,WAAW,CAAA;AAAA,EAWhB,YAAY,MAAsB,EAAA;AAPzC;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,QAAA,CAAA,CAAA;AAKhB;AAAA;AAAA;AAAA,IAAA,YAAA,CAAA,IAAA,EAAA,QAAA,EAAW,IAAI,UAA8B,EAAA,CAAA,CAAA;AAG5C,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA,CAAA;AAAA,GACf;AAAA,EAEA,IAAW,IAAO,GAAA;AACjB,IAAA,OAAO,KAAK,MAAO,CAAA,IAAA,CAAA;AAAA,GACpB;AAAA,EAEO,kBAAkB,KAAkD,EAAA;AAC1E,IAAA,MAAM,aAAqC,EAAC,CAAA;AAE5C,IAAA,IAAI,SAA8B,IAAK,CAAA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,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"]}
@@ -64,5 +64,5 @@ __name(_RouterRoot, "RouterRoot");
64
64
  var RouterRoot = _RouterRoot;
65
65
 
66
66
  export { RouterRoot };
67
- //# sourceMappingURL=out.js.map
67
+ //# sourceMappingURL=RouterRoot.mjs.map
68
68
  //# sourceMappingURL=RouterRoot.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/structures/router/RouterRoot.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,wBAAwB;AAGjC,SAAS,oBAAoB;AAGtB,IAAM,cAAN,MAAM,oBAAmB,aAAa;AAAA,EACrC,cAAc;AACpB,UAAM,YAAY,OAAO,IAAI;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,IAAI,OAA0B;AACpC,WAAO,KAAK,KAAK,MAAM,MAAM,GAAG,KAAK;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,OAAO,OAAuB;AACpC,WAAO,KAAK,QAAQ,MAAM,MAAM,GAAG,KAAK;AAAA,EACzC;AAAA;AAAA,EAGA,IAAoB,OAAe;AAClC,WAAO;AAAA,EACR;AAAA,EAEgB,WAAmB;AAClC,WAAO;AAAA,EACR;AAAA,EAEA,OAAc,UAAU,MAA2C;AAClE,UAAM,QAAQ,CAAC;AACf,QAAI,iBAAiB,IAAI,EAAG,QAAO;AAEnC,QAAI,OAAO;AACX,eAAW,QAAQ,MAAM;AACxB,UAAI,SAAS,KAAK;AACjB,YAAI,KAAK,QAAQ;AAChB,gBAAM,KAAK,IAAI;AACf,iBAAO;AAAA,QACR;AAAA,MACD,OAAO;AACN,gBAAQ;AAAA,MACT;AAAA,IACD;AAEA,QAAI,KAAK,QAAQ;AAChB,YAAM,KAAK,IAAI;AACf,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR;AAAA,EAEA,OAAc,cAAc,MAA4C;AACvE,QAAI,KAAK,WAAW,EAAG,QAAO;AAE9B,UAAM,YAAY,KAAK,SAAS;AAChC,UAAM,OAAO,KAAK,SAAS;AAC3B,UAAM,cAAc,KAAK,YAAY,GAAG;AACxC,QAAI,gBAAgB,MAAM,gBAAgB,KAAK,SAAS,EAAG,QAAO;AAElE,WAAO,KAAK,MAAM,cAAc,CAAC,EAAE,YAAY;AAAA,EAChD;AACD;AApE6C;AAAtC,IAAM,aAAN","sourcesContent":["import { isNullishOrEmpty } from '@sapphire/utilities';\nimport type { Route } from '../Route';\nimport type { MethodName } from '../http/HttpMethods';\nimport { RouterBranch } from './RouterBranch';\nimport type { RouterNode } from './RouterNode';\n\nexport class RouterRoot extends RouterBranch {\n\tpublic constructor() {\n\t\tsuper('::ROOT::', false, null);\n\t}\n\n\t/**\n\t * Adds a route to the branch\n\t *\n\t * @param route The route to add\n\t * @returns The node the route was added to\n\t */\n\tpublic add(route: Route): RouterNode {\n\t\treturn this._add(route.path, 0, route);\n\t}\n\n\t/**\n\t * Removes a route from the branch\n\t *\n\t * @param route The route to remove\n\t * @returns Whether or not the route was removed\n\t */\n\tpublic remove(route: Route): boolean {\n\t\treturn this._remove(route.path, 0, route);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/class-literal-property-style\n\tpublic override get path(): string {\n\t\treturn '';\n\t}\n\n\tpublic override toString(): string {\n\t\treturn '';\n\t}\n\n\tpublic static normalize(path: string | null | undefined): string[] {\n\t\tconst parts = [] as string[];\n\t\tif (isNullishOrEmpty(path)) return parts;\n\n\t\tlet part = '';\n\t\tfor (const char of path) {\n\t\t\tif (char === '/') {\n\t\t\t\tif (part.length) {\n\t\t\t\t\tparts.push(part);\n\t\t\t\t\tpart = '';\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpart += char;\n\t\t\t}\n\t\t}\n\n\t\tif (part.length) {\n\t\t\tparts.push(part);\n\t\t\tpart = '';\n\t\t}\n\n\t\treturn parts;\n\t}\n\n\tpublic static extractMethod(path: readonly string[]): MethodName | null {\n\t\tif (path.length === 0) return null;\n\n\t\tconst lastIndex = path.length - 1;\n\t\tconst last = path[lastIndex];\n\t\tconst methodIndex = last.lastIndexOf('.');\n\t\tif (methodIndex === -1 || methodIndex === last.length - 1) return null;\n\n\t\treturn last.slice(methodIndex + 1).toUpperCase() as MethodName;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../../../src/lib/structures/router/RouterRoot.ts"],"names":[],"mappings":";;;;AAMO,IAAM,WAAA,GAAN,MAAM,WAAA,SAAmB,YAAa,CAAA;AAAA,EACrC,W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Ac,IAA4C,EAAA;AACvE,IAAI,IAAA,IAAA,CAAK,MAAW,KAAA,CAAA,EAAU,OAAA,IAAA,CAAA;AAE9B,IAAM,MAAA,SAAA,GAAY,KAAK,MAAS,GAAA,CAAA,CAAA;AAChC,IAAM,MAAA,IAAA,GAAO,KAAK,SAAS,CAAA,CAAA;AAC3B,IAAM,MAAA,WAAA,GAAc,IAAK,CAAA,WAAA,CAAY,GAAG,CAAA,CAAA;AACxC,IAAA,IAAI,gBAAgB,CAAM,CAAA,IAAA,WAAA,KAAgB,IAAK,CAAA,MAAA,GAAS,GAAU,OAAA,IAAA,CAAA;AAElE,IAAA,OAAO,IAAK,CAAA,KAAA,CAAM,WAAc,GAAA,CAAC,EAAE,WAAY,EAAA,CAAA;AAAA,GAChD;AACD,CAAA,CAAA;AApE6C,MAAA,CAAA,WAAA,EAAA,YAAA,CAAA,CAAA;AAAtC,IAAM,UAAN,GAAA","file":"RouterRoot.mjs","sourcesContent":["import { isNullishOrEmpty } from '@sapphire/utilities';\nimport type { Route } from '../Route';\nimport type { MethodName } from '../http/HttpMethods';\nimport { RouterBranch } from './RouterBranch';\nimport type { RouterNode } from './RouterNode';\n\nexport class RouterRoot extends RouterBranch {\n\tpublic constructor() {\n\t\tsuper('::ROOT::', false, null);\n\t}\n\n\t/**\n\t * Adds a route to the branch\n\t *\n\t * @param route The route to add\n\t * @returns The node the route was added to\n\t */\n\tpublic add(route: Route): RouterNode {\n\t\treturn this._add(route.path, 0, route);\n\t}\n\n\t/**\n\t * Removes a route from the branch\n\t *\n\t * @param route The route to remove\n\t * @returns Whether or not the route was removed\n\t */\n\tpublic remove(route: Route): boolean {\n\t\treturn this._remove(route.path, 0, route);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/class-literal-property-style\n\tpublic override get path(): string {\n\t\treturn '';\n\t}\n\n\tpublic override toString(): string {\n\t\treturn '';\n\t}\n\n\tpublic static normalize(path: string | null | undefined): string[] {\n\t\tconst parts = [] as string[];\n\t\tif (isNullishOrEmpty(path)) return parts;\n\n\t\tlet part = '';\n\t\tfor (const char of path) {\n\t\t\tif (char === '/') {\n\t\t\t\tif (part.length) {\n\t\t\t\t\tparts.push(part);\n\t\t\t\t\tpart = '';\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpart += char;\n\t\t\t}\n\t\t}\n\n\t\tif (part.length) {\n\t\t\tparts.push(part);\n\t\t\tpart = '';\n\t\t}\n\n\t\treturn parts;\n\t}\n\n\tpublic static extractMethod(path: readonly string[]): MethodName | null {\n\t\tif (path.length === 0) return null;\n\n\t\tconst lastIndex = path.length - 1;\n\t\tconst last = path[lastIndex];\n\t\tconst methodIndex = last.lastIndexOf('.');\n\t\tif (methodIndex === -1 || methodIndex === last.length - 1) return null;\n\n\t\treturn last.slice(methodIndex + 1).toUpperCase() as MethodName;\n\t}\n}\n"]}
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=MimeType.mjs.map
3
+ //# sourceMappingURL=MimeType.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"MimeType.mjs"}
@@ -16,5 +16,5 @@ __name(_PluginListener, "PluginListener");
16
16
  var PluginListener = _PluginListener;
17
17
 
18
18
  export { PluginListener };
19
- //# sourceMappingURL=out.js.map
19
+ //# sourceMappingURL=PluginRouteError.mjs.map
20
20
  //# sourceMappingURL=PluginRouteError.mjs.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":[],"mappings":";;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,YAAY,CAAA,CAAA;AAAA,GACpE;AAAA,EAEgB,GAAA,CAAI,KAAc,EAAA,QAAA,EAAsB,QAAuB,EAAA;AAE9E,IAAK,IAAA,CAAA,SAAA,CAAU,MAAO,CAAA,KAAA,CAAM,KAAK,CAAA,CAAA;AAGjC,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,OAAO,SAAU,CAAA,mBAAmB,CAAE,CAAA,IAAA,CAAK,EAAE,KAAA,EAAO,KAAM,CAAA,OAAA,IAAW,OAAO,CAAA,CAAA;AAAA,GACnH;AACD,CAAA,CAAA;AAZ6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginRouteError.mjs","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"]}
@@ -16,5 +16,5 @@ __name(_PluginListener, "PluginListener");
16
16
  var PluginListener = _PluginListener;
17
17
 
18
18
  export { PluginListener };
19
- //# sourceMappingURL=out.js.map
19
+ //# sourceMappingURL=PluginServerMiddlewareError.mjs.map
20
20
  //# sourceMappingURL=PluginServerMiddlewareError.mjs.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":[],"mappings":";;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,iBAAiB,CAAA,CAAA;AAAA,GACzE;AAAA,EAEgB,GAAA,CAAI,KAAc,EAAA,QAAA,EAAsB,QAAuB,EAAA;AAE9E,IAAK,IAAA,CAAA,SAAA,CAAU,MAAO,CAAA,KAAA,CAAM,KAAK,CAAA,CAAA;AAGjC,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,OAAO,SAAU,CAAA,mBAAmB,CAAE,CAAA,IAAA,CAAK,EAAE,KAAA,EAAO,KAAM,CAAA,OAAA,IAAW,OAAO,CAAA,CAAA;AAAA,GACnH;AACD,CAAA,CAAA;AAZ6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerMiddlewareError.mjs","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"]}
@@ -18,5 +18,5 @@ __name(_PluginListener, "PluginListener");
18
18
  var PluginListener = _PluginListener;
19
19
 
20
20
  export { PluginListener };
21
- //# sourceMappingURL=out.js.map
21
+ //# sourceMappingURL=PluginServerMiddlewareSuccess.mjs.map
22
22
  //# sourceMappingURL=PluginServerMiddlewareSuccess.mjs.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":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,mBAAmB,CAAA,CAAA;AAAA,GAC3E;AAAA,EAEA,MAAsB,GAAI,CAAA,OAAA,EAAqB,QAAuB,EAAA;AACrE,IAAI,IAAA;AACH,MAAA,MAAM,OAAQ,CAAA,KAAA,CAAO,GAAI,CAAA,OAAA,EAAS,QAAQ,CAAA,CAAA;AAAA,aAClC,KAAO,EAAA;AACf,MAAA,IAAA,CAAK,UAAU,MAAO,CAAA,IAAA,CAAK,YAAY,UAAY,EAAA,KAAA,EAAgB,SAAS,QAAQ,CAAA,CAAA;AAAA,KACrF;AAAA,GACD;AACD,CAAA,CAAA;AAZ6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerMiddlewareSuccess.mjs","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"]}
@@ -29,7 +29,7 @@ var _PluginListener = class _PluginListener extends Listener {
29
29
  if (branch === null) {
30
30
  this.container.server.emit(ServerEvent.RouterBranchNotFound, request, response);
31
31
  } else if (route === null) {
32
- this.container.server.emit(ServerEvent.RouterBranchMethodNotAllowed, request, response);
32
+ this.container.server.emit(ServerEvent.RouterBranchMethodNotAllowed, request, response, branch);
33
33
  } else {
34
34
  this.container.server.emit(ServerEvent.RouterFound, request, response);
35
35
  }
@@ -53,5 +53,5 @@ __name(_PluginListener, "PluginListener");
53
53
  var PluginListener = _PluginListener;
54
54
 
55
55
  export { PluginListener };
56
- //# sourceMappingURL=out.js.map
56
+ //# sourceMappingURL=PluginServerRequest.mjs.map
57
57
  //# sourceMappingURL=PluginServerRequest.mjs.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":[],"mappings":";;;;;AAAA,IAAA,yBAAA,EAAA,WAAA,CAAA;AAOO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,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":"PluginServerRequest.mjs","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"]}
@@ -14,5 +14,5 @@ __name(_PluginListener, "PluginListener");
14
14
  var PluginListener = _PluginListener;
15
15
 
16
16
  export { PluginListener };
17
- //# sourceMappingURL=out.js.map
17
+ //# sourceMappingURL=PluginServerRouterBranchMethodNotAllowed.mjs.map
18
18
  //# sourceMappingURL=PluginServerRouterBranchMethodNotAllowed.mjs.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":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,8BAA8B,CAAA,CAAA;AAAA,GACtF;AAAA,EAEgB,GAAA,CAAI,GAAe,QAAuB,EAAA;AACzD,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,gBAAiB,EAAA,CAAA;AAAA,GACxD;AACD,CAAA,CAAA;AAR6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRouterBranchMethodNotAllowed.mjs","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"]}
@@ -14,5 +14,5 @@ __name(_PluginListener, "PluginListener");
14
14
  var PluginListener = _PluginListener;
15
15
 
16
16
  export { PluginListener };
17
- //# sourceMappingURL=out.js.map
17
+ //# sourceMappingURL=PluginServerRouterBranchNotFound.mjs.map
18
18
  //# sourceMappingURL=PluginServerRouterBranchNotFound.mjs.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":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,sBAAsB,CAAA,CAAA;AAAA,GAC9E;AAAA,EAEgB,GAAA,CAAI,GAAe,QAAuB,EAAA;AACzD,IAAA,IAAI,CAAC,QAAA,CAAS,aAAe,EAAA,QAAA,CAAS,QAAS,EAAA,CAAA;AAAA,GAChD;AACD,CAAA,CAAA;AAR6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRouterBranchNotFound.mjs","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"]}
@@ -7,12 +7,13 @@ var _PluginListener = class _PluginListener extends Listener {
7
7
  super(context, { emitter: "server", event: ServerEvent.RouterFound });
8
8
  }
9
9
  run(request, response) {
10
- this.container.server.emit(response.writableEnded ? ServerEvent.MiddlewareFailure : ServerEvent.MiddlewareSuccess, request, response);
10
+ const event = response.writableEnded ? ServerEvent.MiddlewareFailure : ServerEvent.MiddlewareSuccess;
11
+ this.container.server.emit(event, request, response);
11
12
  }
12
13
  };
13
14
  __name(_PluginListener, "PluginListener");
14
15
  var PluginListener = _PluginListener;
15
16
 
16
17
  export { PluginListener };
17
- //# sourceMappingURL=out.js.map
18
+ //# sourceMappingURL=PluginServerRouterFound.mjs.map
18
19
  //# sourceMappingURL=PluginServerRouterFound.mjs.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":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAS,CAAA;AAAA,EACrC,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,SAAS,EAAE,OAAA,EAAS,UAAU,KAAO,EAAA,WAAA,CAAY,aAAa,CAAA,CAAA;AAAA,GACrE;AAAA,EAEgB,GAAA,CAAI,SAAqB,QAAuB,EAAA;AAC/D,IAAA,MAAM,KAAQ,GAAA,QAAA,CAAS,aAAgB,GAAA,WAAA,CAAY,oBAAoB,WAAY,CAAA,iBAAA,CAAA;AACnF,IAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,IAAK,CAAA,KAAA,EAAO,SAAS,QAAQ,CAAA,CAAA;AAAA,GACpD;AACD,CAAA,CAAA;AAT6C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAAtC,IAAM,cAAN,GAAA","file":"PluginServerRouterFound.mjs","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"]}
@@ -21,5 +21,5 @@ function loadListeners() {
21
21
  __name(loadListeners, "loadListeners");
22
22
 
23
23
  export { loadListeners };
24
- //# sourceMappingURL=out.js.map
24
+ //# sourceMappingURL=_load.mjs.map
25
25
  //# sourceMappingURL=_load.mjs.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":["PluginRouteError","PluginServerMiddlewareError","PluginServerMiddlewareSuccess","PluginServerRequest","PluginServerRouterBranchMethodNotAllowed","PluginServerRouterBranchNotFound","PluginServerRouterFound"],"mappings":";;;;;;;;;;AASO,SAAS,aAAgB,GAAA;AAC/B,EAAA,MAAM,KAAQ,GAAA,WAAA,CAAA;AACd,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,kBAAoB,EAAA,KAAA,EAAOA,cAAkB,EAAA,KAAA,EAAO,CAAA,CAAA;AAC5F,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,6BAA+B,EAAA,KAAA,EAAOC,gBAA6B,EAAA,KAAA,EAAO,CAAA,CAAA;AAClH,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,+BAAiC,EAAA,KAAA,EAAOC,gBAA+B,EAAA,KAAA,EAAO,CAAA,CAAA;AACtH,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,qBAAuB,EAAA,KAAA,EAAOC,gBAAqB,EAAA,KAAA,EAAO,CAAA,CAAA;AAClG,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,0CAA4C,EAAA,KAAA,EAAOC,gBAA0C,EAAA,KAAA,EAAO,CAAA,CAAA;AAC5I,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,kCAAoC,EAAA,KAAA,EAAOC,gBAAkC,EAAA,KAAA,EAAO,CAAA,CAAA;AAC5H,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,yBAA2B,EAAA,KAAA,EAAOC,gBAAyB,EAAA,KAAA,EAAO,CAAA,CAAA;AAC3G,CAAA;AATgB,MAAA,CAAA,aAAA,EAAA,eAAA,CAAA","file":"_load.mjs","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"]}
@@ -13,5 +13,5 @@ function loadMediaParsers() {
13
13
  __name(loadMediaParsers, "loadMediaParsers");
14
14
 
15
15
  export { loadMediaParsers };
16
- //# sourceMappingURL=out.js.map
16
+ //# sourceMappingURL=_load.mjs.map
17
17
  //# sourceMappingURL=_load.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mediaParsers/_load.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB,uCAAuC;AACrE,SAAS,qBAAqB,6BAA6B;AAC3D,SAAS,qBAAqB,uBAAuB;AAE9C,SAAS,mBAAmB;AAClC,QAAM,QAAQ;AACd,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,6BAA6B,OAAO,iCAAiC,MAAM,CAAC;AACpH,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,mBAAmB,OAAO,uBAAuB,MAAM,CAAC;AAChG,OAAK,UAAU,OAAO,UAAU,EAAE,MAAM,aAAa,OAAO,iBAAiB,MAAM,CAAC;AACrF;AALgB","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginMediaParser as PluginApplicationFormUrlEncoded } from './applicationFormUrlEncoded';\nimport { PluginMediaParser as PluginApplicationJson } from './applicationJson';\nimport { PluginMediaParser as PluginTextPlain } from './textPlain';\n\nexport function loadMediaParsers() {\n\tconst store = 'mediaParsers' as const;\n\tvoid container.stores.loadPiece({ name: 'applicationFormUrlEncoded', piece: PluginApplicationFormUrlEncoded, store });\n\tvoid container.stores.loadPiece({ name: 'applicationJson', piece: PluginApplicationJson, store });\n\tvoid container.stores.loadPiece({ name: 'textPlain', piece: PluginTextPlain, store });\n}\n"]}
1
+ {"version":3,"sources":["../../../src/mediaParsers/_load.ts"],"names":["PluginApplicationFormUrlEncoded","PluginApplicationJson","PluginTextPlain"],"mappings":";;;;;;AAKO,SAAS,gBAAmB,GAAA;AAClC,EAAA,MAAM,KAAQ,GAAA,cAAA,CAAA;AACd,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,2BAA6B,EAAA,KAAA,EAAOA,iBAAiC,EAAA,KAAA,EAAO,CAAA,CAAA;AACpH,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,iBAAmB,EAAA,KAAA,EAAOC,mBAAuB,EAAA,KAAA,EAAO,CAAA,CAAA;AAChG,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,WAAa,EAAA,KAAA,EAAOC,mBAAiB,EAAA,KAAA,EAAO,CAAA,CAAA;AACrF,CAAA;AALgB,MAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA","file":"_load.mjs","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginMediaParser as PluginApplicationFormUrlEncoded } from './applicationFormUrlEncoded';\nimport { PluginMediaParser as PluginApplicationJson } from './applicationJson';\nimport { PluginMediaParser as PluginTextPlain } from './textPlain';\n\nexport function loadMediaParsers() {\n\tconst store = 'mediaParsers' as const;\n\tvoid container.stores.loadPiece({ name: 'applicationFormUrlEncoded', piece: PluginApplicationFormUrlEncoded, store });\n\tvoid container.stores.loadPiece({ name: 'applicationJson', piece: PluginApplicationJson, store });\n\tvoid container.stores.loadPiece({ name: 'textPlain', piece: PluginTextPlain, store });\n}\n"]}
@@ -1,11 +1,10 @@
1
1
  import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { URLSearchParams } from 'url';
3
3
  import { MediaParser } from '../lib/structures/MediaParser.mjs';
4
- import { MimeTypes } from '../lib/utils/MimeTypes.mjs';
5
4
 
6
5
  var _PluginMediaParser = class _PluginMediaParser extends MediaParser {
7
6
  constructor(context) {
8
- super(context, { name: MimeTypes.ApplicationFormUrlEncoded });
7
+ super(context, { name: "application/x-www-form-urlencoded" });
9
8
  }
10
9
  async run(request) {
11
10
  const body = await this.readString(request);
@@ -16,5 +15,5 @@ __name(_PluginMediaParser, "PluginMediaParser");
16
15
  var PluginMediaParser = _PluginMediaParser;
17
16
 
18
17
  export { PluginMediaParser };
19
- //# sourceMappingURL=out.js.map
18
+ //# sourceMappingURL=applicationFormUrlEncoded.mjs.map
20
19
  //# sourceMappingURL=applicationFormUrlEncoded.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mediaParsers/applicationFormUrlEncoded.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAE5B,SAAS,iBAAiB;AAEnB,IAAM,qBAAN,MAAM,2BAA0B,YAAY;AAAA,EAC3C,YAAY,SAAoC;AACtD,UAAM,SAAS,EAAE,MAAM,UAAU,0BAA0B,CAAC;AAAA,EAC7D;AAAA,EAEA,MAAsB,IAAI,SAAuC;AAChE,UAAM,OAAO,MAAM,KAAK,WAAW,OAAO;AAC1C,WAAO,KAAK,WAAW,IAAI,OAAO,OAAO,YAAY,IAAI,gBAAgB,IAAI,EAAE,QAAQ,CAAC;AAAA,EACzF;AACD;AATmD;AAA5C,IAAM,oBAAN","sourcesContent":["import { URLSearchParams } from 'url';\nimport { MediaParser } from '../lib/structures/MediaParser';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport { MimeTypes } from '../lib/utils/MimeTypes';\n\nexport class PluginMediaParser extends MediaParser {\n\tpublic constructor(context: MediaParser.LoaderContext) {\n\t\tsuper(context, { name: MimeTypes.ApplicationFormUrlEncoded });\n\t}\n\n\tpublic override async run(request: ApiRequest): Promise<unknown> {\n\t\tconst body = await this.readString(request);\n\t\treturn body.length === 0 ? null : Object.fromEntries(new URLSearchParams(body).entries());\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/mediaParsers/applicationFormUrlEncoded.ts"],"names":[],"mappings":";;;;AAIO,IAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0B,WAAY,CAAA;AAAA,EAC3C,YAAY,OAAoC,EAAA;AACtD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,IAAM,EAAA,mCAAA,EAAwD,CAAA,CAAA;AAAA,GAChF;AAAA,EAEA,MAAsB,IAAI,OAAgD,EAAA;AACzE,IAAA,MAAM,IAAO,GAAA,MAAM,IAAK,CAAA,UAAA,CAAW,OAAO,CAAA,CAAA;AAC1C,IAAO,OAAA,IAAA,CAAK,MAAW,KAAA,CAAA,GAAI,IAAO,GAAA,MAAA,CAAO,WAAY,CAAA,IAAI,eAAgB,CAAA,IAAI,CAAE,CAAA,OAAA,EAAS,CAAA,CAAA;AAAA,GACzF;AACD,CAAA,CAAA;AATmD,MAAA,CAAA,kBAAA,EAAA,mBAAA,CAAA,CAAA;AAA5C,IAAM,iBAAN,GAAA","file":"applicationFormUrlEncoded.mjs","sourcesContent":["import { URLSearchParams } from 'url';\nimport { MediaParser } from '../lib/structures/MediaParser';\nimport type { MimeType } from '../lib/utils/MimeType';\n\nexport class PluginMediaParser extends MediaParser {\n\tpublic constructor(context: MediaParser.LoaderContext) {\n\t\tsuper(context, { name: 'application/x-www-form-urlencoded' satisfies MimeType });\n\t}\n\n\tpublic override async run(request: MediaParser.Request): Promise<unknown> {\n\t\tconst body = await this.readString(request);\n\t\treturn body.length === 0 ? null : Object.fromEntries(new URLSearchParams(body).entries());\n\t}\n}\n"]}
@@ -1,10 +1,9 @@
1
1
  import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { MediaParser } from '../lib/structures/MediaParser.mjs';
3
- import { MimeTypes } from '../lib/utils/MimeTypes.mjs';
4
3
 
5
4
  var _PluginMediaParser = class _PluginMediaParser extends MediaParser {
6
5
  constructor(context) {
7
- super(context, { name: MimeTypes.ApplicationJson });
6
+ super(context, { name: "application/json" });
8
7
  }
9
8
  async run(request) {
10
9
  const body = await this.readString(request);
@@ -15,5 +14,5 @@ __name(_PluginMediaParser, "PluginMediaParser");
15
14
  var PluginMediaParser = _PluginMediaParser;
16
15
 
17
16
  export { PluginMediaParser };
18
- //# sourceMappingURL=out.js.map
17
+ //# sourceMappingURL=applicationJson.mjs.map
19
18
  //# sourceMappingURL=applicationJson.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mediaParsers/applicationJson.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAEnB,IAAM,qBAAN,MAAM,2BAA0B,YAAY;AAAA,EAC3C,YAAY,SAAoC;AACtD,UAAM,SAAS,EAAE,MAAM,UAAU,gBAAgB,CAAC;AAAA,EACnD;AAAA,EAEA,MAAsB,IAAI,SAAgD;AACzE,UAAM,OAAO,MAAM,KAAK,WAAW,OAAO;AAC1C,WAAO,KAAK,WAAW,IAAI,OAAO,KAAK,MAAM,IAAI;AAAA,EAClD;AACD;AATmD;AAA5C,IAAM,oBAAN","sourcesContent":["import { MediaParser } from '../lib/structures/MediaParser';\nimport { MimeTypes } from '../lib/utils/MimeTypes';\n\nexport class PluginMediaParser extends MediaParser {\n\tpublic constructor(context: MediaParser.LoaderContext) {\n\t\tsuper(context, { name: MimeTypes.ApplicationJson });\n\t}\n\n\tpublic override async run(request: MediaParser.Request): Promise<unknown> {\n\t\tconst body = await this.readString(request);\n\t\treturn body.length === 0 ? null : JSON.parse(body);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/mediaParsers/applicationJson.ts"],"names":[],"mappings":";;;AAGO,IAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0B,WAAY,CAAA;AAAA,EAC3C,YAAY,OAAoC,EAAA;AACtD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,IAAM,EAAA,kBAAA,EAAuC,CAAA,CAAA;AAAA,GAC/D;AAAA,EAEA,MAAsB,IAAI,OAAgD,EAAA;AACzE,IAAA,MAAM,IAAO,GAAA,MAAM,IAAK,CAAA,UAAA,CAAW,OAAO,CAAA,CAAA;AAC1C,IAAA,OAAO,KAAK,MAAW,KAAA,CAAA,GAAI,IAAO,GAAA,IAAA,CAAK,MAAM,IAAI,CAAA,CAAA;AAAA,GAClD;AACD,CAAA,CAAA;AATmD,MAAA,CAAA,kBAAA,EAAA,mBAAA,CAAA,CAAA;AAA5C,IAAM,iBAAN,GAAA","file":"applicationJson.mjs","sourcesContent":["import { MediaParser } from '../lib/structures/MediaParser';\nimport type { MimeType } from '../lib/utils/MimeType';\n\nexport class PluginMediaParser extends MediaParser {\n\tpublic constructor(context: MediaParser.LoaderContext) {\n\t\tsuper(context, { name: 'application/json' satisfies MimeType });\n\t}\n\n\tpublic override async run(request: MediaParser.Request): Promise<unknown> {\n\t\tconst body = await this.readString(request);\n\t\treturn body.length === 0 ? null : JSON.parse(body);\n\t}\n}\n"]}
@@ -1,10 +1,9 @@
1
1
  import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { MediaParser } from '../lib/structures/MediaParser.mjs';
3
- import { MimeTypes } from '../lib/utils/MimeTypes.mjs';
4
3
 
5
4
  var _PluginMediaParser = class _PluginMediaParser extends MediaParser {
6
5
  constructor(context) {
7
- super(context, { name: MimeTypes.TextPlain });
6
+ super(context, { name: "text/plain" });
8
7
  }
9
8
  async run(request) {
10
9
  const body = await this.readString(request);
@@ -15,5 +14,5 @@ __name(_PluginMediaParser, "PluginMediaParser");
15
14
  var PluginMediaParser = _PluginMediaParser;
16
15
 
17
16
  export { PluginMediaParser };
18
- //# sourceMappingURL=out.js.map
17
+ //# sourceMappingURL=textPlain.mjs.map
19
18
  //# sourceMappingURL=textPlain.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mediaParsers/textPlain.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAEnB,IAAM,qBAAN,MAAM,2BAA0B,YAAY;AAAA,EAC3C,YAAY,SAAoC;AACtD,UAAM,SAAS,EAAE,MAAM,UAAU,UAAU,CAAC;AAAA,EAC7C;AAAA,EAEA,MAAsB,IAAI,SAAgD;AACzE,UAAM,OAAO,MAAM,KAAK,WAAW,OAAO;AAC1C,WAAO,KAAK,WAAW,IAAI,OAAO;AAAA,EACnC;AACD;AATmD;AAA5C,IAAM,oBAAN","sourcesContent":["import { MediaParser } from '../lib/structures/MediaParser';\nimport { MimeTypes } from '../lib/utils/MimeTypes';\n\nexport class PluginMediaParser extends MediaParser {\n\tpublic constructor(context: MediaParser.LoaderContext) {\n\t\tsuper(context, { name: MimeTypes.TextPlain });\n\t}\n\n\tpublic override async run(request: MediaParser.Request): Promise<unknown> {\n\t\tconst body = await this.readString(request);\n\t\treturn body.length === 0 ? null : body;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/mediaParsers/textPlain.ts"],"names":[],"mappings":";;;AAGO,IAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0B,WAAY,CAAA;AAAA,EAC3C,YAAY,OAAoC,EAAA;AACtD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,IAAM,EAAA,YAAA,EAAiC,CAAA,CAAA;AAAA,GACzD;AAAA,EAEA,MAAsB,IAAI,OAAgD,EAAA;AACzE,IAAA,MAAM,IAAO,GAAA,MAAM,IAAK,CAAA,UAAA,CAAW,OAAO,CAAA,CAAA;AAC1C,IAAO,OAAA,IAAA,CAAK,MAAW,KAAA,CAAA,GAAI,IAAO,GAAA,IAAA,CAAA;AAAA,GACnC;AACD,CAAA,CAAA;AATmD,MAAA,CAAA,kBAAA,EAAA,mBAAA,CAAA,CAAA;AAA5C,IAAM,iBAAN,GAAA","file":"textPlain.mjs","sourcesContent":["import { MediaParser } from '../lib/structures/MediaParser';\nimport type { MimeType } from '../lib/utils/MimeType';\n\nexport class PluginMediaParser extends MediaParser {\n\tpublic constructor(context: MediaParser.LoaderContext) {\n\t\tsuper(context, { name: 'text/plain' satisfies MimeType });\n\t}\n\n\tpublic override async run(request: MediaParser.Request): Promise<unknown> {\n\t\tconst body = await this.readString(request);\n\t\treturn body.length === 0 ? null : body;\n\t}\n}\n"]}
@@ -15,5 +15,5 @@ function loadMiddlewares() {
15
15
  __name(loadMiddlewares, "loadMiddlewares");
16
16
 
17
17
  export { loadMiddlewares };
18
- //# sourceMappingURL=out.js.map
18
+ //# sourceMappingURL=_load.mjs.map
19
19
  //# sourceMappingURL=_load.mjs.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":["PluginAuth","PluginBody","PluginCookies","PluginHeaders"],"mappings":";;;;;;;AAMO,SAAS,eAAkB,GAAA;AACjC,EAAA,MAAM,KAAQ,GAAA,aAAA,CAAA;AACd,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,MAAQ,EAAA,KAAA,EAAOA,gBAAY,EAAA,KAAA,EAAO,CAAA,CAAA;AAC1E,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,MAAQ,EAAA,KAAA,EAAOC,kBAAY,EAAA,KAAA,EAAO,CAAA,CAAA;AAC1E,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,SAAW,EAAA,KAAA,EAAOC,kBAAe,EAAA,KAAA,EAAO,CAAA,CAAA;AAChF,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,SAAW,EAAA,KAAA,EAAOC,kBAAe,EAAA,KAAA,EAAO,CAAA,CAAA;AACjF,CAAA;AANgB,MAAA,CAAA,eAAA,EAAA,iBAAA,CAAA","file":"_load.mjs","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"]}
@@ -23,5 +23,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
23
23
  var PluginMiddleware = _PluginMiddleware;
24
24
 
25
25
  export { PluginMiddleware };
26
- //# sourceMappingURL=out.js.map
26
+ //# sourceMappingURL=auth.mjs.map
27
27
  //# sourceMappingURL=auth.mjs.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":[],"mappings":";;;AAEO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAGzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA,CAAA;AAHhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,CAAA,CAAA;AAKhB,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA,CAAA;AACxB,IAAK,IAAA,CAAA,UAAA,GAAa,MAAO,CAAA,IAAA,EAAM,MAAU,IAAA,eAAA,CAAA;AACzC,IAAK,IAAA,CAAA,OAAA,GAAU,OAAO,IAAS,KAAA,IAAA,CAAA;AAAA,GAChC;AAAA,EAEgB,GAAA,CAAI,SAA6B,QAA+B,EAAA;AAE/E,IAAA,MAAM,aAAgB,GAAA,QAAA,CAAS,OAAQ,CAAA,GAAA,CAAI,KAAK,UAAU,CAAA,CAAA;AAC1D,IAAA,IAAI,CAAC,aAAe,EAAA;AACnB,MAAA,OAAA,CAAQ,IAAO,GAAA,IAAA,CAAA;AACf,MAAA,OAAA;AAAA,KACD;AAGA,IAAA,OAAA,CAAQ,OAAO,IAAK,CAAA,SAAA,CAAU,MAAO,CAAA,IAAA,CAAM,QAAQ,aAAa,CAAA,CAAA;AAChE,IAAA,IAAI,QAAQ,IAAS,KAAA,IAAA,WAAe,OAAQ,CAAA,MAAA,CAAO,KAAK,UAAU,CAAA,CAAA;AAAA,GACnE;AACD,CAAA,CAAA;AAvBiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"auth.mjs","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"]}
@@ -37,5 +37,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
37
37
  var PluginMiddleware = _PluginMiddleware;
38
38
 
39
39
  export { PluginMiddleware };
40
- //# sourceMappingURL=out.js.map
40
+ //# sourceMappingURL=body.mjs.map
41
41
  //# sourceMappingURL=body.mjs.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":[],"mappings":";;;;AAIO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAGzC,YAAY,OAAmC,EAAA;AACrD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,CAAA,CAAA;AAHhC,IAAiB,aAAA,CAAA,IAAA,EAAA,cAAA,CAAA,CAAA;AAIhB,IAAK,IAAA,CAAA,YAAA,GAAe,IAAK,CAAA,SAAA,CAAU,MAAO,CAAA,YAAA,CAAA;AAAA,GAC3C;AAAA,EAEA,MAAsB,GAAI,CAAA,OAAA,EAA6B,QAA+B,EAAA;AACrF,IAAI,IAAA,CAAC,QAAQ,KAAO,EAAA,OAAA;AAGpB,IAAM,MAAA,WAAA,GAAc,OAAQ,CAAA,OAAA,CAAQ,cAAc,CAAA,CAAA;AAClD,IAAI,IAAA,OAAO,gBAAgB,QAAU,EAAA,OAAA;AAGrC,IAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,OAAA,CAAQ,gBAAgB,CAAA,CAAA;AACrD,IAAI,IAAA,OAAO,iBAAiB,QAAU,EAAA,OAAA;AAGtC,IAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA,CAAA;AAClC,IAAM,MAAA,aAAA,GAAgB,QAAQ,KAAM,CAAA,iBAAA,CAAA;AACpC,IAAA,IAAI,SAAS,aAAe,EAAA;AAC3B,MAAS,QAAA,CAAA,MAAA,CAAO,UAAU,eAAe,CAAA,CAAE,KAAK,EAAE,KAAA,EAAO,oCAAoC,CAAA,CAAA;AAC7F,MAAA,OAAA;AAAA,KACD;AAGA,IAAA,MAAM,IAAO,GAAA,IAAA,CAAK,YAAa,CAAA,gBAAA,CAAiB,WAAW,CAAA,CAAA;AAC3D,IAAA,MAAM,MAAS,GAAA,IAAA,CAAK,YAAa,CAAA,GAAA,CAAI,IAAI,CAAA,CAAA;AACzC,IAAA,IAAI,CAAC,MAAU,IAAA,CAAC,OAAO,OAAQ,CAAA,OAAA,CAAQ,KAAK,CAAG,EAAA;AAC9C,MAAS,QAAA,CAAA,MAAA,CAAO,SAAU,CAAA,oBAAoB,CAAE,CAAA,IAAA,CAAK,EAAE,KAAO,EAAA,CAAA,iBAAA,EAAoB,IAAI,CAAA,CAAA,CAAA,EAAK,CAAA,CAAA;AAC3F,MAAA,OAAA;AAAA,KACD;AAEA,IAAI,IAAA;AAEH,MAAA,OAAA,CAAQ,IAAO,GAAA,MAAM,MAAO,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AAAA,KAChC,CAAA,MAAA;AACP,MAAS,QAAA,CAAA,MAAA,CAAO,SAAU,CAAA,UAAU,CAAE,CAAA,IAAA,CAAK,EAAE,KAAO,EAAA,CAAA,aAAA,EAAgB,IAAI,CAAA,MAAA,CAAA,EAAU,CAAA,CAAA;AAAA,KACnF;AAAA,GACD;AACD,CAAA,CAAA;AA1CiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA,CAAA;AAA1C,IAAM,gBAAN,GAAA","file":"body.mjs","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"]}
@@ -18,5 +18,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
18
18
  var PluginMiddleware = _PluginMiddleware;
19
19
 
20
20
  export { PluginMiddleware };
21
- //# sourceMappingURL=out.js.map
21
+ //# sourceMappingURL=cookies.mjs.map
22
22
  //# sourceMappingURL=cookies.mjs.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":[],"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,CAAA;AAJhC,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,EAAsB,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,YAAA,CAAA,CAAA;AAChE,IAAA,aAAA,CAAA,IAAA,EAAQ,iBAAiC,EAAA,IAAA,CAAA,CAAA;AAKxC,IAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,SAAA,CAAA;AACxB,IAAK,IAAA,CAAA,eAAA,GAAkB,MAAO,CAAA,IAAA,EAAM,eAAmB,IAAA,IAAA,CAAA;AAAA,GACxD;AAAA,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,CAAA;AAAA,GAC5F;AACD,CAAA,CAAA;AAdiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA,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"]}
@@ -57,5 +57,5 @@ __name(_PluginMiddleware, "PluginMiddleware");
57
57
  var PluginMiddleware = _PluginMiddleware;
58
58
 
59
59
  export { PluginMiddleware };
60
- //# sourceMappingURL=out.js.map
60
+ //# sourceMappingURL=headers.mjs.map
61
61
  //# sourceMappingURL=headers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/headers.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAG3B,SAAS,iBAAiB;AAEnB,IAAM,oBAAN,MAAM,0BAAyB,WAAW;AAAA,EAIzC,YAAY,SAAmC;AACrD,UAAM,SAAS,EAAE,UAAU,GAAG,CAAC;AAJhC,wBAAiB;AACjB,wBAAiB;AAIhB,SAAK,SAAS,KAAK,UAAU,OAAO,QAAQ,UAAU;AACtD,SAAK,SAAS,KAAK,UAAU,OAAO,IAAI,QAAQ;AAAA,EACjD;AAAA,EAEgB,IAAI,SAA6B,UAA+B;AAC/E,aAAS,UAAU,SAAQ,oBAAI,KAAK,GAAE,YAAY,CAAC;AACnD,aAAS,UAAU,oCAAoC,MAAM;AAC7D,aAAS,UAAU,+BAA+B,KAAK,MAAM;AAC7D,aAAS,UAAU,gCAAgC,yCAAyC;AAC5F,aAAS,UAAU,gCAAgC,KAAK,WAAW,QAAQ,SAAS,IAAI,CAAC;AAEzF,SAAK,yBAAyB,SAAS,QAAQ;AAAA,EAChD;AAAA,EAEQ,WAAW,OAAqB;AACvC,QAAI,UAAU,MAAM;AACnB,aAAO,KAAK,OAAO,OAAO,iBAAiB,KAAK,IAAI;AAAA,IACrD;AAEA,QAAI,MAAM,QAAQ,SAAS,EAAG,QAAO;AACrC,QAAI,MAAM,QAAQ,SAAS,EAAG,QAAO,MAAM,QAAQ,KAAK,EAAE,KAAK,EAAE;AACjE,WAAO,CAAC,GAAG,MAAM,OAAO,EAAE,KAAK,IAAI;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBQ,yBAAyB,EAAE,QAAQ,OAAO,WAAW,GAAuB,UAA+B;AAClH,QAAI,WAAW,WAAW;AACzB,UAAI,CAAC,SAAS,CAAC,MAAM,QAAQ,IAAI,SAAS,GAAG;AAC5C,iBAAS,IAAI;AAAA,MACd;AAAA,IACD,WAAW,eAAe,MAAM;AAC/B,eAAS,OAAO,UAAU,QAAQ,EAAE,IAAI;AAAA,IACzC,WAAW,UAAU,MAAM;AAC1B,eAAS,OAAO,UAAU,gBAAgB,EAAE,IAAI;AAAA,IACjD;AAAA,EACD;AACD;AAxDiD;AAA1C,IAAM,mBAAN","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":";;;;AAKO,IAAM,iBAAA,GAAN,MAAM,iBAAA,SAAyB,UAAW,CAAA;AAAA,EAIzC,YAAY,OAAmC,EA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AAM,OAAQ,CAAA,IAAA,KAAS,CAAG,EAAA,OAAO,MAAM,OAAQ,CAAA,IAAA,EAAO,CAAA,IAAA,EAAO,CAAA,KAAA,CAAA;AACjE,IAAA,OAAO,CAAC,GAAG,KAAA,CAAM,OAAO,CAAA,CAAE,KAAK,IAAI,CAAA,CAAA;AAAA,GACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,CAAA;AAAA,OACd;AAAA,KACD,MAAA,IAAW,eAAe,IAAM,EAAA;AAC/B,MAAA,QAAA,CAAS,MAAO,CAAA,SAAA,CAAU,QAAQ,CAAA,CAAE,GAAI,EAAA,CAAA;AAAA,KACzC,MAAA,IAAW,UAAU,IAAM,EAAA;AAC1B,MAAA,QAAA,CAAS,MAAO,CAAA,SAAA,CAAU,gBAAgB,CAAA,CAAE,GAAI,EAAA,CAAA;AAAA,KACjD;AAAA,GACD;AACD,CAAA,CAAA;AAxDiD,MAAA,CAAA,iBAAA,EAAA,kBAAA,CAAA,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"]}