@wolfstar/plugin-api 1.1.4 → 1.1.5-next-20260904173601

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index-D-l34LxR.d.ts","names":[],"sources":["../../src/lib/http/ApiResponse.ts","../../src/lib/http/HttpMethod.ts","../../src/lib/structures/Route.ts","../../src/lib/structures/router/RouterNode.ts","../../src/lib/structures/router/RouterBranch.ts","../../src/lib/http/ApiRequest.ts","../../src/lib/structures/Middleware.ts","../../src/lib/structures/MiddlewareStore.ts","../../src/lib/structures/router/RouterRoot.ts","../../src/lib/structures/RouteStore.ts","../../src/lib/http/ApiServer.ts","../../src/listeners/_load.ts","../../src/middlewares/_load.ts","../../src/index.ts"],"mappings":";;;;;cAIa,oBAAoB,eAAe;EACvC,OAAO;EAKP,KAAK,eAAe;EAQpB,KAAK,cAAc;EAQnB;EAMA,SAAS;EAIT,iBAAiB;EAIjB,WAAW;EAIX,MACL,qBACA;;;;;;;cC3CS;KAED,qBAAqB;;;KCCrB,UAAU,KAAK,IAAI,YAAY;;;;;;;;uBASrB,MAAM,gBAAgB,MAAM,UAAU,MAAM,iBAAiB,MACjF;;;;WAMgB;;;;WAKA,SAAS,YAAY;EAElB,YAAA,SAAS,MAAM,eAAe,SAAS;;;;;WA6B1C,IAAI,SAAS,YAAY,UAAU,cAAc;;kBAGlD;OACH,gBAAgB,MAAM;YAEjB,gBAAgB;;;;;IAK/B;;;;;IAMA,mBAAmB;;;;;;;;cCpEV,mBAAmB,IAAI,YAAY;WAC9B,QAAQ;EAEL,YAAA,QAAQ;;;;;EASpB,kBAAkB,2BAA2B;;;;;;;;;cCXzC;WACK;WACA;WACA,QAAQ;WACR,MAAM;mBAEL;UACT;EAEW,YAAA,cAAc,kBAAkB,QAAQ;EAOpD,QAAQ;YAIL,SAAS,0BAA0B,eAAe,OAAO,QAAQ;YAyBjE,SAAS,0BAA0B,eAAe,OAAO;YAcz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AAS;;;;EA0BrB,WAAW;;;;EAoBX,cAAc;;;;;;;;iBCnHD,iBAAiB;;;;;;iBCLjB,mBAAmB;;;;YCa7B;;;;IAIR,MAAM;;;;YAKE;IACR,QAAQ;IACR,aAAa;;YAGL;;;;;IAKR,QAAQ"}
1
+ {"version":3,"file":"index-D-l34LxR.d.ts","names":[],"sources":["../../src/lib/http/ApiResponse.ts","../../src/lib/http/HttpMethod.ts","../../src/lib/structures/Route.ts","../../src/lib/structures/router/RouterNode.ts","../../src/lib/structures/router/RouterBranch.ts","../../src/lib/http/ApiRequest.ts","../../src/lib/structures/Middleware.ts","../../src/lib/structures/MiddlewareStore.ts","../../src/lib/structures/router/RouterRoot.ts","../../src/lib/structures/RouteStore.ts","../../src/lib/http/ApiServer.ts","../../src/listeners/_load.ts","../../src/middlewares/_load.ts","../../src/index.ts"],"mappings":";;;;;cAIa,oBAAoB,eAAe;EACvC,OAAO;EAKP,KAAK,eAAe;EAQpB,KAAK,cAAc;EAQnB;EAMA,SAAS;EAIT,iBAAiB;EAIjB,WAAW;EAIX,MACL,qBACA;;;;;;;cC3CS;KAED,qBAAqB;;;KCCrB,UAAU,KAAK,IAAI,YAAY;;;;;;;;uBASrB,MAAM,gBAAgB,MAAM,UAAU,MAAM,iBAAiB,MACjF;;;;WAMgB;;;;WAKA,SAAS,YAAY;EAErC,YAAmB,SAAS,MAAM,eAAe,SAAS;;;;;WA6B1C,IAAI,SAAS,YAAY,UAAU,cAAc;;kBAGlD;OACH,gBAAgB,MAAM;YAEjB,gBAAgB;;;;;IAK/B;;;;;IAMA,mBAAmB;;;;;;;;cCpEV,mBAAmB,IAAI,YAAY;WAC9B,QAAQ;EAExB,YAAmB,QAAQ;;;;;EASpB,kBAAkB,2BAA2B;;;;;;;;;cCXzC;WACK;WACA;WACA,QAAQ;WACR,MAAM;mBAEL;UACT;EAER,YAAmB,cAAc,kBAAkB,QAAQ;EAOpD,QAAQ;YAIL,SAAS,0BAA0B,eAAe,OAAO,QAAQ;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Aa;WACb,QAAQ,cAAsB,mBAAmB;WACjD,SAAS;EAEzB,YAAmB,UAAS;;;;EA0BrB,WAAW;;;;EAoBX,cAAc;;;;;;;;iBCnHD,iBAAiB;;;;;;iBCLjB,mBAAmB;;;;YCa7B;;;;IAIR,MAAM;;;;YAKE;IACR,QAAQ;IACR,aAAa;;YAGL;;;;;IAKR,QAAQ"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as RouteStore, c as RouterBranch, d as MiddlewareStore, f as Middleware, i as ApiServerEvent, l as RouterNode, m as ApiRequest, n as loadListeners, o as Route, p as ApiResponse, r as ApiServer, s as RouterRoot, t as loadMiddlewares, u as HttpMethods } from "./src-CscMIChC.js";
1
+ import { a as RouteStore, c as RouterBranch, d as MiddlewareStore, f as Middleware, i as ApiServerEvent, l as RouterNode, m as ApiRequest, n as loadListeners, o as Route, p as ApiResponse, r as ApiServer, s as RouterRoot, t as loadMiddlewares, u as HttpMethods } from "./src-DPwBQpLA.js";
2
2
 
3
3
  export { ApiRequest, ApiResponse, ApiServer, ApiServerEvent, HttpMethods, Middleware, MiddlewareStore, Route, RouteStore, RouterBranch, RouterNode, RouterRoot, loadListeners, loadMiddlewares };
@@ -1,4 +1,4 @@
1
- import { n as loadListeners, r as ApiServer, t as loadMiddlewares } from "./src-CscMIChC.js";
1
+ import { n as loadListeners, r as ApiServer, t as loadMiddlewares } from "./src-DPwBQpLA.js";
2
2
  import { Client, Plugin, container, postInitialization, postListen } from "@wolfstar/http-framework";
3
3
 
4
4
  //#region src/register.ts
@@ -25,7 +25,7 @@ var ApiRequest = class extends IncomingMessage {
25
25
  * Reads the full request body as a UTF-8 string.
26
26
  * @param limit The maximum number of bytes to read before rejecting. Defaults to 1 MiB.
27
27
  */
28
- async readBodyText(limit = 1024 * 1024) {
28
+ async readBodyText(limit = 1048576) {
29
29
  const chunks = [];
30
30
  let size = 0;
31
31
  for await (const chunk of this) {
@@ -616,7 +616,7 @@ var BodyMiddleware = class extends Middleware {
616
616
  super(context, { position: 20 });
617
617
  }
618
618
  run(request, response) {
619
- const limit = container.server.options.maximumBodyLength ?? 1024 * 1024 * 50;
619
+ const limit = container.server.options.maximumBodyLength ?? 52428800;
620
620
  if (Number(request.headers["content-length"] ?? 0) > limit) response.json({ error: "Payload Too Large" }, HttpCodes.PayloadTooLarge);
621
621
  }
622
622
  };
@@ -661,4 +661,4 @@ async function loadMiddlewares() {
661
661
 
662
662
  //#endregion
663
663
  export { RouteStore as a, RouterBranch as c, MiddlewareStore as d, Middleware as f, ApiServerEvent as i, RouterNode as l, ApiRequest as m, loadListeners as n, Route as o, ApiResponse as p, ApiServer as r, RouterRoot as s, loadMiddlewares as t, HttpMethods as u };
664
- //# sourceMappingURL=src-CscMIChC.js.map
664
+ //# sourceMappingURL=src-DPwBQpLA.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"src-CscMIChC.js","names":[],"sources":["../../src/lib/http/ApiRequest.ts","../../src/lib/http/ApiResponse.ts","../../src/lib/structures/Middleware.ts","../../src/lib/structures/MiddlewareStore.ts","../../src/lib/http/HttpMethod.ts","../../src/lib/structures/router/RouterNode.ts","../../src/lib/structures/router/RouterBranch.ts","../../src/lib/structures/router/RouterRoot.ts","../../src/lib/structures/Route.ts","../../src/lib/structures/RouteLoaderStrategy.ts","../../src/lib/structures/RouteStore.ts","../../src/lib/http/ApiServer.ts","../../src/listeners/PluginRouteError.ts","../../src/listeners/PluginServerMiddlewareError.ts","../../src/listeners/PluginServerRequest.ts","../../src/listeners/PluginServerRouterBranchMethodNotAllowed.ts","../../src/listeners/PluginServerRouterBranchNotFound.ts","../../src/listeners/PluginServerRouterFound.ts","../../src/listeners/_load.ts","../../src/middlewares/body.ts","../../src/middlewares/headers.ts","../../src/middlewares/_load.ts"],"sourcesContent":["import { IncomingMessage } from \"node:http\";\nimport type { Route } from \"../structures/Route\";\nimport type { RouterBranch } from \"../structures/router/RouterBranch\";\n\nexport class ApiRequest extends IncomingMessage {\n /**\n * The parsed query string parameters.\n */\n public query: URLSearchParams = new URLSearchParams();\n\n /**\n * The extracted dynamic (`[param]`) path segment values.\n */\n public params: Record<string, string> = {};\n\n /**\n * The matched router branch for this request's pathname, if any.\n */\n public routerNode: RouterBranch | null = null;\n\n /**\n * The matched route for this request's pathname and method, if any.\n */\n public route: Route | null = null;\n\n /**\n * Reads the full request body as a UTF-8 string.\n * @param limit The maximum number of bytes to read before rejecting. Defaults to 1 MiB.\n */\n public async readBodyText(limit = 1024 * 1024): Promise<string> {\n const chunks: Buffer[] = [];\n let size = 0;\n\n for await (const chunk of this) {\n size += (chunk as Buffer).length;\n if (size > limit) throw new RangeError(`Request body exceeded the ${limit} byte limit`);\n chunks.push(chunk as Buffer);\n }\n\n return Buffer.concat(chunks).toString(\"utf8\");\n }\n\n /**\n * Reads and parses the request body as JSON.\n * @param limit The maximum number of bytes to read before rejecting. Defaults to 1 MiB.\n */\n public async readBodyJson<T = unknown>(limit?: number): Promise<T> {\n const text = await this.readBodyText(limit);\n return JSON.parse(text) as T;\n }\n}\n","import { ServerResponse } from \"node:http\";\nimport { HttpCodes } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"./ApiRequest\";\n\nexport class ApiResponse extends ServerResponse<ApiRequest> {\n public status(statusCode: number): this {\n this.statusCode = statusCode;\n return this;\n }\n\n public json(body: unknown, statusCode: number = HttpCodes.OK): this {\n this.statusCode = statusCode;\n if (!this.hasHeader(\"Content-Type\"))\n this.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n this.end(JSON.stringify(body));\n return this;\n }\n\n public text(body: string, statusCode: number = HttpCodes.OK): this {\n this.statusCode = statusCode;\n if (!this.hasHeader(\"Content-Type\"))\n this.setHeader(\"Content-Type\", \"text/plain; charset=utf-8\");\n this.end(body);\n return this;\n }\n\n public noContent(): this {\n this.statusCode = HttpCodes.NoContent;\n this.end();\n return this;\n }\n\n public notFound(body: unknown = { error: \"Not Found\" }): this {\n return this.json(body, HttpCodes.NotFound);\n }\n\n public methodNotAllowed(body: unknown = { error: \"Method Not Allowed\" }): this {\n return this.json(body, HttpCodes.MethodNotAllowed);\n }\n\n public badRequest(body: unknown = { error: \"Bad Request\" }): this {\n return this.json(body, HttpCodes.BadRequest);\n }\n\n public error(\n statusCode: number = HttpCodes.InternalServerError,\n body: unknown = { error: \"Internal Server Error\" },\n ): this {\n return this.json(body, statusCode);\n }\n}\n","import { Piece, type PieceOptions } from \"@sapphire/pieces\";\nimport type { ApiRequest } from \"../http/ApiRequest\";\nimport type { ApiResponse } from \"../http/ApiResponse\";\nimport type { Awaitable } from \"./Route\";\n\n/**\n * A piece that runs on every incoming request, in ascending {@link Middleware.position} order,\n * before route dispatch. A middleware stops the chain implicitly by ending the response\n * (`response.writableEnded`); there is no explicit `next()` callback.\n */\nexport abstract class Middleware<\n Options extends Middleware.Options = Middleware.Options,\n> extends Piece<Options, \"middlewares\"> {\n /**\n * The built-in middlewares use the following positions:\n * - `headers`: 10 (CORS headers, 404/405 short-circuit)\n * - `body`: 20 (`Content-Length` validation)\n */\n public readonly position: number;\n\n public constructor(context: Middleware.LoaderContext, options: Options) {\n super(context, options);\n this.position = options.position ?? 1000;\n }\n\n public abstract run(request: ApiRequest, response: ApiResponse): Awaitable<unknown>;\n}\n\nexport namespace Middleware {\n export type LoaderContext = Piece.LoaderContext<\"middlewares\">;\n\n export interface Options extends PieceOptions {\n /**\n * Middlewares run in ascending order of this value.\n * @default 1000\n */\n position?: number;\n }\n}\n","import { Store } from \"@sapphire/pieces\";\nimport type { ApiRequest } from \"../http/ApiRequest\";\nimport type { ApiResponse } from \"../http/ApiResponse\";\nimport { Middleware } from \"./Middleware\";\n\nexport class MiddlewareStore extends Store<Middleware, \"middlewares\"> {\n /**\n * Enabled middlewares, kept sorted in ascending {@link Middleware.position} order.\n */\n public readonly sortedMiddlewares: Middleware[] = [];\n\n public constructor() {\n super(Middleware, { name: \"middlewares\" });\n }\n\n /**\n * Runs every enabled middleware in order, stopping early once the response has ended.\n */\n public async run(request: ApiRequest, response: ApiResponse): Promise<void> {\n for (const middleware of this.sortedMiddlewares) {\n if (response.writableEnded) return;\n if (middleware.enabled) await middleware.run(request, response);\n }\n }\n\n public override set(key: string, value: Middleware): this {\n const index = this.sortedMiddlewares.findIndex(\n (middleware) => middleware.position >= value.position,\n );\n if (index === -1) this.sortedMiddlewares.push(value);\n else this.sortedMiddlewares.splice(index, 0, value);\n\n return super.set(key, value);\n }\n\n public override delete(key: string): boolean {\n const index = this.sortedMiddlewares.findIndex((middleware) => middleware.name === key);\n if (index !== -1) this.sortedMiddlewares.splice(index, 1);\n\n return super.delete(key);\n }\n\n public override clear(): void {\n this.sortedMiddlewares.length = 0;\n super.clear();\n }\n}\n","/**\n * The HTTP methods that a {@link Route} can be registered for.\n */\nexport const HttpMethods = [\"DELETE\", \"GET\", \"HEAD\", \"OPTIONS\", \"PATCH\", \"POST\", \"PUT\"] as const;\n\nexport type HttpMethod = (typeof HttpMethods)[number];\n","import type { HttpMethod } from \"../../http/HttpMethod\";\nimport type { Route } from \"../Route\";\nimport type { RouterBranch } from \"./RouterBranch\";\n\n/**\n * A single path segment's registered routes, keyed by HTTP method.\n */\nexport class RouterNode extends Map<HttpMethod, Route> {\n public readonly branch: RouterBranch;\n\n public constructor(branch: RouterBranch) {\n super();\n this.branch = branch;\n }\n\n /**\n * Walks up the branch chain collecting the values captured by dynamic (`[param]`) segments.\n * @param parts The path segments of the matched request, in the same order used to reach this node.\n */\n public extractParameters(parts: readonly string[]): Record<string, string> {\n const params: Record<string, string> = {};\n\n let branch: RouterBranch | null = this.branch;\n let index = parts.length - 1;\n\n while (branch && branch.parent) {\n if (branch.dynamic) params[branch.name] = decodeURIComponent(parts[index]);\n branch = branch.parent;\n index -= 1;\n }\n\n return params;\n }\n}\n","import type { Route } from \"../Route\";\nimport { RouterNode } from \"./RouterNode\";\n\n/**\n * A single segment of the route trie. Each branch owns exactly one {@link RouterNode} (its\n * method-to-route map) and may have any number of static children plus at most one dynamic\n * (`[param]`) child, which is only checked after every static child fails to match.\n */\nexport class RouterBranch {\n public readonly name: string;\n public readonly dynamic: boolean;\n public readonly parent: RouterBranch | null;\n public readonly node: RouterNode;\n\n private readonly staticChildren: RouterBranch[] = [];\n private dynamicChild: RouterBranch | null = null;\n\n public constructor(name: string, dynamic: boolean, parent: RouterBranch | null) {\n this.name = name;\n this.dynamic = dynamic;\n this.parent = parent;\n this.node = new RouterNode(this);\n }\n\n public matches(part: string): boolean {\n return this.dynamic || this.name === part;\n }\n\n protected insertAt(parts: readonly string[], index: number, route: Route): RouterNode {\n if (index >= parts.length) {\n for (const method of route.methods) this.node.set(method, route);\n return this.node;\n }\n\n const part = parts[index];\n const dynamic = part.startsWith(\"[\") && part.endsWith(\"]\");\n\n if (dynamic) {\n if (this.dynamicChild) return this.dynamicChild.insertAt(parts, index + 1, route);\n\n const branch = new RouterBranch(part.slice(1, -1), true, this);\n this.dynamicChild = branch;\n return branch.insertAt(parts, index + 1, route);\n }\n\n const staticChild = this.staticChildren.find((branch) => branch.name === part);\n if (staticChild) return staticChild.insertAt(parts, index + 1, route);\n\n const branch = new RouterBranch(part, false, this);\n this.staticChildren.push(branch);\n return branch.insertAt(parts, index + 1, route);\n }\n\n protected removeAt(parts: readonly string[], index: number, route: Route): boolean {\n if (index >= parts.length) {\n let removed = false;\n for (const method of route.methods) {\n if (this.node.delete(method)) removed = true;\n }\n return removed;\n }\n\n const part = parts[index];\n const child = this.staticChildren.find((branch) => branch.matches(part)) ?? this.dynamicChild;\n return child ? child.removeAt(parts, index + 1, route) : false;\n }\n\n protected findAt(parts: readonly string[], index: number): RouterBranch | null {\n if (index >= parts.length) return this;\n\n const part = parts[index];\n const child = this.staticChildren.find((branch) => branch.matches(part)) ?? this.dynamicChild;\n\n return child ? child.findAt(parts, index + 1) : null;\n }\n}\n","import { HttpMethods, type HttpMethod } from \"../../http/HttpMethod\";\nimport type { Route } from \"../Route\";\nimport { RouterBranch } from \"./RouterBranch\";\nimport type { RouterNode } from \"./RouterNode\";\n\nconst ROOT_NAME = \"::ROOT::\";\n\n/**\n * The root of the route trie, owned by {@link RouteStore.router}. Provides the public\n * add/remove/find API plus the static path-parsing helpers used by {@link Route}'s constructor.\n */\nexport class RouterRoot extends RouterBranch {\n public constructor() {\n super(ROOT_NAME, false, null);\n }\n\n public add(route: Route): RouterNode {\n return this.insertAt(route.path, 0, route);\n }\n\n public remove(route: Route): boolean {\n return this.removeAt(route.path, 0, route);\n }\n\n public find(parts: readonly string[]): RouterBranch | null {\n return this.findAt(parts, 0);\n }\n\n /**\n * Splits a `/`-delimited path into its non-empty segments.\n */\n public static normalize(path?: string | null): string[] {\n if (!path) return [];\n return path.split(\"/\").filter((part) => part.length > 0);\n }\n\n /**\n * Builds a route path from a piece's directory structure and file name: `(group)`-style\n * directories are skipped, and a file named `index` collapses into its parent directory.\n */\n public static makeRoutePathForPiece(directories: readonly string[], name: string): string {\n const parts: string[] = [];\n\n for (const directory of directories) {\n const trimmed = directory.trim();\n if (trimmed.length === 0) continue;\n if (trimmed.startsWith(\"(\") && trimmed.endsWith(\")\")) continue;\n parts.push(trimmed);\n }\n\n const trimmedName = name.trim();\n if (trimmedName !== \"index\") parts.push(trimmedName);\n\n return parts.join(\"/\");\n }\n\n /**\n * Extracts a trailing `.<method>` suffix from a piece name, e.g. `hello.post` → `POST`.\n */\n public static extractMethod(name: string): HttpMethod | null {\n const index = name.lastIndexOf(\".\");\n if (index === -1) return null;\n\n const method = name.slice(index + 1).toUpperCase();\n return (HttpMethods as readonly string[]).includes(method) ? (method as HttpMethod) : null;\n }\n}\n","import { Piece, type PieceOptions } from \"@sapphire/pieces\";\nimport type { ApiRequest } from \"../http/ApiRequest\";\nimport type { ApiResponse } from \"../http/ApiResponse\";\nimport type { HttpMethod } from \"../http/HttpMethod\";\nimport { RouterRoot } from \"./router/RouterRoot\";\n\nexport type Awaitable<T> = T | PromiseLike<T>;\n\n/**\n * A single HTTP endpoint. The route's path and methods are either given explicitly via\n * {@link Route.Options.route}/{@link Route.Options.methods}, or inferred from the piece's file\n * system location: directories become path segments (`(group)`-style directories are skipped,\n * `index` collapses into its parent), `[param]` segments become dynamic, and a `.<method>`\n * filename suffix (e.g. `hello.post.ts`) implies that HTTP method.\n */\nexport abstract class Route<Options extends Route.Options = Route.Options> extends Piece<\n Options,\n \"routes\"\n> {\n /**\n * The normalized path segments this route is registered under, e.g. `['users', '[id]']`.\n */\n public readonly path: readonly string[];\n\n /**\n * The HTTP methods this route responds to.\n */\n public readonly methods: ReadonlySet<HttpMethod>;\n\n public constructor(context: Route.LoaderContext, options: Options) {\n super(context, options);\n\n const methods = new Set<HttpMethod>(options.methods ?? []);\n\n let path: string;\n if (options.route) {\n path = options.route;\n } else {\n let name = context.name;\n const implied = RouterRoot.extractMethod(name);\n if (implied) {\n name = name.slice(0, name.length - implied.length - 1);\n methods.add(implied);\n }\n\n path = RouterRoot.makeRoutePathForPiece(this.location.directories, name);\n }\n\n if (methods.size === 0) methods.add(\"GET\");\n\n this.path = RouterRoot.normalize(path);\n this.methods = methods;\n }\n\n /**\n * Handles every method this route was registered for. Branch on `request.method` when a route\n * needs to support multiple methods.\n */\n public abstract run(request: ApiRequest, response: ApiResponse): Awaitable<unknown>;\n}\n\nexport namespace Route {\n export type LoaderContext = Piece.LoaderContext<\"routes\">;\n\n export interface Options extends PieceOptions {\n /**\n * An explicit route path, e.g. `/users/[id]`. If omitted, the path is inferred from the\n * piece's directory structure and file name.\n */\n route?: `/${string}`;\n\n /**\n * The HTTP methods this route responds to. If omitted, inferred from a `.<method>` filename\n * suffix (e.g. `hello.post.ts`), defaulting to `GET`.\n */\n methods?: readonly HttpMethod[];\n }\n}\n","import { LoaderStrategy, type Store } from \"@sapphire/pieces\";\nimport type { Route } from \"./Route\";\nimport type { RouteStore } from \"./RouteStore\";\n\n/**\n * Keeps {@link RouteStore.router} in sync as route pieces are loaded and unloaded.\n */\nexport class RouteLoaderStrategy extends LoaderStrategy<Route> {\n public override onLoad(store: Store<Route>, piece: Route): void {\n super.onLoad(store, piece);\n (store as RouteStore).router.add(piece);\n }\n\n public override onUnload(store: Store<Route>, piece: Route): void {\n super.onUnload(store, piece);\n (store as RouteStore).router.remove(piece);\n }\n}\n","import { Store } from \"@sapphire/pieces\";\nimport { Route } from \"./Route\";\nimport { RouteLoaderStrategy } from \"./RouteLoaderStrategy\";\nimport { RouterRoot } from \"./router/RouterRoot\";\n\nexport class RouteStore extends Store<Route, \"routes\"> {\n /**\n * The trie used to match an incoming request's pathname to a registered {@link Route}.\n */\n public readonly router = new RouterRoot();\n\n public constructor() {\n super(Route, { name: \"routes\", strategy: new RouteLoaderStrategy() });\n }\n}\n","import { AsyncEventEmitter } from \"@vladfrangu/async_event_emitter\";\nimport { container } from \"@wolfstar/http-framework\";\nimport {\n createServer,\n type Server as NodeHttpServer,\n type ServerOptions as NodeHttpServerOptions,\n} from \"node:http\";\nimport type { ListenOptions } from \"node:net\";\nimport { MiddlewareStore } from \"../structures/MiddlewareStore\";\nimport { RouteStore } from \"../structures/RouteStore\";\nimport { ApiRequest } from \"./ApiRequest\";\nimport { ApiResponse } from \"./ApiResponse\";\n\nexport enum ApiServerEvent {\n Error = \"error\",\n Request = \"request\",\n RouterBranchNotFound = \"routerBranchNotFound\",\n RouterBranchMethodNotAllowed = \"routerBranchMethodNotAllowed\",\n RouterFound = \"routerFound\",\n RouteError = \"routeError\",\n MiddlewareError = \"middlewareError\",\n}\n\nexport interface ApiServerEvents {\n [ApiServerEvent.Error]: [error: Error];\n [ApiServerEvent.Request]: [request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.RouterBranchNotFound]: [request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.RouterBranchMethodNotAllowed]: [request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.RouterFound]: [request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.RouteError]: [error: unknown, request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.MiddlewareError]: [error: unknown, request: ApiRequest, response: ApiResponse];\n}\n\nexport interface ApiServerOptions {\n /**\n * A path segment prefix applied to every route, e.g. `/api`.\n */\n prefix?: string;\n\n /**\n * The value of the `Access-Control-Allow-Origin` header set by the built-in `headers` middleware.\n * @default '*'\n */\n origin?: string;\n\n /**\n * The maximum request body size in bytes, enforced by the built-in `body` middleware.\n * @default 1024 * 1024 * 50\n */\n maximumBodyLength?: number;\n\n /**\n * Raw options forwarded to `node:http`'s `createServer`.\n */\n server?: NodeHttpServerOptions;\n\n /**\n * Raw options forwarded to `Server#listen`.\n * @default { port: 4000 }\n */\n listenOptions?: ListenOptions;\n\n /**\n * Whether to start listening automatically once the interaction webhook is up (during the\n * `postListen` plugin hook).\n * @default true\n */\n automaticallyConnect?: boolean;\n}\n\n/**\n * A standalone HTTP server for auxiliary REST routes (health checks, dashboards, webhooks from\n * other services, etc). It is deliberately independent from {@link Client.server}, which is\n * reserved for the Discord interactions webhook.\n */\nexport class ApiServer extends AsyncEventEmitter<ApiServerEvents> {\n public readonly routes: RouteStore;\n public readonly middlewares: MiddlewareStore;\n public readonly server: NodeHttpServer<typeof ApiRequest, typeof ApiResponse>;\n public readonly options: ApiServerOptions;\n\n public constructor(options: ApiServerOptions = {}) {\n super();\n\n container.server = this;\n\n this.options = options;\n\n const serverOptions: NodeHttpServerOptions<typeof ApiRequest, typeof ApiResponse> = {\n ...options.server,\n IncomingMessage: ApiRequest,\n ServerResponse: ApiResponse,\n };\n this.server = createServer(serverOptions);\n\n this.routes = new RouteStore();\n this.middlewares = new MiddlewareStore();\n\n this.server.on(\"error\", (error) => this.emit(ApiServerEvent.Error, error));\n this.server.on(\"request\", (request, response) =>\n this.emit(ApiServerEvent.Request, request, response),\n );\n }\n\n /**\n * Starts listening for requests.\n */\n public connect(): Promise<void> {\n return new Promise((resolve, reject) => {\n const onError = (error: Error) => {\n this.server.off(\"listening\", onListening);\n reject(error);\n };\n const onListening = () => {\n this.server.off(\"error\", onError);\n resolve();\n };\n\n this.server.once(\"error\", onError);\n this.server.once(\"listening\", onListening);\n this.server.listen({ port: 4000, ...this.options.listenOptions });\n });\n }\n\n /**\n * Stops the server from accepting new connections.\n */\n public disconnect(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.server.close((error) => (error ? reject(error) : resolve()));\n });\n }\n}\n","import { Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Logs and responds with a 500 when a route's `run` method throws.\n */\nexport class PluginRouteErrorListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.RouteError });\n }\n\n public override run(error: unknown, _request: ApiRequest, response: ApiResponse): void {\n console.error(\"[plugin-api] Route error:\", error);\n if (!response.writableEnded) response.error();\n }\n}\n","import { Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Logs and responds with a 500 when a middleware throws.\n */\nexport class PluginServerMiddlewareErrorListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.MiddlewareError });\n }\n\n public override run(error: unknown, _request: ApiRequest, response: ApiResponse): void {\n console.error(\"[plugin-api] Middleware error:\", error);\n if (!response.writableEnded) response.error();\n }\n}\n","import { container, Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\nimport type { HttpMethod } from \"../lib/http/HttpMethod\";\nimport { RouterRoot } from \"../lib/structures/router/RouterRoot\";\n\n/**\n * Parses the request URL, matches it against the route trie, runs every middleware, then emits\n * the outcome (`routerFound`, `routerBranchNotFound`, or `routerBranchMethodNotAllowed`) for the\n * downstream listeners to handle.\n */\nexport class PluginServerRequestListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.Request });\n }\n\n public override async run(request: ApiRequest, response: ApiResponse): Promise<void> {\n const [pathname, querystring] = splitUrl(request.url);\n request.query = new URLSearchParams(querystring);\n\n const parts = RouterRoot.normalize(pathname);\n const branch = container.server.routes.router.find(parts);\n const node = branch?.node ?? null;\n const route = node?.get((request.method ?? \"GET\") as HttpMethod) ?? null;\n\n if (node) request.params = node.extractParameters(parts);\n request.routerNode = branch;\n request.route = route;\n\n try {\n // Middlewares always run, even without a match, since browsers send a pre-flight OPTIONS request.\n await container.server.middlewares.run(request, response);\n } catch (error) {\n container.server.emit(ApiServerEvent.MiddlewareError, error, request, response);\n return;\n }\n\n if (response.writableEnded) return;\n\n if (branch === null) {\n container.server.emit(ApiServerEvent.RouterBranchNotFound, request, response);\n } else if (route === null) {\n container.server.emit(ApiServerEvent.RouterBranchMethodNotAllowed, request, response);\n } else {\n container.server.emit(ApiServerEvent.RouterFound, request, response);\n }\n }\n}\n\nfunction splitUrl(url = \"/\"): [pathname: string, querystring: string] {\n const index = url.indexOf(\"?\");\n return index === -1 ? [url, \"\"] : [url.slice(0, index), url.slice(index + 1)];\n}\n","import { Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Responds with a 405 when the pathname matched but no route handles this HTTP method.\n */\nexport class PluginServerRouterBranchMethodNotAllowedListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.RouterBranchMethodNotAllowed });\n }\n\n public override run(_request: ApiRequest, response: ApiResponse): void {\n if (!response.writableEnded) response.methodNotAllowed();\n }\n}\n","import { Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Responds with a 404 when no route matched the request's pathname.\n */\nexport class PluginServerRouterBranchNotFoundListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.RouterBranchNotFound });\n }\n\n public override run(_request: ApiRequest, response: ApiResponse): void {\n if (!response.writableEnded) response.notFound();\n }\n}\n","import { container, Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Invokes the matched route's `run` method, emitting `routeError` if it throws.\n */\nexport class PluginServerRouterFoundListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.RouterFound });\n }\n\n public override async run(request: ApiRequest, response: ApiResponse): Promise<void> {\n try {\n await request.route!.run(request, response);\n } catch (error) {\n container.server.emit(ApiServerEvent.RouteError, error, request, response);\n }\n }\n}\n","import { container } from \"@wolfstar/http-framework\";\nimport { PluginRouteErrorListener } from \"./PluginRouteError\";\nimport { PluginServerMiddlewareErrorListener } from \"./PluginServerMiddlewareError\";\nimport { PluginServerRequestListener } from \"./PluginServerRequest\";\nimport { PluginServerRouterBranchMethodNotAllowedListener } from \"./PluginServerRouterBranchMethodNotAllowed\";\nimport { PluginServerRouterBranchNotFoundListener } from \"./PluginServerRouterBranchNotFound\";\nimport { PluginServerRouterFoundListener } from \"./PluginServerRouterFound\";\n\n/**\n * Registers the built-in dispatch-pipeline listeners into the framework's existing listener\n * store, targeting the `server` container entry (see {@link ApiServer}).\n */\nexport async function loadListeners(): Promise<void> {\n await Promise.all([\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerRequest\",\n piece: PluginServerRequestListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerRouterFound\",\n piece: PluginServerRouterFoundListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerRouterBranchNotFound\",\n piece: PluginServerRouterBranchNotFoundListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerRouterBranchMethodNotAllowed\",\n piece: PluginServerRouterBranchMethodNotAllowedListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerMiddlewareError\",\n piece: PluginServerMiddlewareErrorListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginRouteError\",\n piece: PluginRouteErrorListener,\n }),\n ]);\n}\n","import { container, HttpCodes } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { Middleware } from \"../lib/structures/Middleware\";\n\n/**\n * Rejects requests whose declared `Content-Length` exceeds {@link ApiServerOptions.maximumBodyLength}.\n * Runs second (position 20), after CORS headers have been set.\n */\nexport class BodyMiddleware extends Middleware {\n public constructor(context: Middleware.LoaderContext) {\n super(context, { position: 20 });\n }\n\n public override run(request: ApiRequest, response: ApiResponse): void {\n const limit = container.server.options.maximumBodyLength ?? 1024 * 1024 * 50;\n const contentLength = Number(request.headers[\"content-length\"] ?? 0);\n\n if (contentLength > limit) {\n response.json({ error: \"Payload Too Large\" }, HttpCodes.PayloadTooLarge);\n }\n }\n}\n","import { container } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { Middleware } from \"../lib/structures/Middleware\";\n\n/**\n * Sets CORS headers on every response and short-circuits `OPTIONS` pre-flight requests.\n * Runs first (position 10); 404/405 handling stays the sole responsibility of the router\n * listeners, so it is not duplicated here.\n */\nexport class HeadersMiddleware extends Middleware {\n public constructor(context: Middleware.LoaderContext) {\n super(context, { position: 10 });\n }\n\n public override run(request: ApiRequest, response: ApiResponse): void {\n const origin = container.server.options.origin ?? \"*\";\n\n response.setHeader(\"Access-Control-Allow-Origin\", origin);\n response.setHeader(\"Access-Control-Allow-Headers\", \"Content-Type, Authorization\");\n response.setHeader(\n \"Access-Control-Allow-Methods\",\n \"GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS\",\n );\n response.setHeader(\"Date\", new Date().toUTCString());\n\n if (request.method === \"OPTIONS\") response.noContent();\n }\n}\n","import { container } from \"@wolfstar/http-framework\";\nimport { BodyMiddleware } from \"./body\";\nimport { HeadersMiddleware } from \"./headers\";\n\n/**\n * Registers the built-in middlewares (`headers`, `body`) into {@link ApiServer.middlewares}.\n */\nexport async function loadMiddlewares(): Promise<void> {\n await Promise.all([\n container.stores.loadPiece({ store: \"middlewares\", name: \"headers\", piece: HeadersMiddleware }),\n container.stores.loadPiece({ store: \"middlewares\", name: \"body\", piece: BodyMiddleware }),\n ]);\n}\n"],"mappings":";;;;;;AAIA,IAAa,aAAb,cAAgC,gBAAgB;;;;CAI9C,AAAO,QAAyB,IAAI,gBAAgB;;;;CAKpD,AAAO,SAAiC,CAAC;;;;CAKzC,AAAO,aAAkC;;;;CAKzC,AAAO,QAAsB;;;;;CAM7B,MAAa,aAAa,QAAQ,OAAO,MAAuB;EAC9D,MAAM,SAAmB,CAAC;EAC1B,IAAI,OAAO;EAEX,WAAW,MAAM,SAAS,MAAM;GAC9B,QAAS,MAAiB;GAC1B,IAAI,OAAO,OAAO,MAAM,IAAI,WAAW,6BAA6B,MAAM,YAAY;GACtF,OAAO,KAAK,KAAe;EAC7B;EAEA,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,MAAM;CAC9C;;;;;CAMA,MAAa,aAA0B,OAA4B;EACjE,MAAM,OAAO,MAAM,KAAK,aAAa,KAAK;EAC1C,OAAO,KAAK,MAAM,IAAI;CACxB;AACF;;;;AC9CA,IAAa,cAAb,cAAiC,eAA2B;CAC1D,AAAO,OAAO,YAA0B;EACtC,KAAK,aAAa;EAClB,OAAO;CACT;CAEA,AAAO,KAAK,MA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AAO;EACT,CAAC;CACH,CAAC;AACH;;;;;;;;ACpCA,IAAa,iBAAb,cAAoC,WAAW;CAC7C,AAAO,YAAY,SAAmC;EACpD,MAAM,SAAS,EAAE,UAAU,GAAG,CAAC;CACjC;CAEA,AAAgB,IAAI,SAAqB,UAA6B;EACpE,MAAM,QAAQ,UAAU,OAAO,QAAQ,qBAAqB,OAAO,OAAO;EAG1E,IAFsB,OAAO,QAAQ,QAAQ,qBAAqB,CAElD,IAAI,OAClB,SAAS,KAAK,EAAE,OAAO,oBAAoB,GAAG,UAAU,eAAe;CAE3E;AACF;;;;;;;;;ACZA,IAAa,oBAAb,cAAuC,WAAW;CAChD,AAAO,YAAY,SAAmC;EACpD,MAAM,SAAS,EAAE,UAAU,GAAG,CAAC;CACjC;CAEA,AAAgB,IAAI,SAAqB,UAA6B;EACpE,MAAM,SAAS,UAAU,OAAO,QAAQ,UAAU;EAElD,SAAS,UAAU,+BAA+B,MAAM;EACxD,SAAS,UAAU,gCAAgC,6BAA6B;EAChF,SAAS,UACP,gCACA,8CACF;EACA,SAAS,UAAU,yBAAQ,IAAI,KAAK,EAAC,CAAC,YAAY,CAAC;EAEnD,IAAI,QAAQ,WAAW,WAAW,SAAS,UAAU;CACvD;AACF;;;;;;;ACrBA,eAAsB,kBAAiC;CACrD,MAAM,QAAQ,IAAI,CAChB,UAAU,OAAO,UAAU;EAAE,OAAO;EAAe,MAAM;EAAW,OAAO;CAAkB,CAAC,GAC9F,UAAU,OAAO,UAAU;EAAE,OAAO;EAAe,MAAM;EAAQ,OAAO;CAAe,CAAC,CAC1F,CAAC;AACH"}
1
+ {"version":3,"file":"src-DPwBQpLA.js","names":[],"sources":["../../src/lib/http/ApiRequest.ts","../../src/lib/http/ApiResponse.ts","../../src/lib/structures/Middleware.ts","../../src/lib/structures/MiddlewareStore.ts","../../src/lib/http/HttpMethod.ts","../../src/lib/structures/router/RouterNode.ts","../../src/lib/structures/router/RouterBranch.ts","../../src/lib/structures/router/RouterRoot.ts","../../src/lib/structures/Route.ts","../../src/lib/structures/RouteLoaderStrategy.ts","../../src/lib/structures/RouteStore.ts","../../src/lib/http/ApiServer.ts","../../src/listeners/PluginRouteError.ts","../../src/listeners/PluginServerMiddlewareError.ts","../../src/listeners/PluginServerRequest.ts","../../src/listeners/PluginServerRouterBranchMethodNotAllowed.ts","../../src/listeners/PluginServerRouterBranchNotFound.ts","../../src/listeners/PluginServerRouterFound.ts","../../src/listeners/_load.ts","../../src/middlewares/body.ts","../../src/middlewares/headers.ts","../../src/middlewares/_load.ts"],"sourcesContent":["import { IncomingMessage } from \"node:http\";\nimport type { Route } from \"../structures/Route\";\nimport type { RouterBranch } from \"../structures/router/RouterBranch\";\n\nexport class ApiRequest extends IncomingMessage {\n /**\n * The parsed query string parameters.\n */\n public query: URLSearchParams = new URLSearchParams();\n\n /**\n * The extracted dynamic (`[param]`) path segment values.\n */\n public params: Record<string, string> = {};\n\n /**\n * The matched router branch for this request's pathname, if any.\n */\n public routerNode: RouterBranch | null = null;\n\n /**\n * The matched route for this request's pathname and method, if any.\n */\n public route: Route | null = null;\n\n /**\n * Reads the full request body as a UTF-8 string.\n * @param limit The maximum number of bytes to read before rejecting. Defaults to 1 MiB.\n */\n public async readBodyText(limit = 1024 * 1024): Promise<string> {\n const chunks: Buffer[] = [];\n let size = 0;\n\n for await (const chunk of this) {\n size += (chunk as Buffer).length;\n if (size > limit) throw new RangeError(`Request body exceeded the ${limit} byte limit`);\n chunks.push(chunk as Buffer);\n }\n\n return Buffer.concat(chunks).toString(\"utf8\");\n }\n\n /**\n * Reads and parses the request body as JSON.\n * @param limit The maximum number of bytes to read before rejecting. Defaults to 1 MiB.\n */\n public async readBodyJson<T = unknown>(limit?: number): Promise<T> {\n const text = await this.readBodyText(limit);\n return JSON.parse(text) as T;\n }\n}\n","import { ServerResponse } from \"node:http\";\nimport { HttpCodes } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"./ApiRequest\";\n\nexport class ApiResponse extends ServerResponse<ApiRequest> {\n public status(statusCode: number): this {\n this.statusCode = statusCode;\n return this;\n }\n\n public json(body: unknown, statusCode: number = HttpCodes.OK): this {\n this.statusCode = statusCode;\n if (!this.hasHeader(\"Content-Type\"))\n this.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n this.end(JSON.stringify(body));\n return this;\n }\n\n public text(body: string, statusCode: number = HttpCodes.OK): this {\n this.statusCode = statusCode;\n if (!this.hasHeader(\"Content-Type\"))\n this.setHeader(\"Content-Type\", \"text/plain; charset=utf-8\");\n this.end(body);\n return this;\n }\n\n public noContent(): this {\n this.statusCode = HttpCodes.NoContent;\n this.end();\n return this;\n }\n\n public notFound(body: unknown = { error: \"Not Found\" }): this {\n return this.json(body, HttpCodes.NotFound);\n }\n\n public methodNotAllowed(body: unknown = { error: \"Method Not Allowed\" }): this {\n return this.json(body, HttpCodes.MethodNotAllowed);\n }\n\n public badRequest(body: unknown = { error: \"Bad Request\" }): this {\n return this.json(body, HttpCodes.BadRequest);\n }\n\n public error(\n statusCode: number = HttpCodes.InternalServerError,\n body: unknown = { error: \"Internal Server Error\" },\n ): this {\n return this.json(body, statusCode);\n }\n}\n","import { Piece, type PieceOptions } from \"@sapphire/pieces\";\nimport type { ApiRequest } from \"../http/ApiRequest\";\nimport type { ApiResponse } from \"../http/ApiResponse\";\nimport type { Awaitable } from \"./Route\";\n\n/**\n * A piece that runs on every incoming request, in ascending {@link Middleware.position} order,\n * before route dispatch. A middleware stops the chain implicitly by ending the response\n * (`response.writableEnded`); there is no explicit `next()` callback.\n */\nexport abstract class Middleware<\n Options extends Middleware.Options = Middleware.Options,\n> extends Piece<Options, \"middlewares\"> {\n /**\n * The built-in middlewares use the following positions:\n * - `headers`: 10 (CORS headers, 404/405 short-circuit)\n * - `body`: 20 (`Content-Length` validation)\n */\n public readonly position: number;\n\n public constructor(context: Middleware.LoaderContext, options: Options) {\n super(context, options);\n this.position = options.position ?? 1000;\n }\n\n public abstract run(request: ApiRequest, response: ApiResponse): Awaitable<unknown>;\n}\n\nexport namespace Middleware {\n export type LoaderContext = Piece.LoaderContext<\"middlewares\">;\n\n export interface Options extends PieceOptions {\n /**\n * Middlewares run in ascending order of this value.\n * @default 1000\n */\n position?: number;\n }\n}\n","import { Store } from \"@sapphire/pieces\";\nimport type { ApiRequest } from \"../http/ApiRequest\";\nimport type { ApiResponse } from \"../http/ApiResponse\";\nimport { Middleware } from \"./Middleware\";\n\nexport class MiddlewareStore extends Store<Middleware, \"middlewares\"> {\n /**\n * Enabled middlewares, kept sorted in ascending {@link Middleware.position} order.\n */\n public readonly sortedMiddlewares: Middleware[] = [];\n\n public constructor() {\n super(Middleware, { name: \"middlewares\" });\n }\n\n /**\n * Runs every enabled middleware in order, stopping early once the response has ended.\n */\n public async run(request: ApiRequest, response: ApiResponse): Promise<void> {\n for (const middleware of this.sortedMiddlewares) {\n if (response.writableEnded) return;\n if (middleware.enabled) await middleware.run(request, response);\n }\n }\n\n public override set(key: string, value: Middleware): this {\n const index = this.sortedMiddlewares.findIndex(\n (middleware) => middleware.position >= value.position,\n );\n if (index === -1) this.sortedMiddlewares.push(value);\n else this.sortedMiddlewares.splice(index, 0, value);\n\n return super.set(key, value);\n }\n\n public override delete(key: string): boolean {\n const index = this.sortedMiddlewares.findIndex((middleware) => middleware.name === key);\n if (index !== -1) this.sortedMiddlewares.splice(index, 1);\n\n return super.delete(key);\n }\n\n public override clear(): void {\n this.sortedMiddlewares.length = 0;\n super.clear();\n }\n}\n","/**\n * The HTTP methods that a {@link Route} can be registered for.\n */\nexport const HttpMethods = [\"DELETE\", \"GET\", \"HEAD\", \"OPTIONS\", \"PATCH\", \"POST\", \"PUT\"] as const;\n\nexport type HttpMethod = (typeof HttpMethods)[number];\n","import type { HttpMethod } from \"../../http/HttpMethod\";\nimport type { Route } from \"../Route\";\nimport type { RouterBranch } from \"./RouterBranch\";\n\n/**\n * A single path segment's registered routes, keyed by HTTP method.\n */\nexport class RouterNode extends Map<HttpMethod, Route> {\n public readonly branch: RouterBranch;\n\n public constructor(branch: RouterBranch) {\n super();\n this.branch = branch;\n }\n\n /**\n * Walks up the branch chain collecting the values captured by dynamic (`[param]`) segments.\n * @param parts The path segments of the matched request, in the same order used to reach this node.\n */\n public extractParameters(parts: readonly string[]): Record<string, string> {\n const params: Record<string, string> = {};\n\n let branch: RouterBranch | null = this.branch;\n let index = parts.length - 1;\n\n while (branch && branch.parent) {\n if (branch.dynamic) params[branch.name] = decodeURIComponent(parts[index]);\n branch = branch.parent;\n index -= 1;\n }\n\n return params;\n }\n}\n","import type { Route } from \"../Route\";\nimport { RouterNode } from \"./RouterNode\";\n\n/**\n * A single segment of the route trie. Each branch owns exactly one {@link RouterNode} (its\n * method-to-route map) and may have any number of static children plus at most one dynamic\n * (`[param]`) child, which is only checked after every static child fails to match.\n */\nexport class RouterBranch {\n public readonly name: string;\n public readonly dynamic: boolean;\n public readonly parent: RouterBranch | null;\n public readonly node: RouterNode;\n\n private readonly staticChildren: RouterBranch[] = [];\n private dynamicChild: RouterBranch | null = null;\n\n public constructor(name: string, dynamic: boolean, parent: RouterBranch | null) {\n this.name = name;\n this.dynamic = dynamic;\n this.parent = parent;\n this.node = new RouterNode(this);\n }\n\n public matches(part: string): boolean {\n return this.dynamic || this.name === part;\n }\n\n protected insertAt(parts: readonly string[], index: number, route: Route): RouterNode {\n if (index >= parts.length) {\n for (const method of route.methods) this.node.set(method, route);\n return this.node;\n }\n\n const part = parts[index];\n const dynamic = part.startsWith(\"[\") && part.endsWith(\"]\");\n\n if (dynamic) {\n if (this.dynamicChild) return this.dynamicChild.insertAt(parts, index + 1, route);\n\n const branch = new RouterBranch(part.slice(1, -1), true, this);\n this.dynamicChild = branch;\n return branch.insertAt(parts, index + 1, route);\n }\n\n const staticChild = this.staticChildren.find((branch) => branch.name === part);\n if (staticChild) return staticChild.insertAt(parts, index + 1, route);\n\n const branch = new RouterBranch(part, false, this);\n this.staticChildren.push(branch);\n return branch.insertAt(parts, index + 1, route);\n }\n\n protected removeAt(parts: readonly string[], index: number, route: Route): boolean {\n if (index >= parts.length) {\n let removed = false;\n for (const method of route.methods) {\n if (this.node.delete(method)) removed = true;\n }\n return removed;\n }\n\n const part = parts[index];\n const child = this.staticChildren.find((branch) => branch.matches(part)) ?? this.dynamicChild;\n return child ? child.removeAt(parts, index + 1, route) : false;\n }\n\n protected findAt(parts: readonly string[], index: number): RouterBranch | null {\n if (index >= parts.length) return this;\n\n const part = parts[index];\n const child = this.staticChildren.find((branch) => branch.matches(part)) ?? this.dynamicChild;\n\n return child ? child.findAt(parts, index + 1) : null;\n }\n}\n","import { HttpMethods, type HttpMethod } from \"../../http/HttpMethod\";\nimport type { Route } from \"../Route\";\nimport { RouterBranch } from \"./RouterBranch\";\nimport type { RouterNode } from \"./RouterNode\";\n\nconst ROOT_NAME = \"::ROOT::\";\n\n/**\n * The root of the route trie, owned by {@link RouteStore.router}. Provides the public\n * add/remove/find API plus the static path-parsing helpers used by {@link Route}'s constructor.\n */\nexport class RouterRoot extends RouterBranch {\n public constructor() {\n super(ROOT_NAME, false, null);\n }\n\n public add(route: Route): RouterNode {\n return this.insertAt(route.path, 0, route);\n }\n\n public remove(route: Route): boolean {\n return this.removeAt(route.path, 0, route);\n }\n\n public find(parts: readonly string[]): RouterBranch | null {\n return this.findAt(parts, 0);\n }\n\n /**\n * Splits a `/`-delimited path into its non-empty segments.\n */\n public static normalize(path?: string | null): string[] {\n if (!path) return [];\n return path.split(\"/\").filter((part) => part.length > 0);\n }\n\n /**\n * Builds a route path from a piece's directory structure and file name: `(group)`-style\n * directories are skipped, and a file named `index` collapses into its parent directory.\n */\n public static makeRoutePathForPiece(directories: readonly string[], name: string): string {\n const parts: string[] = [];\n\n for (const directory of directories) {\n const trimmed = directory.trim();\n if (trimmed.length === 0) continue;\n if (trimmed.startsWith(\"(\") && trimmed.endsWith(\")\")) continue;\n parts.push(trimmed);\n }\n\n const trimmedName = name.trim();\n if (trimmedName !== \"index\") parts.push(trimmedName);\n\n return parts.join(\"/\");\n }\n\n /**\n * Extracts a trailing `.<method>` suffix from a piece name, e.g. `hello.post` → `POST`.\n */\n public static extractMethod(name: string): HttpMethod | null {\n const index = name.lastIndexOf(\".\");\n if (index === -1) return null;\n\n const method = name.slice(index + 1).toUpperCase();\n return (HttpMethods as readonly string[]).includes(method) ? (method as HttpMethod) : null;\n }\n}\n","import { Piece, type PieceOptions } from \"@sapphire/pieces\";\nimport type { ApiRequest } from \"../http/ApiRequest\";\nimport type { ApiResponse } from \"../http/ApiResponse\";\nimport type { HttpMethod } from \"../http/HttpMethod\";\nimport { RouterRoot } from \"./router/RouterRoot\";\n\nexport type Awaitable<T> = T | PromiseLike<T>;\n\n/**\n * A single HTTP endpoint. The route's path and methods are either given explicitly via\n * {@link Route.Options.route}/{@link Route.Options.methods}, or inferred from the piece's file\n * system location: directories become path segments (`(group)`-style directories are skipped,\n * `index` collapses into its parent), `[param]` segments become dynamic, and a `.<method>`\n * filename suffix (e.g. `hello.post.ts`) implies that HTTP method.\n */\nexport abstract class Route<Options extends Route.Options = Route.Options> extends Piece<\n Options,\n \"routes\"\n> {\n /**\n * The normalized path segments this route is registered under, e.g. `['users', '[id]']`.\n */\n public readonly path: readonly string[];\n\n /**\n * The HTTP methods this route responds to.\n */\n public readonly methods: ReadonlySet<HttpMethod>;\n\n public constructor(context: Route.LoaderContext, options: Options) {\n super(context, options);\n\n const methods = new Set<HttpMethod>(options.methods ?? []);\n\n let path: string;\n if (options.route) {\n path = options.route;\n } else {\n let name = context.name;\n const implied = RouterRoot.extractMethod(name);\n if (implied) {\n name = name.slice(0, name.length - implied.length - 1);\n methods.add(implied);\n }\n\n path = RouterRoot.makeRoutePathForPiece(this.location.directories, name);\n }\n\n if (methods.size === 0) methods.add(\"GET\");\n\n this.path = RouterRoot.normalize(path);\n this.methods = methods;\n }\n\n /**\n * Handles every method this route was registered for. Branch on `request.method` when a route\n * needs to support multiple methods.\n */\n public abstract run(request: ApiRequest, response: ApiResponse): Awaitable<unknown>;\n}\n\nexport namespace Route {\n export type LoaderContext = Piece.LoaderContext<\"routes\">;\n\n export interface Options extends PieceOptions {\n /**\n * An explicit route path, e.g. `/users/[id]`. If omitted, the path is inferred from the\n * piece's directory structure and file name.\n */\n route?: `/${string}`;\n\n /**\n * The HTTP methods this route responds to. If omitted, inferred from a `.<method>` filename\n * suffix (e.g. `hello.post.ts`), defaulting to `GET`.\n */\n methods?: readonly HttpMethod[];\n }\n}\n","import { LoaderStrategy, type Store } from \"@sapphire/pieces\";\nimport type { Route } from \"./Route\";\nimport type { RouteStore } from \"./RouteStore\";\n\n/**\n * Keeps {@link RouteStore.router} in sync as route pieces are loaded and unloaded.\n */\nexport class RouteLoaderStrategy extends LoaderStrategy<Route> {\n public override onLoad(store: Store<Route>, piece: Route): void {\n super.onLoad(store, piece);\n (store as RouteStore).router.add(piece);\n }\n\n public override onUnload(store: Store<Route>, piece: Route): void {\n super.onUnload(store, piece);\n (store as RouteStore).router.remove(piece);\n }\n}\n","import { Store } from \"@sapphire/pieces\";\nimport { Route } from \"./Route\";\nimport { RouteLoaderStrategy } from \"./RouteLoaderStrategy\";\nimport { RouterRoot } from \"./router/RouterRoot\";\n\nexport class RouteStore extends Store<Route, \"routes\"> {\n /**\n * The trie used to match an incoming request's pathname to a registered {@link Route}.\n */\n public readonly router = new RouterRoot();\n\n public constructor() {\n super(Route, { name: \"routes\", strategy: new RouteLoaderStrategy() });\n }\n}\n","import { AsyncEventEmitter } from \"@vladfrangu/async_event_emitter\";\nimport { container } from \"@wolfstar/http-framework\";\nimport {\n createServer,\n type Server as NodeHttpServer,\n type ServerOptions as NodeHttpServerOptions,\n} from \"node:http\";\nimport type { ListenOptions } from \"node:net\";\nimport { MiddlewareStore } from \"../structures/MiddlewareStore\";\nimport { RouteStore } from \"../structures/RouteStore\";\nimport { ApiRequest } from \"./ApiRequest\";\nimport { ApiResponse } from \"./ApiResponse\";\n\nexport enum ApiServerEvent {\n Error = \"error\",\n Request = \"request\",\n RouterBranchNotFound = \"routerBranchNotFound\",\n RouterBranchMethodNotAllowed = \"routerBranchMethodNotAllowed\",\n RouterFound = \"routerFound\",\n RouteError = \"routeError\",\n MiddlewareError = \"middlewareError\",\n}\n\nexport interface ApiServerEvents {\n [ApiServerEvent.Error]: [error: Error];\n [ApiServerEvent.Request]: [request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.RouterBranchNotFound]: [request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.RouterBranchMethodNotAllowed]: [request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.RouterFound]: [request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.RouteError]: [error: unknown, request: ApiRequest, response: ApiResponse];\n [ApiServerEvent.MiddlewareError]: [error: unknown, request: ApiRequest, response: ApiResponse];\n}\n\nexport interface ApiServerOptions {\n /**\n * A path segment prefix applied to every route, e.g. `/api`.\n */\n prefix?: string;\n\n /**\n * The value of the `Access-Control-Allow-Origin` header set by the built-in `headers` middleware.\n * @default '*'\n */\n origin?: string;\n\n /**\n * The maximum request body size in bytes, enforced by the built-in `body` middleware.\n * @default 1024 * 1024 * 50\n */\n maximumBodyLength?: number;\n\n /**\n * Raw options forwarded to `node:http`'s `createServer`.\n */\n server?: NodeHttpServerOptions;\n\n /**\n * Raw options forwarded to `Server#listen`.\n * @default { port: 4000 }\n */\n listenOptions?: ListenOptions;\n\n /**\n * Whether to start listening automatically once the interaction webhook is up (during the\n * `postListen` plugin hook).\n * @default true\n */\n automaticallyConnect?: boolean;\n}\n\n/**\n * A standalone HTTP server for auxiliary REST routes (health checks, dashboards, webhooks from\n * other services, etc). It is deliberately independent from {@link Client.server}, which is\n * reserved for the Discord interactions webhook.\n */\nexport class ApiServer extends AsyncEventEmitter<ApiServerEvents> {\n public readonly routes: RouteStore;\n public readonly middlewares: MiddlewareStore;\n public readonly server: NodeHttpServer<typeof ApiRequest, typeof ApiResponse>;\n public readonly options: ApiServerOptions;\n\n public constructor(options: ApiServerOptions = {}) {\n super();\n\n container.server = this;\n\n this.options = options;\n\n const serverOptions: NodeHttpServerOptions<typeof ApiRequest, typeof ApiResponse> = {\n ...options.server,\n IncomingMessage: ApiRequest,\n ServerResponse: ApiResponse,\n };\n this.server = createServer(serverOptions);\n\n this.routes = new RouteStore();\n this.middlewares = new MiddlewareStore();\n\n this.server.on(\"error\", (error) => this.emit(ApiServerEvent.Error, error));\n this.server.on(\"request\", (request, response) =>\n this.emit(ApiServerEvent.Request, request, response),\n );\n }\n\n /**\n * Starts listening for requests.\n */\n public connect(): Promise<void> {\n return new Promise((resolve, reject) => {\n const onError = (error: Error) => {\n this.server.off(\"listening\", onListening);\n reject(error);\n };\n const onListening = () => {\n this.server.off(\"error\", onError);\n resolve();\n };\n\n this.server.once(\"error\", onError);\n this.server.once(\"listening\", onListening);\n this.server.listen({ port: 4000, ...this.options.listenOptions });\n });\n }\n\n /**\n * Stops the server from accepting new connections.\n */\n public disconnect(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.server.close((error) => (error ? reject(error) : resolve()));\n });\n }\n}\n","import { Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Logs and responds with a 500 when a route's `run` method throws.\n */\nexport class PluginRouteErrorListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.RouteError });\n }\n\n public override run(error: unknown, _request: ApiRequest, response: ApiResponse): void {\n console.error(\"[plugin-api] Route error:\", error);\n if (!response.writableEnded) response.error();\n }\n}\n","import { Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Logs and responds with a 500 when a middleware throws.\n */\nexport class PluginServerMiddlewareErrorListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.MiddlewareError });\n }\n\n public override run(error: unknown, _request: ApiRequest, response: ApiResponse): void {\n console.error(\"[plugin-api] Middleware error:\", error);\n if (!response.writableEnded) response.error();\n }\n}\n","import { container, Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\nimport type { HttpMethod } from \"../lib/http/HttpMethod\";\nimport { RouterRoot } from \"../lib/structures/router/RouterRoot\";\n\n/**\n * Parses the request URL, matches it against the route trie, runs every middleware, then emits\n * the outcome (`routerFound`, `routerBranchNotFound`, or `routerBranchMethodNotAllowed`) for the\n * downstream listeners to handle.\n */\nexport class PluginServerRequestListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.Request });\n }\n\n public override async run(request: ApiRequest, response: ApiResponse): Promise<void> {\n const [pathname, querystring] = splitUrl(request.url);\n request.query = new URLSearchParams(querystring);\n\n const parts = RouterRoot.normalize(pathname);\n const branch = container.server.routes.router.find(parts);\n const node = branch?.node ?? null;\n const route = node?.get((request.method ?? \"GET\") as HttpMethod) ?? null;\n\n if (node) request.params = node.extractParameters(parts);\n request.routerNode = branch;\n request.route = route;\n\n try {\n // Middlewares always run, even without a match, since browsers send a pre-flight OPTIONS request.\n await container.server.middlewares.run(request, response);\n } catch (error) {\n container.server.emit(ApiServerEvent.MiddlewareError, error, request, response);\n return;\n }\n\n if (response.writableEnded) return;\n\n if (branch === null) {\n container.server.emit(ApiServerEvent.RouterBranchNotFound, request, response);\n } else if (route === null) {\n container.server.emit(ApiServerEvent.RouterBranchMethodNotAllowed, request, response);\n } else {\n container.server.emit(ApiServerEvent.RouterFound, request, response);\n }\n }\n}\n\nfunction splitUrl(url = \"/\"): [pathname: string, querystring: string] {\n const index = url.indexOf(\"?\");\n return index === -1 ? [url, \"\"] : [url.slice(0, index), url.slice(index + 1)];\n}\n","import { Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Responds with a 405 when the pathname matched but no route handles this HTTP method.\n */\nexport class PluginServerRouterBranchMethodNotAllowedListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.RouterBranchMethodNotAllowed });\n }\n\n public override run(_request: ApiRequest, response: ApiResponse): void {\n if (!response.writableEnded) response.methodNotAllowed();\n }\n}\n","import { Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Responds with a 404 when no route matched the request's pathname.\n */\nexport class PluginServerRouterBranchNotFoundListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.RouterBranchNotFound });\n }\n\n public override run(_request: ApiRequest, response: ApiResponse): void {\n if (!response.writableEnded) response.notFound();\n }\n}\n","import { container, Listener } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { ApiServerEvent } from \"../lib/http/ApiServer\";\n\n/**\n * Invokes the matched route's `run` method, emitting `routeError` if it throws.\n */\nexport class PluginServerRouterFoundListener extends Listener {\n public constructor(context: Listener.LoaderContext) {\n super(context, { emitter: \"server\", event: ApiServerEvent.RouterFound });\n }\n\n public override async run(request: ApiRequest, response: ApiResponse): Promise<void> {\n try {\n await request.route!.run(request, response);\n } catch (error) {\n container.server.emit(ApiServerEvent.RouteError, error, request, response);\n }\n }\n}\n","import { container } from \"@wolfstar/http-framework\";\nimport { PluginRouteErrorListener } from \"./PluginRouteError\";\nimport { PluginServerMiddlewareErrorListener } from \"./PluginServerMiddlewareError\";\nimport { PluginServerRequestListener } from \"./PluginServerRequest\";\nimport { PluginServerRouterBranchMethodNotAllowedListener } from \"./PluginServerRouterBranchMethodNotAllowed\";\nimport { PluginServerRouterBranchNotFoundListener } from \"./PluginServerRouterBranchNotFound\";\nimport { PluginServerRouterFoundListener } from \"./PluginServerRouterFound\";\n\n/**\n * Registers the built-in dispatch-pipeline listeners into the framework's existing listener\n * store, targeting the `server` container entry (see {@link ApiServer}).\n */\nexport async function loadListeners(): Promise<void> {\n await Promise.all([\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerRequest\",\n piece: PluginServerRequestListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerRouterFound\",\n piece: PluginServerRouterFoundListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerRouterBranchNotFound\",\n piece: PluginServerRouterBranchNotFoundListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerRouterBranchMethodNotAllowed\",\n piece: PluginServerRouterBranchMethodNotAllowedListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginServerMiddlewareError\",\n piece: PluginServerMiddlewareErrorListener,\n }),\n container.stores.loadPiece({\n store: \"listeners\",\n name: \"pluginRouteError\",\n piece: PluginRouteErrorListener,\n }),\n ]);\n}\n","import { container, HttpCodes } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { Middleware } from \"../lib/structures/Middleware\";\n\n/**\n * Rejects requests whose declared `Content-Length` exceeds {@link ApiServerOptions.maximumBodyLength}.\n * Runs second (position 20), after CORS headers have been set.\n */\nexport class BodyMiddleware extends Middleware {\n public constructor(context: Middleware.LoaderContext) {\n super(context, { position: 20 });\n }\n\n public override run(request: ApiRequest, response: ApiResponse): void {\n const limit = container.server.options.maximumBodyLength ?? 1024 * 1024 * 50;\n const contentLength = Number(request.headers[\"content-length\"] ?? 0);\n\n if (contentLength > limit) {\n response.json({ error: \"Payload Too Large\" }, HttpCodes.PayloadTooLarge);\n }\n }\n}\n","import { container } from \"@wolfstar/http-framework\";\nimport type { ApiRequest } from \"../lib/http/ApiRequest\";\nimport type { ApiResponse } from \"../lib/http/ApiResponse\";\nimport { Middleware } from \"../lib/structures/Middleware\";\n\n/**\n * Sets CORS headers on every response and short-circuits `OPTIONS` pre-flight requests.\n * Runs first (position 10); 404/405 handling stays the sole responsibility of the router\n * listeners, so it is not duplicated here.\n */\nexport class HeadersMiddleware extends Middleware {\n public constructor(context: Middleware.LoaderContext) {\n super(context, { position: 10 });\n }\n\n public override run(request: ApiRequest, response: ApiResponse): void {\n const origin = container.server.options.origin ?? \"*\";\n\n response.setHeader(\"Access-Control-Allow-Origin\", origin);\n response.setHeader(\"Access-Control-Allow-Headers\", \"Content-Type, Authorization\");\n response.setHeader(\n \"Access-Control-Allow-Methods\",\n \"GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS\",\n );\n response.setHeader(\"Date\", new Date().toUTCString());\n\n if (request.method === \"OPTIONS\") response.noContent();\n }\n}\n","import { container } from \"@wolfstar/http-framework\";\nimport { BodyMiddleware } from \"./body\";\nimport { HeadersMiddleware } from \"./headers\";\n\n/**\n * Registers the built-in middlewares (`headers`, `body`) into {@link ApiServer.middlewares}.\n */\nexport async function loadMiddlewares(): Promise<void> {\n await Promise.all([\n container.stores.loadPiece({ store: \"middlewares\", name: \"headers\", piece: HeadersMiddleware }),\n container.stores.loadPiece({ store: \"middlewares\", name: \"body\", piece: BodyMiddleware }),\n ]);\n}\n"],"mappings":";;;;;;AAIA,IAAa,aAAb,cAAgC,gBAAgB;;;;CAI9C,AAAO,QAAyB,IAAI,gBAAgB;;;;CAKpD,AAAO,SAAiC,CAAC;;;;CAKzC,AAAO,aAAkC;;;;CAKzC,AAAO,QAAsB;;;;;CAM7B,MAAa,aAAa,QAAQ,SAA8B;EAC9D,MAAM,SAAm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;;ACrBA,eAAsB,kBAAiC;CACrD,MAAM,QAAQ,IAAI,CAChB,UAAU,OAAO,UAAU;EAAE,OAAO;EAAe,MAAM;EAAW,OAAO;CAAkB,CAAC,GAC9F,UAAU,OAAO,UAAU;EAAE,OAAO;EAAe,MAAM;EAAQ,OAAO;CAAe,CAAC,CAC1F,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wolfstar/plugin-api",
3
- "version": "1.1.4",
3
+ "version": "1.1.5-next-20260904173601",
4
4
  "description": "Plugin for @wolfstar/http-framework exposing a standalone REST API server (routes, middlewares, router)",
5
5
  "keywords": [
6
6
  "api",
@@ -59,7 +59,6 @@
59
59
  },
60
60
  "scripts": {
61
61
  "build": "tsdown --config-loader unrun",
62
- "typecheck": "tsc --noEmit",
63
62
  "lint": "oxlint src --fix",
64
63
  "test": "vitest run"
65
64
  }