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

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 (148) hide show
  1. package/dist/cjs/index.cjs +22 -8
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +273 -149
  4. package/dist/cjs/lib/structures/MediaParser.cjs.map +1 -1
  5. package/dist/cjs/lib/structures/Middleware.cjs.map +1 -1
  6. package/dist/cjs/lib/structures/MiddlewareStore.cjs +2 -2
  7. package/dist/cjs/lib/structures/MiddlewareStore.cjs.map +1 -1
  8. package/dist/cjs/lib/structures/Route.cjs +17 -34
  9. package/dist/cjs/lib/structures/Route.cjs.map +1 -1
  10. package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs +20 -0
  11. package/dist/cjs/lib/structures/RouteLoaderStrategy.cjs.map +1 -0
  12. package/dist/cjs/lib/structures/RouteStore.cjs +4 -42
  13. package/dist/cjs/lib/structures/RouteStore.cjs.map +1 -1
  14. package/dist/cjs/lib/structures/api/ApiRequest.cjs +26 -0
  15. package/dist/cjs/lib/structures/api/ApiRequest.cjs.map +1 -1
  16. package/dist/cjs/lib/structures/api/ApiResponse.cjs +6 -0
  17. package/dist/cjs/lib/structures/api/ApiResponse.cjs.map +1 -1
  18. package/dist/cjs/lib/structures/api/CookieStore.cjs +3 -3
  19. package/dist/cjs/lib/structures/api/CookieStore.cjs.map +1 -1
  20. package/dist/cjs/lib/structures/http/HttpMethods.cjs +37 -6
  21. package/dist/cjs/lib/structures/http/HttpMethods.cjs.map +1 -1
  22. package/dist/cjs/lib/structures/http/Server.cjs +15 -14
  23. package/dist/cjs/lib/structures/http/Server.cjs.map +1 -1
  24. package/dist/cjs/lib/structures/router/RouterBranch.cjs +184 -0
  25. package/dist/cjs/lib/structures/router/RouterBranch.cjs.map +1 -0
  26. package/dist/cjs/lib/structures/router/RouterNode.cjs +67 -0
  27. package/dist/cjs/lib/structures/router/RouterNode.cjs.map +1 -0
  28. package/dist/cjs/lib/structures/router/RouterRoot.cjs +71 -0
  29. package/dist/cjs/lib/structures/router/RouterRoot.cjs.map +1 -0
  30. package/dist/cjs/listeners/PluginRouteError.cjs +2 -2
  31. package/dist/cjs/listeners/PluginRouteError.cjs.map +1 -1
  32. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs +2 -2
  33. package/dist/cjs/listeners/PluginServerMiddlewareError.cjs.map +1 -1
  34. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs +4 -4
  35. package/dist/cjs/listeners/PluginServerMiddlewareSuccess.cjs.map +1 -1
  36. package/dist/cjs/listeners/PluginServerRequest.cjs +41 -7
  37. package/dist/cjs/listeners/PluginServerRequest.cjs.map +1 -1
  38. package/dist/cjs/listeners/{PluginServerMatch.cjs → PluginServerRouterBranchMethodNotAllowed.cjs} +4 -9
  39. package/dist/cjs/listeners/PluginServerRouterBranchMethodNotAllowed.cjs.map +1 -0
  40. package/dist/cjs/listeners/{PluginServerNoMatch.cjs → PluginServerRouterBranchNotFound.cjs} +2 -2
  41. package/dist/cjs/listeners/PluginServerRouterBranchNotFound.cjs.map +1 -0
  42. package/dist/cjs/listeners/PluginServerRouterFound.cjs +21 -0
  43. package/dist/cjs/listeners/PluginServerRouterFound.cjs.map +1 -0
  44. package/dist/cjs/listeners/_load.cjs +6 -4
  45. package/dist/cjs/listeners/_load.cjs.map +1 -1
  46. package/dist/cjs/mediaParsers/applicationJson.cjs.map +1 -1
  47. package/dist/cjs/mediaParsers/textPlain.cjs.map +1 -1
  48. package/dist/cjs/middlewares/auth.cjs.map +1 -1
  49. package/dist/cjs/middlewares/body.cjs +4 -3
  50. package/dist/cjs/middlewares/body.cjs.map +1 -1
  51. package/dist/cjs/middlewares/cookies.cjs.map +1 -1
  52. package/dist/cjs/middlewares/headers.cjs +18 -8
  53. package/dist/cjs/middlewares/headers.cjs.map +1 -1
  54. package/dist/cjs/routes/_load.cjs +4 -4
  55. package/dist/cjs/routes/_load.cjs.map +1 -1
  56. package/dist/cjs/routes/oauth/{callback.cjs → callback.post.cjs} +3 -4
  57. package/dist/cjs/routes/oauth/callback.post.cjs.map +1 -0
  58. package/dist/cjs/routes/oauth/{logout.cjs → logout.post.cjs} +5 -7
  59. package/dist/cjs/routes/oauth/logout.post.cjs.map +1 -0
  60. package/dist/esm/{chunk-JTFKMR4I.mjs → chunk-S573YWRP.mjs} +3 -2
  61. package/dist/esm/index.d.mts +273 -149
  62. package/dist/esm/index.mjs +5 -3
  63. package/dist/esm/index.mjs.map +1 -1
  64. package/dist/esm/lib/structures/MediaParser.mjs +1 -1
  65. package/dist/esm/lib/structures/MediaParser.mjs.map +1 -1
  66. package/dist/esm/lib/structures/MediaParserStore.mjs +1 -1
  67. package/dist/esm/lib/structures/Middleware.mjs +1 -1
  68. package/dist/esm/lib/structures/Middleware.mjs.map +1 -1
  69. package/dist/esm/lib/structures/MiddlewareStore.mjs +3 -3
  70. package/dist/esm/lib/structures/MiddlewareStore.mjs.map +1 -1
  71. package/dist/esm/lib/structures/Route.mjs +18 -35
  72. package/dist/esm/lib/structures/Route.mjs.map +1 -1
  73. package/dist/esm/lib/structures/RouteLoaderStrategy.mjs +17 -0
  74. package/dist/esm/lib/structures/RouteLoaderStrategy.mjs.map +1 -0
  75. package/dist/esm/lib/structures/RouteStore.mjs +5 -43
  76. package/dist/esm/lib/structures/RouteStore.mjs.map +1 -1
  77. package/dist/esm/lib/structures/api/ApiRequest.mjs +27 -1
  78. package/dist/esm/lib/structures/api/ApiRequest.mjs.map +1 -1
  79. package/dist/esm/lib/structures/api/ApiResponse.mjs +7 -1
  80. package/dist/esm/lib/structures/api/ApiResponse.mjs.map +1 -1
  81. package/dist/esm/lib/structures/api/CookieStore.mjs +4 -4
  82. package/dist/esm/lib/structures/api/CookieStore.mjs.map +1 -1
  83. package/dist/esm/lib/structures/http/Auth.mjs +1 -1
  84. package/dist/esm/lib/structures/http/HttpCodes.mjs +1 -1
  85. package/dist/esm/lib/structures/http/HttpMethods.mjs +39 -5
  86. package/dist/esm/lib/structures/http/HttpMethods.mjs.map +1 -1
  87. package/dist/esm/lib/structures/http/Server.mjs +16 -15
  88. package/dist/esm/lib/structures/http/Server.mjs.map +1 -1
  89. package/dist/esm/lib/structures/router/RouterBranch.mjs +179 -0
  90. package/dist/esm/lib/structures/router/RouterBranch.mjs.map +1 -0
  91. package/dist/esm/lib/structures/router/RouterNode.mjs +56 -0
  92. package/dist/esm/lib/structures/router/RouterNode.mjs.map +1 -0
  93. package/dist/esm/lib/structures/router/RouterRoot.mjs +68 -0
  94. package/dist/esm/lib/structures/router/RouterRoot.mjs.map +1 -0
  95. package/dist/esm/lib/utils/MimeTypes.mjs +1 -1
  96. package/dist/esm/listeners/PluginRouteError.mjs +4 -4
  97. package/dist/esm/listeners/PluginRouteError.mjs.map +1 -1
  98. package/dist/esm/listeners/PluginServerMiddlewareError.mjs +4 -4
  99. package/dist/esm/listeners/PluginServerMiddlewareError.mjs.map +1 -1
  100. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs +6 -6
  101. package/dist/esm/listeners/PluginServerMiddlewareSuccess.mjs.map +1 -1
  102. package/dist/esm/listeners/PluginServerRequest.mjs +37 -9
  103. package/dist/esm/listeners/PluginServerRequest.mjs.map +1 -1
  104. package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs +18 -0
  105. package/dist/esm/listeners/PluginServerRouterBranchMethodNotAllowed.mjs.map +1 -0
  106. package/dist/esm/listeners/{PluginServerNoMatch.mjs → PluginServerRouterBranchNotFound.mjs} +4 -4
  107. package/dist/esm/listeners/PluginServerRouterBranchNotFound.mjs.map +1 -0
  108. package/dist/esm/listeners/PluginServerRouterFound.mjs +18 -0
  109. package/dist/esm/listeners/PluginServerRouterFound.mjs.map +1 -0
  110. package/dist/esm/listeners/_load.mjs +13 -11
  111. package/dist/esm/listeners/_load.mjs.map +1 -1
  112. package/dist/esm/mediaParsers/_load.mjs +1 -1
  113. package/dist/esm/mediaParsers/applicationFormUrlEncoded.mjs +1 -1
  114. package/dist/esm/mediaParsers/applicationJson.mjs +1 -1
  115. package/dist/esm/mediaParsers/applicationJson.mjs.map +1 -1
  116. package/dist/esm/mediaParsers/textPlain.mjs +1 -1
  117. package/dist/esm/mediaParsers/textPlain.mjs.map +1 -1
  118. package/dist/esm/middlewares/_load.mjs +1 -1
  119. package/dist/esm/middlewares/auth.mjs +1 -1
  120. package/dist/esm/middlewares/auth.mjs.map +1 -1
  121. package/dist/esm/middlewares/body.mjs +5 -4
  122. package/dist/esm/middlewares/body.mjs.map +1 -1
  123. package/dist/esm/middlewares/cookies.mjs +1 -1
  124. package/dist/esm/middlewares/cookies.mjs.map +1 -1
  125. package/dist/esm/middlewares/headers.mjs +19 -9
  126. package/dist/esm/middlewares/headers.mjs.map +1 -1
  127. package/dist/esm/register.mjs +1 -1
  128. package/dist/esm/routes/_load.mjs +3 -3
  129. package/dist/esm/routes/_load.mjs.map +1 -1
  130. package/dist/esm/routes/oauth/{callback.mjs → callback.post.mjs} +4 -5
  131. package/dist/esm/routes/oauth/callback.post.mjs.map +1 -0
  132. package/dist/esm/routes/oauth/{logout.mjs → logout.post.mjs} +5 -7
  133. package/dist/esm/routes/oauth/logout.post.mjs.map +1 -0
  134. package/package.json +4 -3
  135. package/dist/cjs/lib/utils/RouteData.cjs +0 -62
  136. package/dist/cjs/lib/utils/RouteData.cjs.map +0 -1
  137. package/dist/cjs/listeners/PluginServerMatch.cjs.map +0 -1
  138. package/dist/cjs/listeners/PluginServerNoMatch.cjs.map +0 -1
  139. package/dist/cjs/routes/oauth/callback.cjs.map +0 -1
  140. package/dist/cjs/routes/oauth/logout.cjs.map +0 -1
  141. package/dist/esm/lib/utils/RouteData.mjs +0 -56
  142. package/dist/esm/lib/utils/RouteData.mjs.map +0 -1
  143. package/dist/esm/listeners/PluginServerMatch.mjs +0 -23
  144. package/dist/esm/listeners/PluginServerMatch.mjs.map +0 -1
  145. package/dist/esm/listeners/PluginServerNoMatch.mjs.map +0 -1
  146. package/dist/esm/routes/oauth/callback.mjs.map +0 -1
  147. package/dist/esm/routes/oauth/logout.mjs.map +0 -1
  148. /package/dist/esm/{chunk-JTFKMR4I.mjs.map → chunk-S573YWRP.mjs.map} +0 -0
@@ -0,0 +1,179 @@
1
+ import { __name, __publicField } from '../../../chunk-S573YWRP.mjs';
2
+ import { isNullish } from '@sapphire/utilities';
3
+ import { RouterNode } from './RouterNode.mjs';
4
+
5
+ var _RouterBranch = class _RouterBranch {
6
+ constructor(name, dynamic, parent) {
7
+ /**
8
+ * The name of the branch.
9
+ */
10
+ __publicField(this, "name");
11
+ /**
12
+ * Whether or not the branch is dynamic.
13
+ */
14
+ __publicField(this, "dynamic");
15
+ /**
16
+ * The parent branch, if any.
17
+ */
18
+ __publicField(this, "parent");
19
+ /**
20
+ * The node this branch is associated with.
21
+ */
22
+ __publicField(this, "node", new RouterNode(this));
23
+ /**
24
+ * The methods supported by the branch's node or any of its children.
25
+ */
26
+ __publicField(this, "supportedMethods", []);
27
+ __publicField(this, "_staticChildren", []);
28
+ __publicField(this, "_dynamicChild", null);
29
+ this.name = name;
30
+ this.dynamic = dynamic;
31
+ this.parent = parent;
32
+ }
33
+ /**
34
+ * The path representing this branch
35
+ * @version 7.0.0
36
+ */
37
+ get path() {
38
+ return this.parent ? `${this.parent}/${this}` : `${this}`;
39
+ }
40
+ /**
41
+ * The branches the branch is associated with
42
+ * @version 7.0.0
43
+ */
44
+ get children() {
45
+ return this._staticChildren.concat(this._dynamicChild ?? []);
46
+ }
47
+ /**
48
+ * Whether or not the branch is empty
49
+ * @version 7.0.0
50
+ */
51
+ get empty() {
52
+ return this._staticChildren.length === 0 && this._dynamicChild === null;
53
+ }
54
+ /**
55
+ * Tries to find a branch given a path
56
+ * @version 7.0.0
57
+ *
58
+ * @param parts The parts of a path to find a node from
59
+ * @returns The branch found, or null if not found
60
+ */
61
+ find(parts) {
62
+ return this._find(parts, 0);
63
+ }
64
+ /**
65
+ * Checks if the given name matches the branch
66
+ * @version 7.0.0
67
+ *
68
+ * @param name The name to match
69
+ * @returns Whether or not the branch matches the name
70
+ */
71
+ matches(name) {
72
+ return this.dynamic || this.name === name;
73
+ }
74
+ /**
75
+ * Returns the string representation of the branch
76
+ * @version 7.0.0
77
+ *
78
+ * @returns The string representation of the branch
79
+ */
80
+ toString() {
81
+ return this.dynamic ? `[${this.name}]` : this.name;
82
+ }
83
+ *nodes() {
84
+ yield this.node;
85
+ for (const child of this._staticChildren) {
86
+ yield* child.nodes();
87
+ }
88
+ if (this._dynamicChild) {
89
+ yield* this._dynamicChild.nodes();
90
+ }
91
+ }
92
+ _add(parts, index, route) {
93
+ const result = this._performAdd(parts, index, route);
94
+ this._updateSupportedChildrenMethods();
95
+ return result;
96
+ }
97
+ _remove(parts, index, route) {
98
+ const result = this._performRemove(parts, index, route);
99
+ if (result) this._updateSupportedChildrenMethods();
100
+ return result;
101
+ }
102
+ _performAdd(parts, index, route) {
103
+ if (index >= parts.length) {
104
+ for (const method of route.methods) {
105
+ this.node.set(method, route);
106
+ }
107
+ return this.node;
108
+ }
109
+ const part = parts[index];
110
+ const child = this._staticChildren.find((branch2) => branch2.matches(part));
111
+ if (child) {
112
+ return child._add(parts, index + 1, route);
113
+ }
114
+ if (this._dynamicChild) {
115
+ return this._dynamicChild._add(parts, index + 1, route);
116
+ }
117
+ const dynamic = part.startsWith("[") && part.endsWith("]");
118
+ let branch;
119
+ if (dynamic) {
120
+ branch = new _RouterBranch(part.slice(1, -1), true, this);
121
+ this._dynamicChild = branch;
122
+ } else {
123
+ branch = new _RouterBranch(part, false, this);
124
+ this._staticChildren.push(branch);
125
+ }
126
+ return branch._add(parts, index + 1, route);
127
+ }
128
+ _performRemove(parts, index, route) {
129
+ if (index >= parts.length) {
130
+ let success = false;
131
+ for (const method of route.methods) {
132
+ if (this.node.delete(method, route)) {
133
+ success = true;
134
+ }
135
+ }
136
+ return success;
137
+ }
138
+ const part = parts[index];
139
+ const staticChildIndex = this._staticChildren.findIndex((branch) => branch.matches(part));
140
+ if (staticChildIndex === -1) {
141
+ const child = this._staticChildren[index];
142
+ const removed = child._remove(parts, index + 1, route);
143
+ if (removed && child.empty) {
144
+ this._staticChildren = this._staticChildren.filter((branch) => branch !== child);
145
+ }
146
+ return removed;
147
+ }
148
+ if (this._dynamicChild) {
149
+ const removed = this._dynamicChild._remove(parts, index + 1, route);
150
+ if (removed && this._dynamicChild.empty) {
151
+ this._dynamicChild = null;
152
+ }
153
+ return removed;
154
+ }
155
+ return false;
156
+ }
157
+ _find(parts, index) {
158
+ if (index >= parts.length) return this;
159
+ const part = parts[index];
160
+ const child = this._staticChildren.find((branch) => branch.matches(part)) ?? this._dynamicChild;
161
+ if (isNullish(child)) return null;
162
+ return child._find(parts, index + 1);
163
+ }
164
+ _updateSupportedChildrenMethods() {
165
+ const methods = new Set(this.node.methods());
166
+ for (const child of this.children) {
167
+ for (const method of child.node.methods()) {
168
+ methods.add(method);
169
+ }
170
+ }
171
+ this.supportedMethods = [...methods];
172
+ }
173
+ };
174
+ __name(_RouterBranch, "RouterBranch");
175
+ var RouterBranch = _RouterBranch;
176
+
177
+ export { RouterBranch };
178
+ //# sourceMappingURL=out.js.map
179
+ //# sourceMappingURL=RouterBranch.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/lib/structures/router/RouterBranch.ts"],"names":["branch"],"mappings":"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","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"]}
@@ -0,0 +1,56 @@
1
+ import { __name, __publicField, __privateAdd, __privateGet } from '../../../chunk-S573YWRP.mjs';
2
+ import { Collection } from 'discord.js';
3
+
4
+ var _methods;
5
+ var _RouterNode = class _RouterNode {
6
+ constructor(parent) {
7
+ /**
8
+ * The branch containing this node.
9
+ */
10
+ __publicField(this, "parent");
11
+ /**
12
+ * The methods this node supports.
13
+ */
14
+ __privateAdd(this, _methods, new Collection());
15
+ this.parent = parent;
16
+ }
17
+ get path() {
18
+ return this.parent.path;
19
+ }
20
+ extractParameters(parts) {
21
+ const parameters = {};
22
+ let branch = this.parent;
23
+ let index = parts.length - 1;
24
+ do {
25
+ if (branch.dynamic) parameters[branch.name] = parts[index];
26
+ branch = branch.parent;
27
+ --index;
28
+ } while (branch);
29
+ return parameters;
30
+ }
31
+ get(method) {
32
+ return __privateGet(this, _methods).get(method) ?? null;
33
+ }
34
+ set(method, route) {
35
+ __privateGet(this, _methods).set(method, route);
36
+ return this;
37
+ }
38
+ delete(method, route) {
39
+ const existing = __privateGet(this, _methods).get(method);
40
+ if (existing === route) {
41
+ __privateGet(this, _methods).delete(method);
42
+ return true;
43
+ }
44
+ return false;
45
+ }
46
+ methods() {
47
+ return __privateGet(this, _methods).keys();
48
+ }
49
+ };
50
+ _methods = new WeakMap();
51
+ __name(_RouterNode, "RouterNode");
52
+ var RouterNode = _RouterNode;
53
+
54
+ export { RouterNode };
55
+ //# sourceMappingURL=out.js.map
56
+ //# sourceMappingURL=RouterNode.mjs.map
@@ -0,0 +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"]}
@@ -0,0 +1,68 @@
1
+ import { __name } from '../../../chunk-S573YWRP.mjs';
2
+ import { isNullishOrEmpty } from '@sapphire/utilities';
3
+ import { RouterBranch } from './RouterBranch.mjs';
4
+
5
+ var _RouterRoot = class _RouterRoot extends RouterBranch {
6
+ constructor() {
7
+ super("::ROOT::", false, null);
8
+ }
9
+ /**
10
+ * Adds a route to the branch
11
+ *
12
+ * @param route The route to add
13
+ * @returns The node the route was added to
14
+ */
15
+ add(route) {
16
+ return this._add(route.path, 0, route);
17
+ }
18
+ /**
19
+ * Removes a route from the branch
20
+ *
21
+ * @param route The route to remove
22
+ * @returns Whether or not the route was removed
23
+ */
24
+ remove(route) {
25
+ return this._remove(route.path, 0, route);
26
+ }
27
+ // eslint-disable-next-line @typescript-eslint/class-literal-property-style
28
+ get path() {
29
+ return "";
30
+ }
31
+ toString() {
32
+ return "";
33
+ }
34
+ static normalize(path) {
35
+ const parts = [];
36
+ if (isNullishOrEmpty(path)) return parts;
37
+ let part = "";
38
+ for (const char of path) {
39
+ if (char === "/") {
40
+ if (part.length) {
41
+ parts.push(part);
42
+ part = "";
43
+ }
44
+ } else {
45
+ part += char;
46
+ }
47
+ }
48
+ if (part.length) {
49
+ parts.push(part);
50
+ part = "";
51
+ }
52
+ return parts;
53
+ }
54
+ static extractMethod(path) {
55
+ if (path.length === 0) return null;
56
+ const lastIndex = path.length - 1;
57
+ const last = path[lastIndex];
58
+ const methodIndex = last.lastIndexOf(".");
59
+ if (methodIndex === -1 || methodIndex === last.length - 1) return null;
60
+ return last.slice(methodIndex + 1).toUpperCase();
61
+ }
62
+ };
63
+ __name(_RouterRoot, "RouterRoot");
64
+ var RouterRoot = _RouterRoot;
65
+
66
+ export { RouterRoot };
67
+ //# sourceMappingURL=out.js.map
68
+ //# sourceMappingURL=RouterRoot.mjs.map
@@ -0,0 +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,4 +1,4 @@
1
- import '../../chunk-JTFKMR4I.mjs';
1
+ import '../../chunk-S573YWRP.mjs';
2
2
 
3
3
  // src/lib/utils/MimeTypes.ts
4
4
  var MimeTypes = /* @__PURE__ */ ((MimeTypes2) => {
@@ -1,13 +1,13 @@
1
- import { __name } from '../chunk-JTFKMR4I.mjs';
1
+ import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { Listener } from '@sapphire/framework';
3
3
  import { HttpCodes } from '../lib/structures/http/HttpCodes.mjs';
4
- import { ServerEvents } from '../lib/structures/http/Server.mjs';
4
+ import { ServerEvent } from '../lib/structures/http/Server.mjs';
5
5
 
6
6
  var _PluginListener = class _PluginListener extends Listener {
7
7
  constructor(context) {
8
- super(context, { emitter: "server", event: ServerEvents.RouteError });
8
+ super(context, { emitter: "server", event: ServerEvent.RouteError });
9
9
  }
10
- run(error, { response }) {
10
+ run(error, _request, response) {
11
11
  this.container.logger.fatal(error);
12
12
  if (!response.writableEnded) response.status(HttpCodes.InternalServerError).json({ error: error.message ?? error });
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginRouteError.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,oBAAiD;AAEnD,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,aAAa,WAAW,CAAC;AAAA,EACrE;AAAA,EAEgB,IAAI,OAAc,EAAE,SAAS,GAA2B;AAEvE,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 { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { ServerEvents, type MiddlewareErrorContext } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvents.RouteError });\n\t}\n\n\tpublic override run(error: Error, { response }: MiddlewareErrorContext) {\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":";;;;;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,13 +1,13 @@
1
- import { __name } from '../chunk-JTFKMR4I.mjs';
1
+ import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { Listener } from '@sapphire/framework';
3
3
  import { HttpCodes } from '../lib/structures/http/HttpCodes.mjs';
4
- import { ServerEvents } from '../lib/structures/http/Server.mjs';
4
+ import { ServerEvent } from '../lib/structures/http/Server.mjs';
5
5
 
6
6
  var _PluginListener = class _PluginListener extends Listener {
7
7
  constructor(context) {
8
- super(context, { emitter: "server", event: ServerEvents.MiddlewareError });
8
+ super(context, { emitter: "server", event: ServerEvent.MiddlewareError });
9
9
  }
10
- run(error, { response }) {
10
+ run(error, _request, response) {
11
11
  this.container.logger.fatal(error);
12
12
  if (!response.writableEnded) response.status(HttpCodes.InternalServerError).json({ error: error.message ?? error });
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareError.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,oBAAiD;AAEnD,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,aAAa,gBAAgB,CAAC;AAAA,EAC1E;AAAA,EAEgB,IAAI,OAAc,EAAE,SAAS,GAA2B;AAEvE,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 { HttpCodes } from '../lib/structures/http/HttpCodes';\nimport { ServerEvents, type MiddlewareErrorContext } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvents.MiddlewareError });\n\t}\n\n\tpublic override run(error: Error, { response }: MiddlewareErrorContext) {\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":";;;;;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,16 +1,16 @@
1
- import { __name } from '../chunk-JTFKMR4I.mjs';
1
+ import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { Listener } from '@sapphire/framework';
3
- import { ServerEvents } from '../lib/structures/http/Server.mjs';
3
+ import { ServerEvent } from '../lib/structures/http/Server.mjs';
4
4
 
5
5
  var _PluginListener = class _PluginListener extends Listener {
6
6
  constructor(context) {
7
- super(context, { emitter: "server", event: ServerEvents.MiddlewareSuccess });
7
+ super(context, { emitter: "server", event: ServerEvent.MiddlewareSuccess });
8
8
  }
9
- async run(request, response, match) {
9
+ async run(request, response) {
10
10
  try {
11
- await match.cb(request, response);
11
+ await request.route.run(request, response);
12
12
  } catch (error) {
13
- this.container.server.emit(ServerEvents.RouteError, error, { request, response, match });
13
+ this.container.server.emit(ServerEvent.RouteError, error, request, response);
14
14
  }
15
15
  }
16
16
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginServerMiddlewareSuccess.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAIzB,SAAS,oBAAoB;AAEtB,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,aAAa,kBAAkB,CAAC;AAAA,EAC5E;AAAA,EAEA,MAAsB,IAAI,SAAqB,UAAuB,OAAmB;AACxF,QAAI;AACH,YAAM,MAAM,GAAG,SAAS,QAAQ;AAAA,IACjC,SAAS,OAAO;AACf,WAAK,UAAU,OAAO,KAAK,aAAa,YAAY,OAAO,EAAE,SAAS,UAAU,MAAM,CAAC;AAAA,IACxF;AAAA,EACD;AACD;AAZ6C;AAAtC,IAAM,iBAAN","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { RouteMatch } from '../lib/structures/RouteStore';\nimport type { ApiRequest } from '../lib/structures/api/ApiRequest';\nimport type { ApiResponse } from '../lib/structures/api/ApiResponse';\nimport { ServerEvents } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvents.MiddlewareSuccess });\n\t}\n\n\tpublic override async run(request: ApiRequest, response: ApiResponse, match: RouteMatch) {\n\t\ttry {\n\t\t\tawait match.cb(request, response);\n\t\t} catch (error) {\n\t\t\tthis.container.server.emit(ServerEvents.RouteError, error, { request, response, match });\n\t\t}\n\t}\n}\n"]}
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,26 +1,54 @@
1
- import { __name } from '../chunk-JTFKMR4I.mjs';
1
+ import { __name, __privateAdd, __privateMethod } from '../chunk-S573YWRP.mjs';
2
2
  import { Listener } from '@sapphire/framework';
3
- import { ServerEvents } from '../lib/structures/http/Server.mjs';
3
+ import { ServerEvent } from '../lib/structures/http/Server.mjs';
4
+ import { RouterRoot } from '../lib/structures/router/RouterRoot.mjs';
4
5
 
6
+ var _PluginListener_instances, parseURL_fn;
5
7
  var _PluginListener = class _PluginListener extends Listener {
6
8
  constructor(context) {
7
- super(context, { emitter: "server", event: ServerEvents.Request });
9
+ super(context, { emitter: "server", event: ServerEvent.Request });
10
+ __privateAdd(this, _PluginListener_instances);
8
11
  }
9
12
  async run(request, response) {
10
- const match = this.container.server.routes.match(request);
13
+ const { parts, querystring } = __privateMethod(this, _PluginListener_instances, parseURL_fn).call(this, request.url);
14
+ request.query = Object.fromEntries(new URLSearchParams(querystring).entries());
15
+ const branch = this.container.server.routes.router.find(parts);
16
+ const node = branch ? branch.node : null;
17
+ const route = node ? node.get(request.method ?? "GET") : null;
18
+ if (node !== null) {
19
+ request.params = node.extractParameters(parts);
20
+ }
21
+ request.routerNode = node;
22
+ request.route = route;
11
23
  try {
12
- await this.container.server.middlewares.run(request, response, match?.route ?? null);
24
+ await this.container.server.middlewares.run(request, response);
13
25
  } catch (error) {
14
- this.container.server.emit(ServerEvents.MiddlewareError, error, { request, response, match });
26
+ this.container.server.emit(ServerEvent.MiddlewareError, error, request, response);
15
27
  return;
16
28
  }
17
- if (match === null) {
18
- this.container.server.emit(ServerEvents.NoMatch, request, response);
29
+ if (branch === null) {
30
+ this.container.server.emit(ServerEvent.RouterBranchNotFound, request, response);
31
+ } else if (route === null) {
32
+ this.container.server.emit(ServerEvent.RouterBranchMethodNotAllowed, request, response);
19
33
  } else {
20
- this.container.server.emit(ServerEvents.Match, request, response, match);
34
+ this.container.server.emit(ServerEvent.RouterFound, request, response);
21
35
  }
22
36
  }
23
37
  };
38
+ _PluginListener_instances = new WeakSet();
39
+ parseURL_fn = /* @__PURE__ */ __name(function(url = "") {
40
+ const index = url.indexOf("?");
41
+ let pathname;
42
+ let querystring;
43
+ if (index === -1) {
44
+ pathname = url;
45
+ querystring = "";
46
+ } else {
47
+ pathname = url.substring(0, index);
48
+ querystring = url.substring(index + 1);
49
+ }
50
+ return { parts: RouterRoot.normalize(pathname), querystring };
51
+ }, "#parseURL");
24
52
  __name(_PluginListener, "PluginListener");
25
53
  var PluginListener = _PluginListener;
26
54
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/listeners/PluginServerRequest.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAGzB,SAAS,oBAAoB;AAEtB,IAAM,kBAAN,MAAM,wBAAuB,SAAS;AAAA,EACrC,YAAY,SAAiC;AACnD,UAAM,SAAS,EAAE,SAAS,UAAU,OAAO,aAAa,QAAQ,CAAC;AAAA,EAClE;AAAA,EAEA,MAAsB,IAAI,SAAqB,UAAuB;AACrE,UAAM,QAAQ,KAAK,UAAU,OAAO,OAAO,MAAM,OAAO;AAExD,QAAI;AAEH,YAAM,KAAK,UAAU,OAAO,YAAY,IAAI,SAAS,UAAU,OAAO,SAAS,IAAI;AAAA,IACpF,SAAS,OAAO;AACf,WAAK,UAAU,OAAO,KAAK,aAAa,iBAAiB,OAAO,EAAE,SAAS,UAAU,MAAM,CAAC;AAG5F;AAAA,IACD;AAEA,QAAI,UAAU,MAAM;AACnB,WAAK,UAAU,OAAO,KAAK,aAAa,SAAS,SAAS,QAAQ;AAAA,IACnE,OAAO;AACN,WAAK,UAAU,OAAO,KAAK,aAAa,OAAO,SAAS,UAAU,KAAK;AAAA,IACxE;AAAA,EACD;AACD;AAxB6C;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 { ServerEvents } from '../lib/structures/http/Server';\n\nexport class PluginListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { emitter: 'server', event: ServerEvents.Request });\n\t}\n\n\tpublic override async run(request: ApiRequest, response: ApiResponse) {\n\t\tconst match = this.container.server.routes.match(request);\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, match?.route ?? null);\n\t\t} catch (error) {\n\t\t\tthis.container.server.emit(ServerEvents.MiddlewareError, error, { request, response, match });\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 (match === null) {\n\t\t\tthis.container.server.emit(ServerEvents.NoMatch, request, response);\n\t\t} else {\n\t\t\tthis.container.server.emit(ServerEvents.Match, request, response, match);\n\t\t}\n\t}\n}\n"]}
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"]}
@@ -0,0 +1,18 @@
1
+ import { __name } from '../chunk-S573YWRP.mjs';
2
+ import { Listener } from '@sapphire/framework';
3
+ import { ServerEvent } from '../lib/structures/http/Server.mjs';
4
+
5
+ var _PluginListener = class _PluginListener extends Listener {
6
+ constructor(context) {
7
+ super(context, { emitter: "server", event: ServerEvent.RouterBranchMethodNotAllowed });
8
+ }
9
+ run(_, response) {
10
+ if (!response.writableEnded) response.methodNotAllowed();
11
+ }
12
+ };
13
+ __name(_PluginListener, "PluginListener");
14
+ var PluginListener = _PluginListener;
15
+
16
+ export { PluginListener };
17
+ //# sourceMappingURL=out.js.map
18
+ //# sourceMappingURL=PluginServerRouterBranchMethodNotAllowed.mjs.map
@@ -0,0 +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,10 +1,10 @@
1
- import { __name } from '../chunk-JTFKMR4I.mjs';
1
+ import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { Listener } from '@sapphire/framework';
3
- import { ServerEvents } from '../lib/structures/http/Server.mjs';
3
+ import { ServerEvent } from '../lib/structures/http/Server.mjs';
4
4
 
5
5
  var _PluginListener = class _PluginListener extends Listener {
6
6
  constructor(context) {
7
- super(context, { emitter: "server", event: ServerEvents.NoMatch });
7
+ super(context, { emitter: "server", event: ServerEvent.RouterBranchNotFound });
8
8
  }
9
9
  run(_, response) {
10
10
  if (!response.writableEnded) response.notFound();
@@ -15,4 +15,4 @@ var PluginListener = _PluginListener;
15
15
 
16
16
  export { PluginListener };
17
17
  //# sourceMappingURL=out.js.map
18
- //# sourceMappingURL=PluginServerNoMatch.mjs.map
18
+ //# sourceMappingURL=PluginServerRouterBranchNotFound.mjs.map
@@ -0,0 +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"]}
@@ -0,0 +1,18 @@
1
+ import { __name } from '../chunk-S573YWRP.mjs';
2
+ import { Listener } from '@sapphire/framework';
3
+ import { ServerEvent } from '../lib/structures/http/Server.mjs';
4
+
5
+ var _PluginListener = class _PluginListener extends Listener {
6
+ constructor(context) {
7
+ super(context, { emitter: "server", event: ServerEvent.RouterFound });
8
+ }
9
+ run(request, response) {
10
+ this.container.server.emit(response.writableEnded ? ServerEvent.MiddlewareFailure : ServerEvent.MiddlewareSuccess, request, response);
11
+ }
12
+ };
13
+ __name(_PluginListener, "PluginListener");
14
+ var PluginListener = _PluginListener;
15
+
16
+ export { PluginListener };
17
+ //# sourceMappingURL=out.js.map
18
+ //# sourceMappingURL=PluginServerRouterFound.mjs.map
@@ -0,0 +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,20 +1,22 @@
1
- import { __name } from '../chunk-JTFKMR4I.mjs';
1
+ import { __name } from '../chunk-S573YWRP.mjs';
2
2
  import { container } from '@sapphire/pieces';
3
3
  import { PluginListener } from './PluginRouteError.mjs';
4
- import { PluginListener as PluginListener$1 } from './PluginServerMatch.mjs';
5
- import { PluginListener as PluginListener$2 } from './PluginServerMiddlewareError.mjs';
6
- import { PluginListener as PluginListener$3 } from './PluginServerMiddlewareSuccess.mjs';
7
- import { PluginListener as PluginListener$4 } from './PluginServerNoMatch.mjs';
8
- import { PluginListener as PluginListener$5 } from './PluginServerRequest.mjs';
4
+ import { PluginListener as PluginListener$1 } from './PluginServerMiddlewareError.mjs';
5
+ import { PluginListener as PluginListener$2 } from './PluginServerMiddlewareSuccess.mjs';
6
+ import { PluginListener as PluginListener$3 } from './PluginServerRequest.mjs';
7
+ import { PluginListener as PluginListener$4 } from './PluginServerRouterBranchMethodNotAllowed.mjs';
8
+ import { PluginListener as PluginListener$5 } from './PluginServerRouterBranchNotFound.mjs';
9
+ import { PluginListener as PluginListener$6 } from './PluginServerRouterFound.mjs';
9
10
 
10
11
  function loadListeners() {
11
12
  const store = "listeners";
12
13
  void container.stores.loadPiece({ name: "PluginRouteError", piece: PluginListener, store });
13
- void container.stores.loadPiece({ name: "PluginServerMatch", piece: PluginListener$1, store });
14
- void container.stores.loadPiece({ name: "PluginServerMiddlewareError", piece: PluginListener$2, store });
15
- void container.stores.loadPiece({ name: "PluginServerMiddlewareSuccess", piece: PluginListener$3, store });
16
- void container.stores.loadPiece({ name: "PluginServerNoMatch", piece: PluginListener$4, store });
17
- void container.stores.loadPiece({ name: "PluginServerRequest", piece: PluginListener$5, store });
14
+ void container.stores.loadPiece({ name: "PluginServerMiddlewareError", piece: PluginListener$1, store });
15
+ void container.stores.loadPiece({ name: "PluginServerMiddlewareSuccess", piece: PluginListener$2, store });
16
+ void container.stores.loadPiece({ name: "PluginServerRequest", piece: PluginListener$3, store });
17
+ void container.stores.loadPiece({ name: "PluginServerRouterBranchMethodNotAllowed", piece: PluginListener$4, store });
18
+ void container.stores.loadPiece({ name: "PluginServerRouterBranchNotFound", piece: PluginListener$5, store });
19
+ void container.stores.loadPiece({ name: "PluginServerRouterFound", piece: PluginListener$6, store });
18
20
  }
19
21
  __name(loadListeners, "loadListeners");
20
22