@alxia/core 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +103 -3
  2. package/dist/app/alxia.d.ts +53 -5
  3. package/dist/app/alxia.d.ts.map +1 -1
  4. package/dist/app/chain.d.ts +5 -8
  5. package/dist/app/chain.d.ts.map +1 -1
  6. package/dist/app/context.d.ts +12 -0
  7. package/dist/app/context.d.ts.map +1 -0
  8. package/dist/app/definition.d.ts +22 -1
  9. package/dist/app/definition.d.ts.map +1 -1
  10. package/dist/app/refusal.d.ts +15 -0
  11. package/dist/app/refusal.d.ts.map +1 -0
  12. package/dist/app/send.d.ts +8 -1
  13. package/dist/app/send.d.ts.map +1 -1
  14. package/dist/app/socket.d.ts +1 -1
  15. package/dist/app/socket.d.ts.map +1 -1
  16. package/dist/app/types/index.d.ts +1 -0
  17. package/dist/app/types/index.d.ts.map +1 -1
  18. package/dist/app/types/refusal.d.ts +94 -0
  19. package/dist/app/types/refusal.d.ts.map +1 -0
  20. package/dist/app/types/route-table.d.ts +3 -2
  21. package/dist/app/types/route-table.d.ts.map +1 -1
  22. package/dist/app/types/schema.d.ts +7 -0
  23. package/dist/app/types/schema.d.ts.map +1 -1
  24. package/dist/app/types/valid-schema.d.ts +1 -1
  25. package/dist/app/types/valid-schema.d.ts.map +1 -1
  26. package/dist/errors/errors.d.ts +47 -1
  27. package/dist/errors/errors.d.ts.map +1 -1
  28. package/dist/index.d.ts +5 -3
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +395 -97
  31. package/dist/index.js.map +20 -13
  32. package/dist/reply/problem.d.ts +33 -0
  33. package/dist/reply/problem.d.ts.map +1 -0
  34. package/dist/reply/reply.d.ts.map +1 -1
  35. package/dist/request/limit.d.ts +13 -0
  36. package/dist/request/limit.d.ts.map +1 -0
  37. package/dist/request/read.d.ts +3 -2
  38. package/dist/request/read.d.ts.map +1 -1
  39. package/dist/sse/async-iterable.d.ts +6 -0
  40. package/dist/sse/async-iterable.d.ts.map +1 -0
  41. package/dist/sse/event-stream.d.ts +29 -6
  42. package/dist/sse/event-stream.d.ts.map +1 -1
  43. package/dist/sse/frame.d.ts +35 -0
  44. package/dist/sse/frame.d.ts.map +1 -0
  45. package/dist/sse/named-events.d.ts +70 -0
  46. package/dist/sse/named-events.d.ts.map +1 -0
  47. package/docs/README.md +3 -3
  48. package/docs/guide/groups-and-plugins.md +8 -1
  49. package/docs/guide/hooks.md +128 -3
  50. package/docs/guide/replies.md +40 -0
  51. package/docs/guide/routes.md +115 -1
  52. package/docs/guide/server-sent-events.md +177 -5
  53. package/docs/guide/serving.md +1 -1
  54. package/docs/guide/types.md +3 -1
  55. package/docs/guide/websockets.md +1 -1
  56. package/docs/guide/writing-a-plugin.md +1 -1
  57. package/docs/roadmap.md +35 -2
  58. package/docs/troubleshooting.md +303 -6
  59. package/package.json +1 -1
package/dist/index.js.map CHANGED
@@ -1,28 +1,35 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/router/compile.ts", "../src/router/paths.ts", "../src/router/router.ts", "../src/static/serve.ts", "../src/schema/standard-schema.ts", "../src/sse/event-stream.ts", "../src/types/status.ts", "../src/reply/reply.ts", "../src/static/send.ts", "../src/reply/headers.ts", "../src/static/conditional.ts", "../src/errors/errors.ts", "../src/request/read.ts", "../src/app/send.ts", "../src/app/chain.ts", "../src/app/socket.ts", "../src/app/pipeline.ts", "../src/app/alxia.ts", "../src/app/define-plugin.ts"],
3
+ "sources": ["../src/errors/errors.ts", "../src/request/limit.ts", "../src/router/compile.ts", "../src/router/paths.ts", "../src/router/router.ts", "../src/static/serve.ts", "../src/sse/async-iterable.ts", "../src/schema/standard-schema.ts", "../src/sse/frame.ts", "../src/sse/named-events.ts", "../src/sse/event-stream.ts", "../src/types/status.ts", "../src/reply/reply.ts", "../src/static/send.ts", "../src/reply/headers.ts", "../src/static/conditional.ts", "../src/request/read.ts", "../src/app/context.ts", "../src/app/send.ts", "../src/app/refusal.ts", "../src/app/chain.ts", "../src/app/socket.ts", "../src/app/pipeline.ts", "../src/app/alxia.ts", "../src/app/define-plugin.ts", "../src/reply/problem.ts"],
4
4
  "sourcesContent": [
5
+ "/** Where a refused value was read from. */\nexport type ValidationTarget =\n\t| 'params'\n\t| 'query'\n\t| 'headers'\n\t| 'cookies'\n\t| 'body'\n\t| 'message';\n\nexport interface ValidationIssue {\n\treadonly target: ValidationTarget;\n\treadonly path: readonly (string | number)[];\n\treadonly code: string;\n\treadonly message: string;\n}\n\n/** A part of the request a route validates: where a refused value was read from. */\nexport type RequestPart = Exclude<ValidationTarget, 'message'>;\n\n/**\n * A request the route's schemas refused, as an `onRefusal` hook reads it:\n * the first part that failed, in the order params, query, headers,\n * cookies, body, and every issue, each naming its own part.\n */\nexport interface ValidationRefusal {\n\treadonly kind: 'validation';\n\treadonly part: RequestPart;\n\treadonly issues: readonly ValidationIssue[];\n}\n\n/**\n * A request body larger than its route's `bodyLimit`, as an `onRefusal`\n * hook reads it: the limit, in bytes. Its default is the 413 of\n * `ContentTooLargeBody`.\n */\nexport interface BodyLimitRefusal {\n\treadonly kind: 'body_limit';\n\treadonly limit: number;\n}\n\n/**\n * Why the app refused a request before its handler ran, as an `onRefusal`\n * hook reads it, told apart by `kind`: `validation` or `body_limit`. A\n * kind added later reaches a hook that returns nothing for it as its\n * default.\n */\nexport type Refusal = ValidationRefusal | BodyLimitRefusal;\n\n/** The body of the 400 every route that validates its request may answer. */\nexport interface ValidationErrorBody {\n\treadonly error: 'validation';\n\treadonly issues: readonly ValidationIssue[];\n}\n\n/** The body of the 500 any route may answer. Nothing of the error leaks. */\nexport interface InternalErrorBody {\n\treadonly error: 'internal';\n}\n\n/** The body of the 404, 405 and 426 the app answers outside every route. */\nexport interface RoutingErrorBody {\n\treadonly error: 'not_found' | 'method_not_allowed' | 'upgrade_required';\n}\n\n/**\n * An error a handler or a hook throws to answer with `status` and `body`.\n *\n * Prefer returning `reply(status, body)`: a reply is part of the route's\n * type, and the client sees it. A thrown `HttpError` is not, so the client\n * reads it as a status the route never declared.\n */\nexport class HttpError<\n\tStatus extends number = number,\n\tBody = unknown,\n> extends Error {\n\toverride readonly name: string = 'HttpError';\n\treadonly status: Status;\n\treadonly body: Body;\n\n\tconstructor(status: Status, body: Body, message?: string) {\n\t\tsuper(message ?? `HTTP ${status}`);\n\t\tthis.status = status;\n\t\tthis.body = body;\n\t}\n}\n\n/** The body of the 413 a route with a `bodyLimit` answers to a larger body. */\nexport interface ContentTooLargeBody {\n\treadonly error: 'content_too_large';\n\t/** The route's limit, in bytes. */\n\treadonly limit: number;\n}\n\n/**\n * A request body larger than its route's `bodyLimit`: what reading it\n * throws, as soon as its `Content-Length` or the bytes counted pass the\n * limit. It is answered as a `body_limit` refusal: by the route's\n * `onRefusal` hook, or with its 413. The `onError` hooks never see it.\n */\nexport class ContentTooLargeError extends HttpError<413, ContentTooLargeBody> {\n\toverride readonly name = 'ContentTooLargeError';\n\t/** The route's limit, in bytes. */\n\treadonly limit: number;\n\n\tconstructor(limit: number) {\n\t\tsuper(\n\t\t\t413,\n\t\t\t{ error: 'content_too_large', limit },\n\t\t\t`The request body is larger than the route's limit of ${limit} bytes`,\n\t\t);\n\t\tthis.limit = limit;\n\t}\n}\n\n/**\n * A reply that did not match the schema its route declares for its status.\n * It is answered as a 500: the client must never read an undeclared shape.\n */\nexport class ResponseValidationError extends Error {\n\toverride readonly name = 'ResponseValidationError';\n\treadonly status: number;\n\treadonly issues: readonly ValidationIssue[];\n\n\tconstructor(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tstatus: number,\n\t\tissues: readonly ValidationIssue[],\n\t\t/** Set by `undeclared`, for a status the route has no schema for. */\n\t\tmessage?: string,\n\t) {\n\t\tsuper(\n\t\t\tmessage ??\n\t\t\t\t`${method} ${path}: the ${status} reply does not match its schema: ${issues\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join('; ')}`,\n\t\t);\n\t\tthis.status = status;\n\t\tthis.issues = issues;\n\t}\n\n\t/** A reply whose status the route declares no schema for. */\n\tstatic undeclared(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tstatus: number,\n\t): ResponseValidationError {\n\t\treturn new ResponseValidationError(\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\ttarget: 'body',\n\t\t\t\t\tpath: [],\n\t\t\t\t\tcode: 'undeclared_status',\n\t\t\t\t\tmessage: `the route declares no ${status} reply`,\n\t\t\t\t},\n\t\t\t],\n\t\t\t`${method} ${path} declares no ${status} reply`,\n\t\t);\n\t}\n}\n",
6
+ "import { ContentTooLargeError } from '../errors/errors';\n\n/**\n * The request with its body bounded to `limit` bytes, for every reader:\n * the body parsers, a hook, a handler reading `request.body` as a stream.\n * A `Content-Length` over the limit fails the first read without reading a\n * byte; otherwise the bytes are counted as they arrive, and the read fails\n * with a `ContentTooLargeError` once they pass the limit, so a chunked\n * upload is never buffered whole. A request without a body, or whose body\n * a global hook has already read, is returned as it is.\n */\nexport function limitBody(request: Request, limit: number): Request {\n\tconst source = request.body;\n\tif (source === null || request.bodyUsed || source.locked) return request;\n\tconst declared = Number(request.headers.get('content-length') ?? Number.NaN);\n\tlet body: ReadableStream<Uint8Array>;\n\tif (declared > limit) {\n\t\tsource.cancel().catch(() => {});\n\t\tbody = new ReadableStream({\n\t\t\tstart: (controller) => controller.error(new ContentTooLargeError(limit)),\n\t\t});\n\t} else {\n\t\tlet count = 0;\n\t\tbody = source.pipeThrough(\n\t\t\tnew TransformStream<Uint8Array, Uint8Array>({\n\t\t\t\ttransform(chunk, controller) {\n\t\t\t\t\tcount += chunk.byteLength;\n\t\t\t\t\tif (count > limit) {\n\t\t\t\t\t\tcontroller.error(new ContentTooLargeError(limit));\n\t\t\t\t\t} else controller.enqueue(chunk);\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\treturn new Request(request, { body, duplex: 'half' } as RequestInit);\n}\n\n/** Whether `limit` is a byte count a route can be given. */\nexport function checkLimit(limit: number, where: string): number {\n\tif (!Number.isSafeInteger(limit) || limit < 0) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: bodyLimit must be a whole number of bytes, 0 or more; got ${limit}`,\n\t\t);\n\t}\n\treturn limit;\n}\n",
5
7
  "/**\n * A route path compiled into what matches it, and its rank in\n * `Bun.serve`'s router: segment by segment, a literal before a parameter\n * before a wildcard, with a trailing slash a segment of its own. A path\n * matches strictly, as Bun's router matches it, or forgivingly, a trailing\n * slash more or a wildcard's `/` less, as `listen`'s fallback does.\n *\n * A path is refused where `Bun.serve` would throw at `listen`, or would\n * read it otherwise than `fetch` does: a `:` or a `*` inside a segment, a\n * dot segment, or a literal a request's URL carries otherwise, such as\n * `/é` for `/%C3%A9`. Bun compares a literal with the request's target as\n * it came, and `fetch` with its URL's pathname: a literal in the form the\n * URL gives matches the same requests in both.\n */\n\n/** A segment's rank in Bun's router: lower wins. */\nconst LITERAL = 0;\nconst PARAMETER = 1;\nconst WILDCARD = 2;\n\nexport interface CompiledPath {\n\treadonly path: string;\n\t/** The path with every parameter name erased: two paths with one shape collide. */\n\treadonly shape: string;\n\treadonly names: readonly string[];\n\t/** What matches it forgivingly: a trailing slash more, or a wildcard's `/` less. */\n\treadonly pattern: RegExp | undefined;\n\t/** What matches it as `Bun.serve` does: segment for segment. */\n\treadonly strict: RegExp | undefined;\n\t/** The rank of each segment, `LITERAL`, `PARAMETER` or `WILDCARD`. */\n\treadonly ranks: readonly number[];\n}\n\nexport function compilePath(path: string): CompiledPath {\n\tif (!path.startsWith('/')) {\n\t\tthrow new TypeError(`The route path \"${path}\" must start with \"/\"`);\n\t}\n\tconst names: string[] = [];\n\tconst segments = path.split('/').slice(1);\n\tconst ranks: number[] = [];\n\tlet source = '';\n\tlet strict = '';\n\tlet shape = '';\n\t// The path as a request's URL carries it, and whether `path` differs.\n\tlet carriedPath = '';\n\tlet uncarried = false;\n\tsegments.forEach((segment, index) => {\n\t\tif (segment === '*') {\n\t\t\tif (index !== segments.length - 1) {\n\t\t\t\tthrow new TypeError(`\"${path}\": \"*\" may only end a path`);\n\t\t\t}\n\t\t\tnames.push('*');\n\t\t\tranks.push(WILDCARD);\n\t\t\tsource += '(?:/(.*))?';\n\t\t\tstrict += '/(.*)';\n\t\t\tshape += '/*';\n\t\t\tcarriedPath += '/*';\n\t\t} else if (segment.startsWith(':')) {\n\t\t\tconst name = segment.slice(1);\n\t\t\tif (!/^[A-Za-z_$][\\w$]*$/.test(name)) {\n\t\t\t\tthrow new TypeError(`\"${path}\": \":${name}\" is not a parameter name`);\n\t\t\t}\n\t\t\tif (names.includes(name)) {\n\t\t\t\tthrow new TypeError(`\"${path}\" declares \":${name}\" twice`);\n\t\t\t}\n\t\t\tnames.push(name);\n\t\t\tranks.push(PARAMETER);\n\t\t\tsource += '/([^/]+)';\n\t\t\tstrict += '/([^/]+)';\n\t\t\tshape += '/:';\n\t\t\tcarriedPath += `/${segment}`;\n\t\t} else {\n\t\t\tconst carried = carriedOf(path, segment);\n\t\t\tif (carried !== segment) uncarried = true;\n\t\t\tcarriedPath += `/${carried}`;\n\t\t\tconst literal = `/${segment.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}`;\n\t\t\tranks.push(LITERAL);\n\t\t\tsource += literal;\n\t\t\tstrict += literal;\n\t\t\tshape += `/${segment}`;\n\t\t}\n\t});\n\tconst fixed = names.length === 0;\n\tif (uncarried) {\n\t\tthrow new TypeError(\n\t\t\t`\"${path}\" is not encoded as a request's URL carries it: declare \"${carriedPath}\"`,\n\t\t);\n\t}\n\treturn {\n\t\tpath,\n\t\tshape,\n\t\tnames,\n\t\tpattern: fixed ? undefined : new RegExp(`^${source}/?$`),\n\t\tstrict: fixed ? undefined : new RegExp(`^${strict}$`),\n\t\tranks,\n\t};\n}\n\n/**\n * `segment`, a literal of `path`, as a request's URL carries it: what the\n * URL percent-encodes — non-ASCII, spaces, `\"`, `{` and the like — encoded\n * as it encodes them. Throws for a literal `Bun.serve`'s router reads as\n * something else, and for a dot segment, which no URL keeps.\n */\nfunction carriedOf(path: string, segment: string): string {\n\tif (segment.includes(':')) {\n\t\tthrow new TypeError(\n\t\t\t`\"${path}\": \":\" may only start a segment, as a parameter`,\n\t\t);\n\t}\n\tif (segment.includes('*')) {\n\t\tthrow new TypeError(\n\t\t\t`\"${path}\": \"*\" may only be a whole segment, as a wildcard`,\n\t\t);\n\t}\n\t// What a URL would cut (`?`, `#`), strip (tabs, newlines) or read as a\n\t// `/` (`\\`) is encoded first, so that only its own encoding is left.\n\tlet escaped = '';\n\tfor (const character of segment) {\n\t\tconst code = character.charCodeAt(0);\n\t\tescaped +=\n\t\t\tcode <= 0x20 || code === 0x7f || '?#\\\\'.includes(character)\n\t\t\t\t? `%${code.toString(16).toUpperCase().padStart(2, '0')}`\n\t\t\t\t: character;\n\t}\n\tconst carried = new URL(`http://x/${escaped}/`).pathname;\n\tif (carried === '/') {\n\t\tthrow new TypeError(\n\t\t\t`\"${path}\": \"${segment}\" is a dot segment, which a request's URL never keeps`,\n\t\t);\n\t}\n\treturn carried.slice(1, -1);\n}\n\n/**\n * Below zero when `a` ranks before `b` in Bun's router: the first segment\n * where their ranks differ decides, and a shorter path goes first when one\n * is the other's start. Two paths that both match one request always\n * differ somewhere, since the router refuses two of one shape.\n */\nexport function compareRanks(a: CompiledPath, b: CompiledPath): number {\n\tconst length = Math.min(a.ranks.length, b.ranks.length);\n\tfor (let index = 0; index < length; index++) {\n\t\tconst difference = (a.ranks[index] as number) - (b.ranks[index] as number);\n\t\tif (difference !== 0) return difference;\n\t}\n\treturn a.ranks.length - b.ranks.length;\n}\n\n/** The parameters `pathname` gives `compiled`, or `undefined` if it does not match it. */\nexport function matchPath(\n\tcompiled: CompiledPath,\n\tpathname: string,\n): Record<string, string> | undefined {\n\tif (compiled.pattern === undefined) {\n\t\treturn pathname === compiled.path ||\n\t\t\t(pathname.length > 1 && pathname === `${compiled.path}/`)\n\t\t\t? {}\n\t\t\t: undefined;\n\t}\n\treturn paramsOf(compiled, compiled.pattern.exec(pathname));\n}\n\n/** The parameters `pathname` gives `compiled` when it matches as `Bun.serve` matches it. */\nexport function matchStrictly(\n\tcompiled: CompiledPath,\n\tpathname: string,\n): Record<string, string> | undefined {\n\tif (compiled.strict === undefined) {\n\t\treturn pathname === compiled.path ? {} : undefined;\n\t}\n\treturn paramsOf(compiled, compiled.strict.exec(pathname));\n}\n\nfunction paramsOf(\n\tcompiled: CompiledPath,\n\tmatch: RegExpExecArray | null,\n): Record<string, string> | undefined {\n\tif (match === null) return undefined;\n\tconst params: Record<string, string> = {};\n\tfor (let index = 0; index < compiled.names.length; index++) {\n\t\tconst raw = match[index + 1] ?? '';\n\t\tlet value: string;\n\t\ttry {\n\t\t\tvalue = decodeURIComponent(raw);\n\t\t} catch {\n\t\t\tvalue = raw;\n\t\t}\n\t\tparams[compiled.names[index] as string] = value;\n\t}\n\treturn params;\n}\n",
6
8
  "import type { JoinPath } from '../types/path';\nimport { compilePath } from './compile';\n\n/**\n * `prefix` then `path`, as the app joins them: a prefix, a group, a plugin\n * given to `use`. `/` under `/api` is `/api`, and an empty prefix leaves the\n * path as it is. `JoinPath` is its type. It checks neither argument: the\n * app refuses a prefix or a path that is not absolute when it is given.\n *\n * ```ts\n * joinPath('/api', '/pets'); // '/api/pets'\n * joinPath('/api', '/'); // '/api'\n * joinPath('', '/pets'); // '/pets'\n * ```\n */\nexport function joinPath<Prefix extends string, Path extends string>(\n\tprefix: Prefix,\n\tpath: Path,\n): JoinPath<Prefix, Path> {\n\tif (prefix === '') return path as JoinPath<Prefix, Path>;\n\treturn (path === '/' ? prefix : `${prefix}${path}`) as JoinPath<Prefix, Path>;\n}\n\n/**\n * The path with every parameter name erased: two paths of one shape match\n * the same requests, and the router refuses the second. A parameter is a\n * whole `:name` segment, and a `:` anywhere else is refused.\n *\n * ```ts\n * shapeOf('/pets/:id'); // '/pets/:'\n * shapeOf('/pets/:id') === shapeOf('/pets/:petId'); // true\n * shapeOf('/files/*'); // '/files/*'\n * ```\n *\n * Throws a `TypeError`, as declaring a route there would, for a path that\n * does not start with `/`, a `*` that does not end it, a `:` or a `*` inside\n * a segment, a `:name` that is not an identifier, a name declared twice, a\n * dot segment, or a literal not encoded as a request's URL carries it.\n */\nexport function shapeOf(path: string): string {\n\treturn compilePath(path).shape;\n}\n",
7
9
  "/**\n * The paths an app declares, and the one a request reaches. `app.listen`\n * hands the same paths to `Bun.serve`'s own router instead, and comes back\n * here only for what it leaves unmatched; `match` ranks as Bun does.\n */\n\nimport {\n\ttype CompiledPath,\n\tcompareRanks,\n\tcompilePath,\n\tmatchPath,\n\tmatchStrictly,\n} from './compile';\n\ninterface Entry<Value> {\n\treadonly compiled: CompiledPath;\n\treadonly methods: Map<string, Value>;\n}\n\ntype Found<Value> = [Entry<Value>, Record<string, string>];\n\n/** What `match` found: the route, or the methods its path allows instead. */\nexport type Match<Value> =\n\t| {\n\t\t\treadonly path: string;\n\t\t\treadonly value: Value;\n\t\t\treadonly params: Record<string, string>;\n\t }\n\t| { readonly path: string; readonly allowed: readonly string[] };\n\nexport class Router<Value> {\n\treadonly #paths = new Map<string, Entry<Value>>();\n\treadonly #shapes = new Map<string, string>();\n\t/** The paths with parameters, in Bun's order; rebuilt after an `add`. */\n\t#ranked: Entry<Value>[] | undefined;\n\t/** The paths given to `match` as `served`, compiled once. */\n\treadonly #served = new Map<string, CompiledPath>();\n\n\tadd(method: string, path: string, value: Value): void {\n\t\tconst compiled = compilePath(path);\n\t\tconst existing = this.#shapes.get(compiled.shape);\n\t\tif (existing !== undefined && existing !== path) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`\"${path}\" has the shape of \"${existing}\" with other parameter names. ` +\n\t\t\t\t\t'Use the same names: the two would match the same requests.',\n\t\t\t);\n\t\t}\n\t\tthis.#shapes.set(compiled.shape, path);\n\t\tlet entry = this.#paths.get(path);\n\t\tif (entry === undefined) {\n\t\t\tentry = { compiled, methods: new Map() };\n\t\t\tthis.#paths.set(path, entry);\n\t\t\tthis.#ranked = undefined;\n\t\t}\n\t\tif (entry.methods.has(method)) {\n\t\t\tthrow new TypeError(`${method} ${path} is declared twice`);\n\t\t}\n\t\tentry.methods.set(method, value);\n\t}\n\n\t/** The paths declared, each with its methods. */\n\tpaths(): IterableIterator<[string, ReadonlyMap<string, Value>]> {\n\t\tconst entries = this.#paths.entries();\n\t\treturn (function* () {\n\t\t\tfor (const [path, entry] of entries) yield [path, entry.methods];\n\t\t})();\n\t}\n\n\t/** Whether a path of the same shape as `path` is declared: one matching the same requests. */\n\thasShape(path: string): boolean {\n\t\treturn this.#shapes.has(compilePath(path).shape);\n\t}\n\n\t/** Whether `path` is declared, and has neither a parameter nor a wildcard. */\n\tisFixed(path: string): boolean {\n\t\tconst entry = this.#paths.get(path);\n\t\treturn entry !== undefined && entry.compiled.pattern === undefined;\n\t}\n\n\t/** The methods declared at `path`, exactly as it was declared. */\n\tmethodsAt(path: string): ReadonlyMap<string, Value> | undefined {\n\t\treturn this.#paths.get(path)?.methods;\n\t}\n\n\tparamsAt(path: string, pathname: string): Record<string, string> {\n\t\tconst entry = this.#paths.get(path);\n\t\treturn (entry && matchPath(entry.compiled, pathname)) ?? {};\n\t}\n\n\t/**\n\t * The route `pathname` reaches by `method`; the methods its path allows\n\t * when that path has no route for `method`; nothing when it reaches no\n\t * path. The path is the one `Bun.serve` would choose under `listen`:\n\t * segment by segment, a literal wins over a parameter, which wins over a\n\t * wildcard, whatever the order of declaration. So `/api/*` wins over\n\t * `/*`, and `/users/me` over `/users/:id`, even for a method only\n\t * `/users/:id` has: `Bun.serve` picks the path before the method.\n\t *\n\t * `served` are paths `Bun.serve` answers itself, the app's pages: when\n\t * one of them ranks first, nothing matches, as `fetch` cannot serve it.\n\t *\n\t * Where no path matches as Bun's does, one matching but for a trailing\n\t * slash — `/users/` for `/users`, `/files` for `/files/*` — is taken, in\n\t * the same order: what `listen`'s fallback answers too.\n\t */\n\tmatch(\n\t\tmethod: string,\n\t\tpathname: string,\n\t\tserved?: Iterable<string>,\n\t): Match<Value> | undefined {\n\t\tlet found = this.#strictly(pathname);\n\t\tif (served !== undefined && this.#servedFirst(pathname, found, served)) {\n\t\t\treturn undefined;\n\t\t}\n\t\tfound ??= this.#forgivingly(pathname);\n\t\tif (found === undefined) return undefined;\n\t\tconst [entry, params] = found;\n\t\tconst path = entry.compiled.path;\n\t\tconst value = entry.methods.get(method);\n\t\tif (value !== undefined) return { path, value, params };\n\t\treturn { path, allowed: [...entry.methods.keys()] };\n\t}\n\n\t/** The path Bun's router chooses for `pathname`. */\n\t#strictly(pathname: string): Found<Value> | undefined {\n\t\t// A path without parameters ranks before any other that matches.\n\t\tconst exact = this.#paths.get(pathname);\n\t\tif (exact !== undefined && exact.compiled.pattern === undefined) {\n\t\t\treturn [exact, {}];\n\t\t}\n\t\treturn this.#first(pathname, matchStrictly);\n\t}\n\n\t/** The path `pathname` reaches but for a trailing slash, in the same order. */\n\t#forgivingly(pathname: string): Found<Value> | undefined {\n\t\tif (pathname.length > 1 && pathname.endsWith('/')) {\n\t\t\tconst exact = this.#paths.get(pathname.slice(0, -1));\n\t\t\tif (exact !== undefined && exact.compiled.pattern === undefined) {\n\t\t\t\treturn [exact, {}];\n\t\t\t}\n\t\t}\n\t\treturn this.#first(pathname, matchPath);\n\t}\n\n\t/** The first path with parameters `matches` accepts, in Bun's order. */\n\t#first(\n\t\tpathname: string,\n\t\tmatches: (\n\t\t\tcompiled: CompiledPath,\n\t\t\tpathname: string,\n\t\t) => Record<string, string> | undefined,\n\t): Found<Value> | undefined {\n\t\tthis.#ranked ??= [...this.#paths.values()]\n\t\t\t.filter((entry) => entry.compiled.pattern !== undefined)\n\t\t\t.sort((a, b) => compareRanks(a.compiled, b.compiled));\n\t\tfor (const entry of this.#ranked) {\n\t\t\tconst params = matches(entry.compiled, pathname);\n\t\t\tif (params !== undefined) return [entry, params];\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Whether one of `served` matches `pathname` and ranks before `found`. */\n\t#servedFirst(\n\t\tpathname: string,\n\t\tfound: Found<Value> | undefined,\n\t\tserved: Iterable<string>,\n\t): boolean {\n\t\tfor (const path of served) {\n\t\t\tlet compiled = this.#served.get(path);\n\t\t\tif (compiled === undefined) {\n\t\t\t\tcompiled = compilePath(path);\n\t\t\t\tthis.#served.set(path, compiled);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tmatchStrictly(compiled, pathname) !== undefined &&\n\t\t\t\t(found === undefined || compareRanks(compiled, found[0].compiled) < 0)\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n",
8
10
  "/**\n * Static files, served through the app's pipeline: every hook runs around\n * them, and the client types them like any route.\n */\nimport { extname, resolve, sep } from 'node:path';\nimport type { BaseContext, MaybePromise } from '../app/types';\nimport { type AnyReply, Reply } from '../reply/reply';\nimport { type Found, precompressed, send } from './send';\nimport type {\n\tFileNotFoundBody,\n\tFileOptions,\n\tFileSource,\n\tStaticOptions,\n} from './types';\n\nconst notFound: FileNotFoundBody = { error: 'not_found' };\n\n/** A source as a lookup of one relative path. */\nfunction lookup(source: FileSource) {\n\tif (typeof source === 'function') {\n\t\treturn async (path: string, ctx: BaseContext) => {\n\t\t\tconst file = await source(path, ctx);\n\t\t\treturn file ? file : undefined;\n\t\t};\n\t}\n\tconst root = resolve(source);\n\treturn async (path: string): Promise<Blob | undefined> => {\n\t\tconst full = resolve(root, path);\n\t\tif (full !== root && !full.startsWith(root + sep)) return undefined;\n\t\tconst file = Bun.file(full);\n\t\treturn (await file.exists()) ? file : undefined;\n\t};\n}\n\n/** The segments of a requested path, or `undefined` for one that must never be served. */\nfunction segmentsOf(wanted: string, dotfiles: boolean): string[] | undefined {\n\tif (wanted.includes('\\0') || wanted.includes('\\\\')) return undefined;\n\tconst segments = wanted.split('/').filter((segment) => segment !== '');\n\tif (segments.some((segment) => segment === '..' || segment === '.'))\n\t\treturn undefined;\n\tif (!dotfiles && segments.some((segment) => segment.startsWith('.')))\n\t\treturn undefined;\n\treturn segments;\n}\n\n/** The handler of `app.static`: the wildcard's path, looked up in `source`. */\nexport function staticHandler(source: FileSource, options: StaticOptions = {}) {\n\tconst find = lookup(source);\n\tconst indexes =\n\t\toptions.index === false\n\t\t\t? []\n\t\t\t: typeof options.index === 'string'\n\t\t\t\t? [options.index]\n\t\t\t\t: (options.index ?? ['index.html']);\n\tconst extensions = options.extensions ?? [];\n\tconst dotfiles = options.dotfiles ?? false;\n\n\tconst locate = async (\n\t\twanted: string,\n\t\tctx: BaseContext,\n\t): Promise<Found | undefined> => {\n\t\tconst segments = segmentsOf(wanted, dotfiles);\n\t\tif (segments === undefined) return undefined;\n\t\tconst path = segments.join('/');\n\t\tconst candidates = [path];\n\t\tif (path !== '' && extname(path) === '') {\n\t\t\tcandidates.push(\n\t\t\t\t...extensions.map(\n\t\t\t\t\t(extension) => `${path}.${extension.replace(/^\\./, '')}`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tcandidates.push(\n\t\t\t...indexes.map((index) => (path === '' ? index : `${path}/${index}`)),\n\t\t);\n\t\tfor (const candidate of candidates) {\n\t\t\tif (candidate === '') continue;\n\t\t\tconst file = await find(candidate, ctx);\n\t\t\tif (file !== undefined) return { file, path: candidate };\n\t\t}\n\t\treturn undefined;\n\t};\n\n\treturn async (ctx: BaseContext): Promise<AnyReply> => {\n\t\tconst wanted = ctx.pathParams['*'] ?? '';\n\t\tconst found =\n\t\t\t(await locate(wanted, ctx)) ??\n\t\t\t(options.fallback === undefined\n\t\t\t\t? undefined\n\t\t\t\t: await locate(options.fallback, ctx));\n\t\tif (found === undefined) return new Reply(404, notFound);\n\t\tconst encoded = await precompressed(\n\t\t\tfound,\n\t\t\toptions.precompressed ?? [],\n\t\t\tctx,\n\t\t\tfind,\n\t\t);\n\t\treturn send(\n\t\t\tctx,\n\t\t\tfound,\n\t\t\toptions,\n\t\t\tencoded,\n\t\t\t(options.precompressed?.length ?? 0) > 0,\n\t\t);\n\t};\n}\n\n/** The handler of `app.file`: one file, read anew on every request so a change is served. */\nexport function fileHandler(\n\tfile:\n\t\t| string\n\t\t| Blob\n\t\t| ((ctx: BaseContext) => MaybePromise<Blob | null | undefined>),\n\toptions: FileOptions = {},\n) {\n\treturn async (ctx: BaseContext): Promise<AnyReply> => {\n\t\tconst blob =\n\t\t\ttypeof file === 'string'\n\t\t\t\t? Bun.file(file)\n\t\t\t\t: typeof file === 'function'\n\t\t\t\t\t? await file(ctx)\n\t\t\t\t\t: file;\n\t\tif (!blob || (isBunFile(blob) && !(await blob.exists()))) {\n\t\t\treturn new Reply(404, notFound);\n\t\t}\n\t\tconst path =\n\t\t\ttypeof file === 'string'\n\t\t\t\t? file\n\t\t\t\t: ((isBunFile(blob) ? blob.name : undefined) ?? ctx.route);\n\t\treturn send(ctx, { file: blob, path }, options, undefined, false);\n\t};\n}\n\nfunction isBunFile(blob: Blob): blob is Bun.BunFile {\n\treturn typeof (blob as Bun.BunFile).exists === 'function';\n}\n",
11
+ "/**\n * Whether a body is a stream of events: any async iterable but a\n * `ReadableStream`, which is sent as bytes.\n */\nexport function isAsyncIterable(\n\tvalue: unknown,\n): value is AsyncIterable<unknown> {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object' &&\n\t\tSymbol.asyncIterator in value &&\n\t\t!(value instanceof ReadableStream)\n\t);\n}\n",
9
12
  "/**\n * [Standard Schema](https://standardschema.dev), the part the framework calls.\n * Zod 4, Valibot and ArkType schemas all carry it, so nothing here imports\n * any of them: it reads their `~standard`.\n */\nimport type { ValidationIssue, ValidationTarget } from '../errors/errors';\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n\treadonly '~standard': {\n\t\treadonly version: 1;\n\t\treadonly vendor: string;\n\t\treadonly validate: (\n\t\t\tvalue: unknown,\n\t\t) => StandardResult<Output> | Promise<StandardResult<Output>>;\n\t\treadonly types?:\n\t\t\t| { readonly input: Input; readonly output: Output }\n\t\t\t| undefined;\n\t};\n}\n\nexport type StandardResult<Output> =\n\t| { readonly value: Output; readonly issues?: undefined }\n\t| { readonly issues: readonly StandardIssue[] };\n\nexport interface StandardIssue {\n\treadonly message: string;\n\treadonly path?:\n\t\t| readonly (PropertyKey | { readonly key: PropertyKey })[]\n\t\t| undefined;\n}\n\n/** What a schema accepts: what a handler hands to `reply`, what a client sends. */\nexport type InferInput<Schema extends StandardSchemaV1> = NonNullable<\n\tSchema['~standard']['types']\n>['input'];\n\n/** What a schema gives back: what a handler reads. */\nexport type InferOutput<Schema extends StandardSchemaV1> = NonNullable<\n\tSchema['~standard']['types']\n>['output'];\n\nexport type Checked =\n\t| { readonly ok: true; readonly value: unknown }\n\t| { readonly ok: false; readonly issues: ValidationIssue[] };\n\n/**\n * `value` through `schema`: its output, or its issues. Zod's `code` is kept;\n * a vendor without one reads as `custom`.\n */\nexport async function check(\n\tschema: StandardSchemaV1,\n\tvalue: unknown,\n\ttarget: ValidationTarget,\n): Promise<Checked> {\n\tlet result = schema['~standard'].validate(value);\n\tif (result instanceof Promise) result = await result;\n\tif (result.issues === undefined) return { ok: true, value: result.value };\n\treturn {\n\t\tok: false,\n\t\tissues: result.issues.map((issue) => {\n\t\t\tconst { code } = issue as { code?: unknown };\n\t\t\treturn {\n\t\t\t\ttarget,\n\t\t\t\tpath: (issue.path ?? [])\n\t\t\t\t\t.map((key) => (typeof key === 'object' ? key.key : key))\n\t\t\t\t\t.filter((key): key is string | number => typeof key !== 'symbol'),\n\t\t\t\tcode: typeof code === 'string' ? code : 'custom',\n\t\t\t\tmessage: issue.message,\n\t\t\t};\n\t\t}),\n\t};\n}\n",
10
- "/**\n * Server-sent events, typed. A handler replies with an async iterable — an\n * `async function*` — and each value it yields is one event, sent as JSON.\n * The client reads the same values back as an async iterable.\n */\nimport {\n\tcheck,\n\ttype InferInput,\n\ttype InferOutput,\n\ttype StandardSchemaV1,\n} from '../schema/standard-schema';\n\n/** A response schema whose body is a stream of events, each one checked by `item`. */\nexport interface EventStreamSchema<Item extends StandardSchemaV1>\n\textends StandardSchemaV1<\n\t\tAsyncIterable<InferInput<Item>>,\n\t\tAsyncIterable<InferOutput<Item>>\n\t> {\n\treadonly '~eventStream': Item;\n}\n\n/**\n * The schema of a reply that streams events: each value the handler yields\n * is checked by `item`, and sent as its output.\n *\n * ```ts\n * app.get('/ticks', { response: { 200: eventStream(Tick) } }, ({ reply }) =>\n * reply(200, (async function* () { yield { n: 1 }; })()));\n * ```\n */\nexport function eventStream<Item extends StandardSchemaV1>(\n\titem: Item,\n): EventStreamSchema<Item> {\n\treturn {\n\t\t'~eventStream': item,\n\t\t'~standard': {\n\t\t\tversion: 1,\n\t\t\tvendor: 'alxia',\n\t\t\tvalidate: (value) => {\n\t\t\t\tif (!isAsyncIterable(value)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tissues: [\n\t\t\t\t\t\t\t{ message: 'An event stream replies with an async iterable' },\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { value: checkEach(item, value) };\n\t\t\t},\n\t\t},\n\t} as EventStreamSchema<Item>;\n}\n\nasync function* checkEach(\n\titem: StandardSchemaV1,\n\tvalues: AsyncIterable<unknown>,\n): AsyncGenerator<unknown> {\n\tfor await (const value of values) {\n\t\tconst checked = await check(item, value, 'body');\n\t\tif (!checked.ok) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`An event does not match its schema: ${checked.issues\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join('; ')}`,\n\t\t\t);\n\t\t}\n\t\tyield checked.value;\n\t}\n}\n\nexport function isAsyncIterable(\n\tvalue: unknown,\n): value is AsyncIterable<unknown> {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object' &&\n\t\tSymbol.asyncIterator in value &&\n\t\t!(value instanceof ReadableStream)\n\t);\n}\n\nexport function isEventStreamSchema(\n\tschema: StandardSchemaV1,\n): schema is EventStreamSchema<StandardSchemaV1> {\n\treturn '~eventStream' in schema;\n}\n\n/** How often a comment keeps an idle stream open: Bun closes a silent one. */\nexport const KEEP_ALIVE_MS = 8_000;\n\n/**\n * The events of `values` as a `text/event-stream` body: each value as one\n * `data:` line of JSON, a comment while nothing is sent, and the iterator\n * closed when the client goes away.\n */\nexport function toEventStream(\n\tvalues: AsyncIterable<unknown>,\n\tsignal?: AbortSignal,\n): ReadableStream<Uint8Array> {\n\tconst encoder = new TextEncoder();\n\tconst iterator = values[Symbol.asyncIterator]();\n\tlet timer: ReturnType<typeof setInterval> | undefined;\n\t// Set once the reader is gone: an event still awaited then has nowhere\n\t// to go, and is neither sent nor reported.\n\tlet cancelled = false;\n\tconst stop = () => {\n\t\tif (timer !== undefined) clearInterval(timer);\n\t\ttimer = undefined;\n\t};\n\treturn new ReadableStream<Uint8Array>({\n\t\tstart(controller) {\n\t\t\ttimer = setInterval(() => {\n\t\t\t\ttry {\n\t\t\t\t\tcontroller.enqueue(encoder.encode(': keep-alive\\n\\n'));\n\t\t\t\t} catch {\n\t\t\t\t\tstop();\n\t\t\t\t}\n\t\t\t}, KEEP_ALIVE_MS);\n\t\t\tsignal?.addEventListener('abort', () => {\n\t\t\t\tcancelled = true;\n\t\t\t\tstop();\n\t\t\t\tvoid iterator.return?.();\n\t\t\t});\n\t\t},\n\t\tasync pull(controller) {\n\t\t\ttry {\n\t\t\t\tconst next = await iterator.next();\n\t\t\t\tif (cancelled) return;\n\t\t\t\tif (next.done) {\n\t\t\t\t\tstop();\n\t\t\t\t\tcontroller.close();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = JSON.stringify(next.value) ?? 'null';\n\t\t\t\tcontroller.enqueue(\n\t\t\t\t\tencoder.encode(\n\t\t\t\t\t\t`${data\n\t\t\t\t\t\t\t.split('\\n')\n\t\t\t\t\t\t\t.map((line) => `data: ${line}`)\n\t\t\t\t\t\t\t.join('\\n')}\\n\\n`,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tstop();\n\t\t\t\t// A real failure of the generator is reported even after the\n\t\t\t\t// reader left; only the stream, gone already, is not errored.\n\t\t\t\tconsole.error(error);\n\t\t\t\tif (cancelled) return;\n\t\t\t\tcontroller.error(error);\n\t\t\t}\n\t\t},\n\t\tcancel() {\n\t\t\tcancelled = true;\n\t\t\tstop();\n\t\t\tvoid iterator.return?.();\n\t\t},\n\t});\n}\n",
13
+ "/**\n * One event of a `text/event-stream` body as it is written: its `event:`,\n * `id:` and `retry:` fields, then its data as JSON on `data:` lines.\n */\nimport type { ValidationIssue } from '../errors/errors';\n\n/**\n * An event with fields of its own, as a named stream's validator gives it\n * to the writer. A plain value yielded by any other stream is sent as its\n * `data` alone, so a `{ event }` object a handler yields without a named\n * schema stays JSON.\n */\nexport class Frame {\n\treadonly event: string;\n\treadonly data: unknown;\n\treadonly id: string | undefined;\n\treadonly retry: number | undefined;\n\n\tconstructor(\n\t\tevent: string,\n\t\tdata: unknown,\n\t\tid: string | undefined,\n\t\tretry: number | undefined,\n\t) {\n\t\tthis.event = event;\n\t\tthis.data = data;\n\t\tthis.id = id;\n\t\tthis.retry = retry;\n\t}\n}\n\n/**\n * `value` as the text of one event: a `Frame`'s fields, then its data, each\n * line of it on a `data:` line of its own, and the blank line ending it.\n */\nexport function frameText(value: unknown): string {\n\tconst lines: string[] = [];\n\tlet data = value;\n\tif (value instanceof Frame) {\n\t\tlines.push(`event: ${value.event}`);\n\t\tif (value.id !== undefined) lines.push(`id: ${value.id}`);\n\t\tif (value.retry !== undefined) lines.push(`retry: ${value.retry}`);\n\t\tdata = value.data;\n\t}\n\tconst json = JSON.stringify(data) ?? 'null';\n\tfor (const line of json.split(/\\r\\n|\\r|\\n/)) lines.push(`data: ${line}`);\n\treturn `${lines.join('\\n')}\\n\\n`;\n}\n\n/**\n * The error of an event its schema refuses, each issue at its path, under\n * the event's name on a named stream.\n */\nexport function mismatch(\n\tissues: readonly ValidationIssue[],\n\tname?: string,\n): TypeError {\n\treturn new TypeError(\n\t\t`An event does not match its schema: ${issues\n\t\t\t.map((issue) => {\n\t\t\t\tconst path = name === undefined ? issue.path : [name, ...issue.path];\n\t\t\t\treturn `${path.join('.') || '(root)'}: ${issue.message}`;\n\t\t\t})\n\t\t\t.join('; ')}`,\n\t);\n}\n\n/** A line break, or NUL, which an `EventSource` reads as no id at all. */\nconst BREAK = /[\\r\\n\\0]/;\n\n/** Why `name` cannot be an event's name, or `undefined` when it can. */\nexport function refuseName(name: string): string | undefined {\n\tif (name === '') return 'An event name must not be empty';\n\tif (BREAK.test(name)) {\n\t\treturn `An event name must not hold a line break or a NUL: ${JSON.stringify(name)}`;\n\t}\n\treturn undefined;\n}\n\n/** Why `id` cannot be an event's id, or `undefined` when it can. */\nexport function refuseId(id: unknown): string | undefined {\n\tif (id === undefined) return undefined;\n\tif (typeof id !== 'string') return 'An event id must be a string';\n\tif (BREAK.test(id)) {\n\t\treturn `An event id must not hold a line break or a NUL: ${JSON.stringify(id)}`;\n\t}\n\treturn undefined;\n}\n\n/** Why `retry` cannot be an event's retry, or `undefined` when it can. */\nexport function refuseRetry(retry: unknown): string | undefined {\n\tif (retry === undefined) return undefined;\n\tif (typeof retry !== 'number' || !Number.isSafeInteger(retry) || retry < 0) {\n\t\treturn `An event retry must be a whole number of milliseconds, 0 or more: ${String(retry)}`;\n\t}\n\treturn undefined;\n}\n",
14
+ "/**\n * Server-sent events with names: `eventStream({ state: State, ping: Ping })`\n * maps each event name to the schema of its data. The handler yields\n * `{ event, data, id?, retry? }`, and the client reads `{ event, data, id? }`,\n * a union discriminated by `event`.\n */\nimport {\n\tcheck,\n\ttype InferInput,\n\ttype InferOutput,\n\ttype StandardSchemaV1,\n} from '../schema/standard-schema';\nimport { isAsyncIterable } from './async-iterable';\nimport { Frame, mismatch, refuseId, refuseName, refuseRetry } from './frame';\n\n/** The schema of each event's data, by event name. */\nexport type EventSchemas = Readonly<Record<string, StandardSchemaV1>>;\n\n/** The schemas by name of `Of`: itself, or those of the named stream it is. */\ntype SchemasOf<Of> = Of extends { readonly '~events': infer Events }\n\t? Events\n\t: Of;\n\n/**\n * What a handler yields on a named stream: one of the declared events, with\n * data its schema accepts. `id` sets the client's last event id; `retry`, in\n * milliseconds, how long an `EventSource` waits before it reconnects. `Of`\n * is the stream's schema, `EventInput<typeof Push>`, or its schemas by name.\n */\nexport type EventInput<Of extends EventSchemas | AnyNamedEventStream> = {\n\t[Name in keyof SchemasOf<Of> & string]: {\n\t\treadonly event: Name;\n\t\treadonly data: InferInput<Extract<SchemasOf<Of>[Name], StandardSchemaV1>>;\n\t\treadonly id?: string;\n\t\treadonly retry?: number;\n\t};\n}[keyof SchemasOf<Of> & string];\n\n/** What the client reads of a named stream: the event, its data as its schema gives it back, and its id when it had one. */\nexport type EventOutput<Of extends EventSchemas | AnyNamedEventStream> = {\n\t[Name in keyof SchemasOf<Of> & string]: {\n\t\treadonly event: Name;\n\t\treadonly data: InferOutput<Extract<SchemasOf<Of>[Name], StandardSchemaV1>>;\n\t\treadonly id?: string;\n\t};\n}[keyof SchemasOf<Of> & string];\n\n/** Any named stream, whatever its events. */\ninterface AnyNamedEventStream {\n\treadonly '~events': EventSchemas;\n}\n\n/** The fields an event may carry besides its name and data. */\nexport interface EventFields {\n\treadonly id?: string;\n\treadonly retry?: number;\n}\n\n/** A response schema whose body is a stream of named events, each one's data checked by the schema of its name. */\nexport interface NamedEventStreamSchema<Events extends EventSchemas>\n\textends StandardSchemaV1<\n\t\tAsyncIterable<EventInput<Events>>,\n\t\tAsyncIterable<EventOutput<Events>>\n\t> {\n\treadonly '~events': Events;\n\t/**\n\t * One event to yield, typed by the schema of its name: its data is\n\t * checked, and its literals kept, where a plain `{ event, data }` object\n\t * yielded from a generator would widen `event` to `string`.\n\t *\n\t * ```ts\n\t * yield Push.event('ping', { interval: 30 });\n\t * ```\n\t */\n\tevent<Name extends keyof Events & string>(\n\t\tevent: Name,\n\t\tdata: InferInput<Events[Name]>,\n\t\tfields?: EventFields,\n\t): EventInput<Pick<Events, Name>>;\n}\n\nexport function namedEventStream<Events extends EventSchemas>(\n\tevents: Events,\n): NamedEventStreamSchema<Events> {\n\tconst names = Object.keys(events);\n\tif (names.length === 0) {\n\t\tthrow new TypeError('A named event stream declares at least one event');\n\t}\n\tfor (const name of names) {\n\t\tconst refused = refuseName(name);\n\t\tif (refused !== undefined) throw new TypeError(refused);\n\t\tconst schema: unknown = events[name];\n\t\tif (\n\t\t\tschema === null ||\n\t\t\ttypeof schema !== 'object' ||\n\t\t\t!('~standard' in schema)\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`The event ${JSON.stringify(name)} is not a Standard Schema`,\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\t'~events': events,\n\t\tevent: (event: string, data: unknown, fields?: EventFields) => ({\n\t\t\t...fields,\n\t\t\tevent,\n\t\t\tdata,\n\t\t}),\n\t\t'~standard': {\n\t\t\tversion: 1,\n\t\t\tvendor: 'alxia',\n\t\t\tvalidate: (value) => {\n\t\t\t\tif (!isAsyncIterable(value)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tissues: [\n\t\t\t\t\t\t\t{ message: 'An event stream replies with an async iterable' },\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { value: toFrames(events, value, true) };\n\t\t\t},\n\t\t},\n\t} as NamedEventStreamSchema<Events>;\n}\n\nexport function isNamedEventStreamSchema(\n\tschema: StandardSchemaV1,\n): schema is NamedEventStreamSchema<EventSchemas> {\n\treturn '~events' in schema;\n}\n\n/**\n * Each value of `values` as a `Frame`: its name declared, its id and retry\n * safe to write, and, when `validate`, its data checked by its schema. The\n * fields are checked even when responses are not validated: a line break in\n * one would write a frame the handler never yielded.\n */\nexport async function* toFrames(\n\tevents: EventSchemas,\n\tvalues: AsyncIterable<unknown>,\n\tvalidate: boolean,\n): AsyncGenerator<Frame> {\n\tfor await (const value of values) {\n\t\tif (value === null || typeof value !== 'object' || !('event' in value)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'An event of a named stream is an object { event, data }',\n\t\t\t);\n\t\t}\n\t\tconst { event, data, id, retry } = value as {\n\t\t\tevent: unknown;\n\t\t\tdata?: unknown;\n\t\t\tid?: unknown;\n\t\t\tretry?: unknown;\n\t\t};\n\t\tconst schema =\n\t\t\ttypeof event === 'string' && Object.hasOwn(events, event)\n\t\t\t\t? events[event]\n\t\t\t\t: undefined;\n\t\tif (schema === undefined) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`The event ${JSON.stringify(event)} is not declared: ${Object.keys(\n\t\t\t\t\tevents,\n\t\t\t\t).join(', ')}`,\n\t\t\t);\n\t\t}\n\t\tconst refused = refuseId(id) ?? refuseRetry(retry);\n\t\tif (refused !== undefined) throw new TypeError(refused);\n\t\tlet output = data;\n\t\tif (validate) {\n\t\t\tconst checked = await check(schema, data, 'body');\n\t\t\tif (!checked.ok) {\n\t\t\t\tthrow mismatch(checked.issues, event as string);\n\t\t\t}\n\t\t\toutput = checked.value;\n\t\t}\n\t\tyield new Frame(\n\t\t\tevent as string,\n\t\t\toutput,\n\t\t\tid as string | undefined,\n\t\t\tretry as number | undefined,\n\t\t);\n\t}\n}\n",
15
+ "/**\n * Server-sent events, typed. A handler replies with an async iterable — an\n * `async function*` — and each value it yields is one event, sent as JSON.\n * The client reads the same values back as an async iterable.\n */\nimport {\n\tcheck,\n\ttype InferInput,\n\ttype InferOutput,\n\ttype StandardSchemaV1,\n} from '../schema/standard-schema';\nimport { isAsyncIterable } from './async-iterable';\nimport { frameText, mismatch } from './frame';\nimport {\n\ttype EventSchemas,\n\ttype NamedEventStreamSchema,\n\tnamedEventStream,\n} from './named-events';\n\n/** A response schema whose body is a stream of events, each one checked by `item`. */\nexport interface EventStreamSchema<Item extends StandardSchemaV1>\n\textends StandardSchemaV1<\n\t\tAsyncIterable<InferInput<Item>>,\n\t\tAsyncIterable<InferOutput<Item>>\n\t> {\n\treadonly '~eventStream': Item;\n}\n\n/**\n * The schema of a reply that streams events.\n *\n * Given one schema, each value the handler yields is checked by it and sent\n * as its output, on `data:` lines alone:\n *\n * ```ts\n * app.get('/ticks', { response: { 200: eventStream(Tick) } }, ({ reply }) =>\n * reply(200, (async function* () { yield { n: 1 }; })()));\n * ```\n *\n * Given a schema per event name, the handler yields `{ event, data, id?,\n * retry? }`: only a declared name, with data its schema accepts. Each is\n * sent with its `event:` line, and the client reads `{ event, data, id? }`:\n *\n * ```ts\n * const Push = eventStream({ state: StateChange, ping: Ping });\n * app.get('/push', { response: { 200: Push } }, ({ reply }) =>\n * reply(200, (async function* () { yield { event: 'ping', data: { interval: 30 } }; })()));\n * ```\n *\n * An event name that is empty or holds a line break throws a `TypeError`.\n */\nexport function eventStream<Item extends StandardSchemaV1>(\n\titem: Item,\n): EventStreamSchema<Item>;\nexport function eventStream<Events extends EventSchemas>(\n\tevents: Events & Declarable<Events>,\n): NamedEventStreamSchema<Events>;\nexport function eventStream(\n\tschema: StandardSchemaV1 | EventSchemas,\n): EventStreamSchema<StandardSchemaV1> | NamedEventStreamSchema<EventSchemas> {\n\tif (!isStandardSchema(schema))\n\t\treturn namedEventStream(schema as EventSchemas);\n\tconst item = schema as StandardSchemaV1;\n\treturn {\n\t\t'~eventStream': item,\n\t\t'~standard': {\n\t\t\tversion: 1,\n\t\t\tvendor: 'alxia',\n\t\t\tvalidate: (value) => {\n\t\t\t\tif (!isAsyncIterable(value)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tissues: [\n\t\t\t\t\t\t\t{ message: 'An event stream replies with an async iterable' },\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { value: checkEach(item, value) };\n\t\t\t},\n\t\t},\n\t} as EventStreamSchema<StandardSchemaV1>;\n}\n\nasync function* checkEach(\n\titem: StandardSchemaV1,\n\tvalues: AsyncIterable<unknown>,\n): AsyncGenerator<unknown> {\n\tfor await (const value of values) {\n\t\tconst checked = await check(item, value, 'body');\n\t\tif (!checked.ok) throw mismatch(checked.issues);\n\t\tyield checked.value;\n\t}\n}\n\n/**\n * `unknown` for a map of events the stream can write, `never` for one with\n * no event or an empty name: a compile error, as it is a `TypeError` at run\n * time.\n */\ntype Declarable<Events> = [keyof Events] extends [never]\n\t? never\n\t: '' extends keyof Events\n\t\t? never\n\t\t: unknown;\n\n/** A schema, as opposed to a map of them: an event may be named `~standard`. */\nfunction isStandardSchema(value: object): value is StandardSchemaV1 {\n\tconst standard = (\n\t\tvalue as { '~standard'?: { version?: unknown; vendor?: unknown } }\n\t)['~standard'];\n\treturn standard?.version === 1 && typeof standard.vendor === 'string';\n}\n\nexport function isEventStreamSchema(\n\tschema: StandardSchemaV1,\n): schema is EventStreamSchema<StandardSchemaV1> {\n\treturn '~eventStream' in schema;\n}\n\n/** How often a comment keeps an idle stream open: Bun closes a silent one. */\nexport const KEEP_ALIVE_MS = 8_000;\n\n/**\n * The events of `values` as a `text/event-stream` body: each value as\n * `data:` lines of JSON, after its `event:`, `id:` and `retry:` lines on a\n * named stream, a comment while nothing is sent, and the iterator closed\n * when the client goes away.\n */\nexport function toEventStream(\n\tvalues: AsyncIterable<unknown>,\n\tsignal?: AbortSignal,\n): ReadableStream<Uint8Array> {\n\tconst encoder = new TextEncoder();\n\tconst iterator = values[Symbol.asyncIterator]();\n\tlet timer: ReturnType<typeof setInterval> | undefined;\n\t// Set once the reader is gone: an event still awaited then has nowhere\n\t// to go, and is neither sent nor reported.\n\tlet cancelled = false;\n\tconst stop = () => {\n\t\tif (timer !== undefined) clearInterval(timer);\n\t\ttimer = undefined;\n\t};\n\treturn new ReadableStream<Uint8Array>({\n\t\tstart(controller) {\n\t\t\ttimer = setInterval(() => {\n\t\t\t\ttry {\n\t\t\t\t\tcontroller.enqueue(encoder.encode(': keep-alive\\n\\n'));\n\t\t\t\t} catch {\n\t\t\t\t\tstop();\n\t\t\t\t}\n\t\t\t}, KEEP_ALIVE_MS);\n\t\t\tsignal?.addEventListener('abort', () => {\n\t\t\t\tcancelled = true;\n\t\t\t\tstop();\n\t\t\t\tvoid iterator.return?.();\n\t\t\t});\n\t\t},\n\t\tasync pull(controller) {\n\t\t\ttry {\n\t\t\t\tconst next = await iterator.next();\n\t\t\t\tif (cancelled) return;\n\t\t\t\tif (next.done) {\n\t\t\t\t\tstop();\n\t\t\t\t\tcontroller.close();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcontroller.enqueue(encoder.encode(frameText(next.value)));\n\t\t\t} catch (error) {\n\t\t\t\tstop();\n\t\t\t\t// A real failure of the generator is reported even after the\n\t\t\t\t// reader left; only the stream, gone already, is not errored.\n\t\t\t\tconsole.error(error);\n\t\t\t\tif (cancelled) return;\n\t\t\t\tcontroller.error(error);\n\t\t\t}\n\t\t},\n\t\tcancel() {\n\t\t\tcancelled = true;\n\t\t\tstop();\n\t\t\tvoid iterator.return?.();\n\t\t},\n\t});\n}\n",
11
16
  "/** Every status a route may declare or reply with. */\nexport type StatusCode =\n\t| InformationalStatus\n\t| SuccessStatus\n\t| RedirectStatus\n\t| ClientErrorStatus\n\t| ServerErrorStatus;\n\nexport type InformationalStatus = 100 | 101 | 102 | 103;\nexport type SuccessStatus =\n\t| 200\n\t| 201\n\t| 202\n\t| 203\n\t| 204\n\t| 205\n\t| 206\n\t| 207\n\t| 208\n\t| 226;\nexport type RedirectStatus = 300 | 301 | 302 | 303 | 304 | 307 | 308;\nexport type ClientErrorStatus =\n\t| 400\n\t| 401\n\t| 402\n\t| 403\n\t| 404\n\t| 405\n\t| 406\n\t| 407\n\t| 408\n\t| 409\n\t| 410\n\t| 411\n\t| 412\n\t| 413\n\t| 414\n\t| 415\n\t| 416\n\t| 417\n\t| 418\n\t| 421\n\t| 422\n\t| 423\n\t| 424\n\t| 425\n\t| 426\n\t| 428\n\t| 429\n\t| 431\n\t| 451;\nexport type ServerErrorStatus =\n\t| 500\n\t| 501\n\t| 502\n\t| 503\n\t| 504\n\t| 505\n\t| 506\n\t| 507\n\t| 508\n\t| 510\n\t| 511;\n\n/** Statuses whose response never carries a body. */\nexport const BODILESS = new Set<number>([101, 204, 205, 304]);\n",
12
- "import { isAsyncIterable, toEventStream } from '../sse/event-stream';\nimport { BODILESS, type StatusCode } from '../types/status';\n\nexport interface ReplyInit {\n\t/**\n\t * Headers added to this reply, over those set on `ctx.set.headers` —\n\t * except `Vary`, whose names are added to theirs.\n\t */\n\treadonly headers?: HeadersInit;\n}\n\n/**\n * What a handler returns: a status and the body sent with it. Its type is the\n * route's contract — the client reads the union of every `Reply` a handler\n * may return.\n *\n * Built by `ctx.reply(status, body)`, which checks the body against the\n * schema the route declares for that status.\n */\nexport class Reply<Status extends number = number, Body = unknown> {\n\t/**\n\t * Never set: makes a `Reply` nominal. Without it a `Response` — a\n\t * `status`, a `body`, `headers` — would pass for one, and a hook that\n\t * returns either would type its `Response` as a reply.\n\t */\n\tdeclare readonly '~reply': true;\n\treadonly status: Status;\n\treadonly body: Body;\n\treadonly headers: HeadersInit | undefined;\n\n\tconstructor(status: Status, body: Body, init?: ReplyInit) {\n\t\tthis.status = status;\n\t\tthis.body = body;\n\t\tthis.headers = init?.headers;\n\t}\n}\n\n/** Any reply, whatever its status and body. */\nexport type AnyReply = Reply<any, any>;\n\n/**\n * The statuses `reply` has a shortcut for: `reply.ok(body)` is\n * `reply(200, body)`. `noContent` takes no body.\n */\nexport const SHORTCUTS = {\n\tok: 200,\n\tcreated: 201,\n\taccepted: 202,\n\tnoContent: 204,\n\tbadRequest: 400,\n\tunauthorized: 401,\n\tforbidden: 403,\n\tnotFound: 404,\n\tconflict: 409,\n} as const;\n\n/** The status a shortcut answers: `Shortcuts['notFound']` is `404`. */\nexport type Shortcuts = typeof SHORTCUTS;\n\n/** The shortcuts of `reply` without schemas: any body, its type kept. */\nexport type FreeShortcuts = {\n\treadonly [Name in keyof Shortcuts]: Name extends 'noContent'\n\t\t? (init?: ReplyInit) => Reply<204, undefined>\n\t\t: <const Body = undefined>(\n\t\t\t\tbody?: Body,\n\t\t\t\tinit?: ReplyInit,\n\t\t\t) => Reply<Shortcuts[Name], Body>;\n} & {\n\t/** An HTML page: the body sent as `text/html;charset=utf-8`. */\n\treadonly html: <const Status extends StatusCode>(\n\t\tstatus: Status,\n\t\thtml: string,\n\t\tinit?: ReplyInit,\n\t) => Reply<Status, string>;\n};\n\n/**\n * `reply` without schemas: any status, any body. The body's type is kept, so\n * the client still reads it. Its shortcuts — `reply.ok(body)`,\n * `reply.notFound(body)`, `reply.noContent()` — are the same replies.\n */\nexport type FreeReplyFunction = (<\n\tconst Status extends StatusCode,\n\tconst Body = undefined,\n>(\n\tstatus: Status,\n\tbody?: Body,\n\tinit?: ReplyInit,\n) => Reply<Status, Body>) &\n\tFreeShortcuts;\n\n/** `init`'s headers, with `content-type` set unless they set one. */\nfunction withContentType(type: string, init?: ReplyInit): ReplyInit {\n\tconst headers = new Headers(init?.headers);\n\tif (!headers.has('content-type')) headers.set('content-type', type);\n\treturn { ...init, headers };\n}\n\n/** A shortcut: `reply(status, body, init)` with its status fixed. */\nconst shortcut =\n\t<const Status extends StatusCode>(status: Status) =>\n\t<const Body = undefined>(body?: Body, init?: ReplyInit) =>\n\t\tnew Reply(status, body as Body, init);\n\nconst shortcuts = {\n\tok: shortcut(SHORTCUTS.ok),\n\tcreated: shortcut(SHORTCUTS.created),\n\taccepted: shortcut(SHORTCUTS.accepted),\n\tnoContent: (init?: ReplyInit) =>\n\t\tnew Reply(SHORTCUTS.noContent, undefined, init),\n\tbadRequest: shortcut(SHORTCUTS.badRequest),\n\tunauthorized: shortcut(SHORTCUTS.unauthorized),\n\tforbidden: shortcut(SHORTCUTS.forbidden),\n\tnotFound: shortcut(SHORTCUTS.notFound),\n\tconflict: shortcut(SHORTCUTS.conflict),\n\thtml: <const Status extends StatusCode>(\n\t\tstatus: Status,\n\t\thtml: string,\n\t\tinit?: ReplyInit,\n\t) =>\n\t\tnew Reply(status, html, withContentType('text/html;charset=utf-8', init)),\n} satisfies FreeShortcuts;\n\nexport const createReply: FreeReplyFunction = Object.assign(\n\t<const Status extends StatusCode, const Body = undefined>(\n\t\tstatus: Status,\n\t\tbody?: Body,\n\t\tinit?: ReplyInit,\n\t) => new Reply(status, body as Body, init),\n\tshortcuts,\n);\n\nconst BINARY = (value: unknown): value is BodyInit =>\n\tvalue instanceof Blob ||\n\tvalue instanceof ReadableStream ||\n\tvalue instanceof ArrayBuffer ||\n\tArrayBuffer.isView(value) ||\n\tvalue instanceof FormData ||\n\tvalue instanceof URLSearchParams;\n\n/**\n * The `Response` a reply is sent as. A string is `text/plain`, a binary body\n * goes as it is, an async iterable is a stream of server-sent events, and\n * anything else is JSON. A body-less status sends none.\n */\nexport function toResponse(\n\tstatus: number,\n\tbody: unknown,\n\theaders: Headers,\n\tsignal?: AbortSignal,\n): Response {\n\tif (BODILESS.has(status) || body === undefined) {\n\t\treturn new Response(null, { status, headers });\n\t}\n\tif (typeof body === 'string') {\n\t\tif (!headers.has('content-type'))\n\t\t\theaders.set('content-type', 'text/plain;charset=utf-8');\n\t\theaders.set('content-length', String(Buffer.byteLength(body)));\n\t\treturn new Response(body, { status, headers });\n\t}\n\tif (BINARY(body)) {\n\t\t// Known up front, so `onResponse` (compress's threshold) can read it.\n\t\tconst length =\n\t\t\tbody instanceof Blob\n\t\t\t\t? body.size\n\t\t\t\t: body instanceof ArrayBuffer || ArrayBuffer.isView(body)\n\t\t\t\t\t? body.byteLength\n\t\t\t\t\t: undefined;\n\t\tif (length !== undefined && !headers.has('content-length'))\n\t\t\theaders.set('content-length', String(length));\n\t\treturn new Response(body, { status, headers });\n\t}\n\tif (isAsyncIterable(body)) {\n\t\theaders.set('content-type', 'text/event-stream');\n\t\theaders.set('cache-control', 'no-cache');\n\t\theaders.set('x-accel-buffering', 'no');\n\t\treturn new Response(toEventStream(body, signal), { status, headers });\n\t}\n\tif (!headers.has('content-type'))\n\t\theaders.set('content-type', 'application/json');\n\tconst json = JSON.stringify(body);\n\theaders.set('content-length', String(Buffer.byteLength(json)));\n\treturn new Response(json, { status, headers });\n}\n",
17
+ "import { isAsyncIterable } from '../sse/async-iterable';\nimport { toEventStream } from '../sse/event-stream';\nimport { BODILESS, type StatusCode } from '../types/status';\n\nexport interface ReplyInit {\n\t/**\n\t * Headers added to this reply, over those set on `ctx.set.headers` —\n\t * except `Vary`, whose names are added to theirs.\n\t */\n\treadonly headers?: HeadersInit;\n}\n\n/**\n * What a handler returns: a status and the body sent with it. Its type is the\n * route's contract — the client reads the union of every `Reply` a handler\n * may return.\n *\n * Built by `ctx.reply(status, body)`, which checks the body against the\n * schema the route declares for that status.\n */\nexport class Reply<Status extends number = number, Body = unknown> {\n\t/**\n\t * Never set: makes a `Reply` nominal. Without it a `Response` — a\n\t * `status`, a `body`, `headers` — would pass for one, and a hook that\n\t * returns either would type its `Response` as a reply.\n\t */\n\tdeclare readonly '~reply': true;\n\treadonly status: Status;\n\treadonly body: Body;\n\treadonly headers: HeadersInit | undefined;\n\n\tconstructor(status: Status, body: Body, init?: ReplyInit) {\n\t\tthis.status = status;\n\t\tthis.body = body;\n\t\tthis.headers = init?.headers;\n\t}\n}\n\n/** Any reply, whatever its status and body. */\nexport type AnyReply = Reply<any, any>;\n\n/**\n * The statuses `reply` has a shortcut for: `reply.ok(body)` is\n * `reply(200, body)`. `noContent` takes no body.\n */\nexport const SHORTCUTS = {\n\tok: 200,\n\tcreated: 201,\n\taccepted: 202,\n\tnoContent: 204,\n\tbadRequest: 400,\n\tunauthorized: 401,\n\tforbidden: 403,\n\tnotFound: 404,\n\tconflict: 409,\n} as const;\n\n/** The status a shortcut answers: `Shortcuts['notFound']` is `404`. */\nexport type Shortcuts = typeof SHORTCUTS;\n\n/** The shortcuts of `reply` without schemas: any body, its type kept. */\nexport type FreeShortcuts = {\n\treadonly [Name in keyof Shortcuts]: Name extends 'noContent'\n\t\t? (init?: ReplyInit) => Reply<204, undefined>\n\t\t: <const Body = undefined>(\n\t\t\t\tbody?: Body,\n\t\t\t\tinit?: ReplyInit,\n\t\t\t) => Reply<Shortcuts[Name], Body>;\n} & {\n\t/** An HTML page: the body sent as `text/html;charset=utf-8`. */\n\treadonly html: <const Status extends StatusCode>(\n\t\tstatus: Status,\n\t\thtml: string,\n\t\tinit?: ReplyInit,\n\t) => Reply<Status, string>;\n};\n\n/**\n * `reply` without schemas: any status, any body. The body's type is kept, so\n * the client still reads it. Its shortcuts — `reply.ok(body)`,\n * `reply.notFound(body)`, `reply.noContent()` — are the same replies.\n */\nexport type FreeReplyFunction = (<\n\tconst Status extends StatusCode,\n\tconst Body = undefined,\n>(\n\tstatus: Status,\n\tbody?: Body,\n\tinit?: ReplyInit,\n) => Reply<Status, Body>) &\n\tFreeShortcuts;\n\n/** `init`'s headers, with `content-type` set unless they set one. */\nfunction withContentType(type: string, init?: ReplyInit): ReplyInit {\n\tconst headers = new Headers(init?.headers);\n\tif (!headers.has('content-type')) headers.set('content-type', type);\n\treturn { ...init, headers };\n}\n\n/** A shortcut: `reply(status, body, init)` with its status fixed. */\nconst shortcut =\n\t<const Status extends StatusCode>(status: Status) =>\n\t<const Body = undefined>(body?: Body, init?: ReplyInit) =>\n\t\tnew Reply(status, body as Body, init);\n\nconst shortcuts = {\n\tok: shortcut(SHORTCUTS.ok),\n\tcreated: shortcut(SHORTCUTS.created),\n\taccepted: shortcut(SHORTCUTS.accepted),\n\tnoContent: (init?: ReplyInit) =>\n\t\tnew Reply(SHORTCUTS.noContent, undefined, init),\n\tbadRequest: shortcut(SHORTCUTS.badRequest),\n\tunauthorized: shortcut(SHORTCUTS.unauthorized),\n\tforbidden: shortcut(SHORTCUTS.forbidden),\n\tnotFound: shortcut(SHORTCUTS.notFound),\n\tconflict: shortcut(SHORTCUTS.conflict),\n\thtml: <const Status extends StatusCode>(\n\t\tstatus: Status,\n\t\thtml: string,\n\t\tinit?: ReplyInit,\n\t) =>\n\t\tnew Reply(status, html, withContentType('text/html;charset=utf-8', init)),\n} satisfies FreeShortcuts;\n\nexport const createReply: FreeReplyFunction = Object.assign(\n\t<const Status extends StatusCode, const Body = undefined>(\n\t\tstatus: Status,\n\t\tbody?: Body,\n\t\tinit?: ReplyInit,\n\t) => new Reply(status, body as Body, init),\n\tshortcuts,\n);\n\nconst BINARY = (value: unknown): value is BodyInit =>\n\tvalue instanceof Blob ||\n\tvalue instanceof ReadableStream ||\n\tvalue instanceof ArrayBuffer ||\n\tArrayBuffer.isView(value) ||\n\tvalue instanceof FormData ||\n\tvalue instanceof URLSearchParams;\n\n/**\n * The `Response` a reply is sent as. A string is `text/plain`, a binary body\n * goes as it is, an async iterable is a stream of server-sent events, and\n * anything else is JSON. A body-less status sends none.\n */\nexport function toResponse(\n\tstatus: number,\n\tbody: unknown,\n\theaders: Headers,\n\tsignal?: AbortSignal,\n): Response {\n\tif (BODILESS.has(status) || body === undefined) {\n\t\treturn new Response(null, { status, headers });\n\t}\n\tif (typeof body === 'string') {\n\t\tif (!headers.has('content-type'))\n\t\t\theaders.set('content-type', 'text/plain;charset=utf-8');\n\t\theaders.set('content-length', String(Buffer.byteLength(body)));\n\t\treturn new Response(body, { status, headers });\n\t}\n\tif (BINARY(body)) {\n\t\t// Known up front, so `onResponse` (compress's threshold) can read it.\n\t\tconst length =\n\t\t\tbody instanceof Blob\n\t\t\t\t? body.size\n\t\t\t\t: body instanceof ArrayBuffer || ArrayBuffer.isView(body)\n\t\t\t\t\t? body.byteLength\n\t\t\t\t\t: undefined;\n\t\tif (length !== undefined && !headers.has('content-length'))\n\t\t\theaders.set('content-length', String(length));\n\t\treturn new Response(body, { status, headers });\n\t}\n\tif (isAsyncIterable(body)) {\n\t\theaders.set('content-type', 'text/event-stream');\n\t\theaders.set('cache-control', 'no-cache');\n\t\theaders.set('x-accel-buffering', 'no');\n\t\treturn new Response(toEventStream(body, signal), { status, headers });\n\t}\n\tif (!headers.has('content-type'))\n\t\theaders.set('content-type', 'application/json');\n\tconst json = JSON.stringify(body);\n\theaders.set('content-length', String(Buffer.byteLength(json)));\n\treturn new Response(json, { status, headers });\n}\n",
13
18
  "/**\n * How a static file becomes a reply: a precompressed copy chosen by\n * `Accept-Encoding`, its headers, and a 304, a 206 or a 416 when the\n * request's conditions and range ask for one.\n */\nimport { extname } from 'node:path';\nimport type { BaseContext } from '../app/types';\nimport { vary } from '../reply/headers';\nimport { type AnyReply, Reply } from '../reply/reply';\nimport { fresh, ifRange, parseRange } from './conditional';\nimport type {\n\tFileOptions,\n\tPrecompressed,\n\tRangeNotSatisfiableBody,\n} from './types';\n\n/** A file found, and the path it was found at. */\nexport interface Found {\n\treadonly file: Blob;\n\t/** The path it was found at, relative to the source: what options are asked by. */\n\treadonly path: string;\n}\n\nconst unsatisfiable: RangeNotSatisfiableBody = {\n\terror: 'range_not_satisfiable',\n};\n\nexport async function precompressed(\n\tfound: Found,\n\tcodings: readonly Precompressed[],\n\tctx: BaseContext,\n\tfind: (path: string, ctx: BaseContext) => Promise<Blob | undefined>,\n): Promise<\n\t{ readonly file: Blob; readonly coding: Precompressed } | undefined\n> {\n\tif (codings.length === 0) return undefined;\n\tconst accept = ctx.request.headers.get('accept-encoding') ?? '';\n\tfor (const coding of codings) {\n\t\tif (\n\t\t\t!new RegExp(`(^|[\\\\s,])${coding}(?!;q=0(\\\\.0*)?(\\\\s|,|$))`).test(accept)\n\t\t)\n\t\t\tcontinue;\n\t\tconst extension =\n\t\t\tcoding === 'gzip' ? 'gz' : coding === 'zstd' ? 'zst' : 'br';\n\t\tconst file = await find(`${found.path}.${extension}`, ctx);\n\t\tif (file !== undefined) return { file, coding };\n\t}\n\treturn undefined;\n}\n\nexport function send(\n\tctx: BaseContext,\n\tfound: Found,\n\toptions: FileOptions,\n\tencoded: { readonly file: Blob; readonly coding: Precompressed } | undefined,\n\t/** Whether a coded copy may be chosen by Accept-Encoding: then even the plain file varies by it. */\n\tnegotiated: boolean,\n): AnyReply {\n\tconst { request } = ctx;\n\tconst served = encoded?.file ?? found.file;\n\tconst headers = new Headers();\n\n\tconst type =\n\t\toptions.types?.[extname(found.path).toLowerCase()] ?? found.file.type;\n\tif (type) headers.set('content-type', type);\n\tif (encoded !== undefined) headers.set('content-encoding', encoded.coding);\n\t// A coding chosen by Accept-Encoding varies by it, and so does the plain\n\t// file a client that accepts none gets: a cache must not hand it to one\n\t// that does.\n\tif (negotiated) vary(headers, 'Accept-Encoding');\n\n\tconst cacheControl =\n\t\ttypeof options.cacheControl === 'function'\n\t\t\t? options.cacheControl(found.path)\n\t\t\t: (options.cacheControl ?? 'public, max-age=0');\n\tif (cacheControl !== false) headers.set('cache-control', cacheControl);\n\n\tconst modified =\n\t\t'lastModified' in served ? (served as File).lastModified : undefined;\n\tconst etag =\n\t\toptions.etag !== false && modified !== undefined\n\t\t\t? `W/\"${served.size.toString(16)}-${Math.floor(modified).toString(16)}${encoded ? `-${encoded.coding}` : ''}\"`\n\t\t\t: undefined;\n\tif (etag !== undefined) headers.set('etag', etag);\n\tif (options.lastModified !== false && modified !== undefined) {\n\t\theaders.set('last-modified', new Date(modified).toUTCString());\n\t}\n\tconst ranges = options.ranges !== false && encoded === undefined;\n\tif (ranges) headers.set('accept-ranges', 'bytes');\n\n\taddCustom(\n\t\theaders,\n\t\ttypeof options.headers === 'function'\n\t\t\t? options.headers(found.path, found.file)\n\t\t\t: options.headers,\n\t);\n\n\tif (fresh(request.headers, etag, modified))\n\t\treturn new Reply(304, undefined, { headers });\n\n\tconst range = request.headers.get('range');\n\tif (\n\t\tranges &&\n\t\trange !== null &&\n\t\tifRange(request.headers.get('if-range'), etag, modified)\n\t) {\n\t\tconst parsed = parseRange(range, served.size);\n\t\tif (parsed === 'unsatisfiable') {\n\t\t\theaders.set('content-range', `bytes */${served.size}`);\n\t\t\treturn new Reply(416, unsatisfiable, { headers });\n\t\t}\n\t\tif (parsed !== undefined) {\n\t\t\theaders.set(\n\t\t\t\t'content-range',\n\t\t\t\t`bytes ${parsed.start}-${parsed.end}/${served.size}`,\n\t\t\t);\n\t\t\treturn new Reply(206, served.slice(parsed.start, parsed.end + 1, type), {\n\t\t\t\theaders,\n\t\t\t});\n\t\t}\n\t}\n\treturn new Reply(200, served, { headers });\n}\n\n/** The `headers` option over the file's own: a cookie is appended, a `Vary` merged. */\nfunction addCustom(headers: Headers, custom: HeadersInit | undefined): void {\n\tif (custom === undefined) return;\n\tfor (const [name, value] of new Headers(custom)) {\n\t\tif (name === 'set-cookie') headers.append(name, value);\n\t\t// What the file varies by — Accept-Encoding with precompressed\n\t\t// copies — stays, whatever else the option adds.\n\t\telse if (name === 'vary') {\n\t\t\tfor (const each of value.split(',')) vary(headers, each);\n\t\t} else headers.set(name, value);\n\t}\n}\n",
14
19
  "/**\n * `response` with its headers edited. A response's headers may be\n * immutable — one from `fetch`, a `Response.redirect` — and then the edit\n * runs on a copy of them, and the response is rebuilt only once it\n * succeeds. An error of `edit` is thrown as it is, the body unread:\n * headers it set before throwing stay, but the caller can still send the\n * response.\n */\nexport function withHeaders(\n\tresponse: Response,\n\tedit: (headers: Headers) => void,\n): Response {\n\ttry {\n\t\tedit(response.headers);\n\t\treturn response;\n\t} catch (error) {\n\t\tif (!immutable(response.headers)) throw error;\n\t\tconst headers = new Headers(response.headers);\n\t\tedit(headers);\n\t\treturn new Response(response.body, {\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t\theaders,\n\t\t});\n\t}\n}\n\n/** Whether `headers` refuse every edit; deleting an absent name changes nothing. */\nfunction immutable(headers: Headers): boolean {\n\ttry {\n\t\theaders.delete('x-alxia-immutable');\n\t\treturn false;\n\t} catch {\n\t\treturn true;\n\t}\n}\n\n/** Adds `value` to the `Vary` header, once; `*` replaces every name. */\nexport function vary(headers: Headers, value: string): void {\n\tconst name = value.trim();\n\tif (name === '') return;\n\tconst current = headers.get('vary');\n\tif (current === null || name === '*') {\n\t\theaders.set('vary', name);\n\t\treturn;\n\t}\n\tconst names = current.split(',').map((name) => name.trim().toLowerCase());\n\tif (!names.includes('*') && !names.includes(name.toLowerCase())) {\n\t\theaders.set('vary', `${current}, ${name}`);\n\t}\n}\n",
15
20
  "/**\n * The conditional and range requests of a static file: whether the client's\n * copy is current, whether a range applies to it, and the range asked for.\n */\n\n/** Whether the client's copy is current: `If-None-Match` first, `If-Modified-Since` without it. */\nexport function fresh(\n\theaders: Headers,\n\tetag: string | undefined,\n\tmodified: number | undefined,\n): boolean {\n\tconst match = headers.get('if-none-match');\n\tif (match !== null) {\n\t\tif (etag === undefined) return false;\n\t\tconst weak = (tag: string) => tag.trim().replace(/^W\\//, '');\n\t\treturn match\n\t\t\t.split(',')\n\t\t\t.some((tag) => tag.trim() === '*' || weak(tag) === weak(etag));\n\t}\n\tconst since = headers.get('if-modified-since');\n\tif (since === null || modified === undefined) return false;\n\tconst time = Date.parse(since);\n\treturn !Number.isNaN(time) && Math.floor(modified / 1000) * 1000 <= time;\n}\n\n/** Whether a range applies: always without `If-Range`, else only to the copy it names. */\nexport function ifRange(\n\tvalue: string | null,\n\tetag: string | undefined,\n\tmodified: number | undefined,\n): boolean {\n\tif (value === null) return true;\n\tif (value.startsWith('\"') || value.startsWith('W/')) {\n\t\t// A weak tag never validates a range.\n\t\treturn etag !== undefined && !etag.startsWith('W/') && value === etag;\n\t}\n\tconst time = Date.parse(value);\n\treturn (\n\t\tmodified !== undefined &&\n\t\t!Number.isNaN(time) &&\n\t\tMath.floor(modified / 1000) * 1000 <= time\n\t);\n}\n\n/**\n * One byte range of `size`: its first and last byte, `unsatisfiable`, or\n * `undefined` — a header this server ignores, several ranges included —\n * which serves the whole file.\n */\nexport function parseRange(\n\theader: string,\n\tsize: number,\n):\n\t| { readonly start: number; readonly end: number }\n\t| 'unsatisfiable'\n\t| undefined {\n\tconst match = /^bytes=(\\d*)-(\\d*)$/.exec(header.trim());\n\tif (match === null) return undefined;\n\tconst [, from = '', to = ''] = match;\n\tif (from === '' && to === '') return undefined;\n\tif (from === '') {\n\t\tconst suffix = Number(to);\n\t\tif (suffix === 0) return 'unsatisfiable';\n\t\treturn { start: Math.max(0, size - suffix), end: size - 1 };\n\t}\n\tconst start = Number(from);\n\tconst end = to === '' ? size - 1 : Math.min(Number(to), size - 1);\n\tif (start >= size || start > end) return 'unsatisfiable';\n\treturn { start, end };\n}\n",
16
- "/** Where a refused value was read from. */\nexport type ValidationTarget =\n\t| 'params'\n\t| 'query'\n\t| 'headers'\n\t| 'cookies'\n\t| 'body'\n\t| 'message';\n\nexport interface ValidationIssue {\n\treadonly target: ValidationTarget;\n\treadonly path: readonly (string | number)[];\n\treadonly code: string;\n\treadonly message: string;\n}\n\n/** The body of the 400 every route that validates its request may answer. */\nexport interface ValidationErrorBody {\n\treadonly error: 'validation';\n\treadonly issues: readonly ValidationIssue[];\n}\n\n/** The body of the 500 any route may answer. Nothing of the error leaks. */\nexport interface InternalErrorBody {\n\treadonly error: 'internal';\n}\n\n/** The body of the 404, 405 and 426 the app answers outside every route. */\nexport interface RoutingErrorBody {\n\treadonly error: 'not_found' | 'method_not_allowed' | 'upgrade_required';\n}\n\n/**\n * An error a handler or a hook throws to answer with `status` and `body`.\n *\n * Prefer returning `reply(status, body)`: a reply is part of the route's\n * type, and the client sees it. A thrown `HttpError` is not, so the client\n * reads it as a status the route never declared.\n */\nexport class HttpError<\n\tStatus extends number = number,\n\tBody = unknown,\n> extends Error {\n\toverride readonly name = 'HttpError';\n\treadonly status: Status;\n\treadonly body: Body;\n\n\tconstructor(status: Status, body: Body, message?: string) {\n\t\tsuper(message ?? `HTTP ${status}`);\n\t\tthis.status = status;\n\t\tthis.body = body;\n\t}\n}\n\n/**\n * A reply that did not match the schema its route declares for its status.\n * It is answered as a 500: the client must never read an undeclared shape.\n */\nexport class ResponseValidationError extends Error {\n\toverride readonly name = 'ResponseValidationError';\n\treadonly status: number;\n\treadonly issues: readonly ValidationIssue[];\n\n\tconstructor(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tstatus: number,\n\t\tissues: readonly ValidationIssue[],\n\t\t/** Set by `undeclared`, for a status the route has no schema for. */\n\t\tmessage?: string,\n\t) {\n\t\tsuper(\n\t\t\tmessage ??\n\t\t\t\t`${method} ${path}: the ${status} reply does not match its schema: ${issues\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join('; ')}`,\n\t\t);\n\t\tthis.status = status;\n\t\tthis.issues = issues;\n\t}\n\n\t/** A reply whose status the route declares no schema for. */\n\tstatic undeclared(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tstatus: number,\n\t): ResponseValidationError {\n\t\treturn new ResponseValidationError(\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\ttarget: 'body',\n\t\t\t\t\tpath: [],\n\t\t\t\t\tcode: 'undeclared_status',\n\t\t\t\t\tmessage: `the route declares no ${status} reply`,\n\t\t\t\t},\n\t\t\t],\n\t\t\t`${method} ${path} declares no ${status} reply`,\n\t\t);\n\t}\n}\n",
17
- "import type { ValidationIssue } from '../errors/errors';\n\n/**\n * The query string as an object. A key given once is a string, a key given\n * more than once an array of them, so `z.array(...)` reads `?tag=a&tag=b`;\n * for a list that may hold one item, accept both (see the README).\n */\nexport function readQuery(url: URL): Record<string, string | string[]> {\n\tconst query: Record<string, string | string[]> = {};\n\tfor (const [key, value] of url.searchParams) {\n\t\tconst seen = query[key];\n\t\tif (seen === undefined) query[key] = value;\n\t\telse if (typeof seen === 'string') query[key] = [seen, value];\n\t\telse seen.push(value);\n\t}\n\treturn query;\n}\n\n/** The request headers as an object, names lowercased. */\nexport function readHeaders(headers: Headers): Record<string, string> {\n\tconst read: Record<string, string> = {};\n\tfor (const [key, value] of headers) read[key] = value;\n\treturn read;\n}\n\n/** The request cookies as an object. */\nexport function readCookies(headers: Headers): Record<string, string> {\n\tconst cookie = headers.get('cookie');\n\tif (cookie === null) return {};\n\treturn Object.fromEntries(new Bun.CookieMap(cookie));\n}\n\n/** A body parser an app adds, tried before the built-in ones. */\nexport interface BodyParser {\n\t/** A `content-type` it reads: a prefix, or a pattern. */\n\treadonly type: string | RegExp;\n\treadonly parse: (request: Request) => unknown;\n}\n\nfunction parserFor(\n\tparsers: readonly BodyParser[],\n\ttype: string,\n): BodyParser | undefined {\n\treturn parsers.find((parser) =>\n\t\ttypeof parser.type === 'string'\n\t\t\t? type.startsWith(parser.type)\n\t\t\t: parser.type.test(type),\n\t);\n}\n\nexport type ReadBody =\n\t| { readonly ok: true; readonly value: unknown }\n\t| { readonly ok: false; readonly issue: ValidationIssue };\n\n/**\n * The request body, read by its `content-type`: by a parser the app added,\n * else JSON, a form (an object of its fields, a field given more than once\n * an array), text, or the bytes.\n */\nexport async function readBody(\n\trequest: Request,\n\tparsers: readonly BodyParser[] = [],\n): Promise<ReadBody> {\n\tconst type = request.headers.get('content-type')?.toLowerCase() ?? '';\n\tconst custom = parserFor(parsers, type);\n\tif (custom !== undefined) {\n\t\ttry {\n\t\t\treturn { ok: true, value: await custom.parse(request) };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tissue: {\n\t\t\t\t\ttarget: 'body',\n\t\t\t\t\tpath: [],\n\t\t\t\t\tcode: 'unreadable_body',\n\t\t\t\t\tmessage:\n\t\t\t\t\t\terror instanceof Error ? error.message : 'The body cannot be read',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\tif (type.includes('json')) {\n\t\tconst text = await request.text();\n\t\tif (text === '') return { ok: true, value: undefined };\n\t\ttry {\n\t\t\treturn { ok: true, value: JSON.parse(text) };\n\t\t} catch {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tissue: {\n\t\t\t\t\ttarget: 'body',\n\t\t\t\t\tpath: [],\n\t\t\t\t\tcode: 'invalid_json',\n\t\t\t\t\tmessage: 'The body is not valid JSON',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\tif (\n\t\ttype.startsWith('multipart/form-data') ||\n\t\ttype.startsWith('application/x-www-form-urlencoded')\n\t) {\n\t\tconst form = await request.formData();\n\t\tconst value: Record<string, FormDataEntryValue | FormDataEntryValue[]> = {};\n\t\tfor (const [key, entry] of form) {\n\t\t\tconst seen = value[key];\n\t\t\tif (seen === undefined) value[key] = entry;\n\t\t\telse if (Array.isArray(seen)) seen.push(entry);\n\t\t\telse value[key] = [seen, entry];\n\t\t}\n\t\treturn { ok: true, value };\n\t}\n\tif (type.startsWith('text/'))\n\t\treturn { ok: true, value: await request.text() };\n\tif (request.body === null) return { ok: true, value: undefined };\n\treturn { ok: true, value: await request.arrayBuffer() };\n}\n",
18
- "/**\n * How a reply becomes a response: the headers and cookies the route set\n * merged with the reply's own, the body checked by the schema the route\n * declares for its status, and the answers the router gives on its own.\n */\nimport {\n\ttype InternalErrorBody,\n\tResponseValidationError,\n\ttype RoutingErrorBody,\n} from '../errors/errors';\nimport { vary } from '../reply/headers';\nimport { type AnyReply, Reply, toResponse } from '../reply/reply';\nimport { check } from '../schema/standard-schema';\nimport type { RouteDefinition } from './definition';\nimport type { ResponseSettings } from './types';\n\nconst internal: InternalErrorBody = { error: 'internal' };\n\n/** The 500 of a request that failed: its body says no more than `internal`. */\nexport function internalError(): Response {\n\treturn toResponse(500, internal, new Headers());\n}\n\n/** A reply as it is, with what the route set on its response. */\nexport function send(\n\treply: AnyReply,\n\tset: ResponseSettings,\n\tsignal?: AbortSignal,\n): Response {\n\tconst headers = new Headers(set.headers);\n\tif (reply.headers !== undefined) {\n\t\tfor (const [key, value] of new Headers(reply.headers)) {\n\t\t\t// A reply's Vary adds to the plugins': each said what it read.\n\t\t\tif (key === 'vary') {\n\t\t\t\tfor (const name of value.split(',')) vary(headers, name);\n\t\t\t} else if (key === 'set-cookie') {\n\t\t\t\t// Each cookie is its own header: setting would keep the last.\n\t\t\t\theaders.append(key, value);\n\t\t\t} else headers.set(key, value);\n\t\t}\n\t}\n\tif ((set as { touched?: () => boolean }).touched?.()) {\n\t\tfor (const cookie of set.cookies.toSetCookieHeaders()) {\n\t\t\theaders.append('set-cookie', cookie);\n\t\t}\n\t}\n\treturn toResponse(reply.status, reply.body, headers, signal);\n}\n\n/**\n * A handler's reply, checked against the schema its route declares for its\n * status and sent as that schema's output. A status the route does not\n * declare, or a body its schema refuses, throws a `ResponseValidationError`.\n */\nexport async function sendDeclared(\n\troute: RouteDefinition,\n\treply: AnyReply,\n\tset: ResponseSettings,\n\tsignal: AbortSignal,\n\tvalidateResponses: boolean,\n): Promise<Response> {\n\tconst responses = route.schema.response;\n\tif (responses === undefined || isRedirect(reply)) {\n\t\treturn send(reply, set, signal);\n\t}\n\tconst schema = responses[reply.status as keyof typeof responses];\n\tif (schema === undefined) {\n\t\tthrow ResponseValidationError.undeclared(\n\t\t\troute.method,\n\t\t\troute.path,\n\t\t\treply.status,\n\t\t);\n\t}\n\tif (!validateResponses) return send(reply, set, signal);\n\tconst checked = await check(schema, reply.body, 'body');\n\tif (!checked.ok) {\n\t\tthrow new ResponseValidationError(\n\t\t\troute.method,\n\t\t\troute.path,\n\t\t\treply.status,\n\t\t\tchecked.issues,\n\t\t);\n\t}\n\treturn send(\n\t\tnew Reply(reply.status, checked.value, { headers: reply.headers ?? {} }),\n\t\tset,\n\t\tsignal,\n\t);\n}\n\n/** What the router answers when no route takes the request. */\nexport function routingError(\n\tstatus: 404 | 405 | 426,\n\terror: RoutingErrorBody['error'],\n\tallowed?: readonly string[],\n): Response {\n\tconst headers = new Headers();\n\tif (allowed !== undefined) headers.set('allow', allowed.join(', '));\n\tconst body: RoutingErrorBody = { error };\n\treturn toResponse(status, body, headers);\n}\n\nfunction isRedirect(reply: AnyReply): boolean {\n\treturn reply.status >= 300 && reply.status < 400 && reply.body === undefined;\n}\n",
19
- "/**\n * A route's own run, once the router has found it: its context, its hooks\n * in the order declared, the request validated, the handler, and the\n * `onError` hooks when any of it throws.\n */\nimport {\n\tHttpError,\n\ttype ValidationErrorBody,\n\ttype ValidationIssue,\n} from '../errors/errors';\nimport { createReply, Reply } from '../reply/reply';\nimport {\n\ttype BodyParser,\n\treadBody,\n\treadCookies,\n\treadHeaders,\n\treadQuery,\n} from '../request/read';\nimport { check } from '../schema/standard-schema';\nimport type { RedirectStatus } from '../types/status';\nimport type { RouteDefinition, SocketDefinition } from './definition';\nimport { internalError, send, sendDeclared } from './send';\nimport type {\n\tBaseContext,\n\tRedirectFunction,\n\tRequestContext,\n\tResponseSettings,\n} from './types';\n\nconst redirect: RedirectFunction = (location, status) =>\n\tnew Reply(status ?? (302 as RedirectStatus), undefined, {\n\t\theaders: { location: String(location) },\n\t}) as never;\n\n/** The context a route's hooks and handler read, and what they set on its response. */\nexport function routeContext(\n\tdefinition: RouteDefinition | SocketDefinition,\n\trequest: RequestContext,\n\tpathParams: Record<string, string>,\n): { ctx: Record<string, unknown> & BaseContext; set: ResponseSettings } {\n\tlet cookies: Bun.CookieMap | undefined;\n\tconst set: ResponseSettings & { readonly touched: () => boolean } = {\n\t\theaders: new Headers(),\n\t\tget cookies() {\n\t\t\tcookies ??= new Bun.CookieMap();\n\t\t\treturn cookies;\n\t\t},\n\t\ttouched: () => cookies !== undefined,\n\t};\n\tconst ctx: Record<string, unknown> & BaseContext = {\n\t\t...request,\n\t\troute: definition.path,\n\t\tpathParams,\n\t\tset,\n\t\treply: createReply,\n\t\tredirect,\n\t};\n\treturn { ctx, set };\n}\n\n/**\n * Runs the hooks of a route in order — a `derive` adds to the context or\n * ends the request, a `wrap` runs the rest inside it — then validates the\n * request, then `last`. A socket's upgrade skips the `wrap` hooks: it has\n * no response to wrap.\n */\nexport async function chain<Last>(\n\tdefinition: RouteDefinition | SocketDefinition,\n\trequest: RequestContext,\n\trawParams: Record<string, string>,\n\tset: ResponseSettings,\n\tctx: Record<string, unknown> & BaseContext,\n\tparsers: readonly BodyParser[],\n\tlast: () => Promise<Response | Last>,\n): Promise<Response | Last> {\n\tconst hooks = definition.derive;\n\tconst socket = !('method' in definition);\n\tconst signal = request.request.signal;\n\tconst step = async (index: number): Promise<Response | Last> => {\n\t\tconst hook = hooks[index];\n\t\tif (hook === undefined) {\n\t\t\tconst refused = await validate(\n\t\t\t\tdefinition,\n\t\t\t\trequest,\n\t\t\t\trawParams,\n\t\t\t\tset,\n\t\t\t\tctx,\n\t\t\t\tparsers,\n\t\t\t);\n\t\t\treturn refused ?? last();\n\t\t}\n\t\tif (hook.kind === 'wrap') {\n\t\t\tif (socket) return step(index + 1);\n\t\t\tlet wrapped = hook.run(ctx, () => step(index + 1) as Promise<Response>);\n\t\t\tif (wrapped instanceof Promise) wrapped = await wrapped;\n\t\t\treturn wrapped instanceof Reply ? send(wrapped, set, signal) : wrapped;\n\t\t}\n\t\tlet added = hook.run(ctx);\n\t\tif (added instanceof Promise) added = await added;\n\t\tif (added instanceof Reply) return send(added, set, signal);\n\t\tif (added !== null && typeof added === 'object') {\n\t\t\tObject.assign(ctx, added);\n\t\t}\n\t\treturn step(index + 1);\n\t};\n\treturn step(0);\n}\n\n/** The request checked by the route's schemas: the 400 that refuses it, or nothing. */\nasync function validate(\n\tdefinition: RouteDefinition | SocketDefinition,\n\trequest: RequestContext,\n\trawParams: Record<string, string>,\n\tset: ResponseSettings,\n\tctx: Record<string, unknown> & BaseContext,\n\tparsers: readonly BodyParser[],\n): Promise<Response | undefined> {\n\tconst { schema } = definition;\n\tconst issues: ValidationIssue[] = [];\n\tconst parts = [\n\t\t['params', schema.params, () => rawParams],\n\t\t['query', schema.query, () => readQuery(request.url)],\n\t\t['headers', schema.headers, () => readHeaders(request.request.headers)],\n\t\t['cookies', schema.cookies, () => readCookies(request.request.headers)],\n\t] as const;\n\tfor (const [target, partSchema, read] of parts) {\n\t\tconst raw = read();\n\t\tif (partSchema === undefined) {\n\t\t\tctx[target] = raw;\n\t\t\tcontinue;\n\t\t}\n\t\tconst checked = await check(partSchema, raw, target);\n\t\tif (checked.ok) ctx[target] = checked.value;\n\t\telse issues.push(...checked.issues);\n\t}\n\tctx['body'] = undefined;\n\tconst bodySchema = 'body' in schema ? schema.body : undefined;\n\tif (bodySchema !== undefined) {\n\t\tconst body = await readBody(request.request, parsers);\n\t\tif (!body.ok) issues.push(body.issue);\n\t\telse {\n\t\t\tconst checked = await check(bodySchema, body.value, 'body');\n\t\t\tif (checked.ok) ctx['body'] = checked.value;\n\t\t\telse issues.push(...checked.issues);\n\t\t}\n\t}\n\tif (issues.length > 0) {\n\t\tconst body: ValidationErrorBody = { error: 'validation', issues };\n\t\treturn send(new Reply(400, body), set);\n\t}\n\treturn undefined;\n}\n\n/** A route's request, from its hooks to its handler's reply, sent. */\nexport async function handle(\n\troute: RouteDefinition,\n\trequest: RequestContext,\n\trawParams: Record<string, string>,\n\tparsers: readonly BodyParser[],\n\tvalidateResponses: boolean,\n): Promise<Response> {\n\tconst { ctx, set } = routeContext(route, request, rawParams);\n\ttry {\n\t\treturn await chain(\n\t\t\troute,\n\t\t\trequest,\n\t\t\trawParams,\n\t\t\tset,\n\t\t\tctx,\n\t\t\tparsers,\n\t\t\tasync () => {\n\t\t\t\tlet reply = route.handler(ctx as never);\n\t\t\t\tif (reply instanceof Promise) reply = await reply;\n\t\t\t\tif (!(reply instanceof Reply)) {\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`${route.method} ${route.path}: the handler returned no reply. ` +\n\t\t\t\t\t\t\t'Return ctx.reply(status, body).',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn sendDeclared(\n\t\t\t\t\troute,\n\t\t\t\t\treply,\n\t\t\t\t\tset,\n\t\t\t\t\trequest.request.signal,\n\t\t\t\t\tvalidateResponses,\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\t(request as { error: unknown }).error = error;\n\t\treturn fail(route, error, ctx);\n\t}\n}\n\n/**\n * An error a route threw, answered by its `onError` hooks in order; past\n * the last, an `HttpError` as it says and anything else as a 500.\n */\nexport async function fail(\n\tdefinition: RouteDefinition | SocketDefinition,\n\terror: unknown,\n\tctx: BaseContext,\n): Promise<Response> {\n\tfor (const hook of definition.onError) {\n\t\tlet handled = hook(error, ctx);\n\t\tif (handled instanceof Promise) handled = await handled;\n\t\tif (handled instanceof Reply) return send(handled, ctx.set);\n\t}\n\tif (error instanceof HttpError) {\n\t\treturn send(new Reply(error.status, error.body), ctx.set);\n\t}\n\tconsole.error(error);\n\treturn internalError();\n}\n",
20
- "/**\n * A socket route: the upgrade request, run through the route's hooks and\n * validated as a route's, then each message checked by its schema and each\n * one sent checked by its own.\n */\nimport {\n\tResponseValidationError,\n\ttype ValidationErrorBody,\n} from '../errors/errors';\nimport type { BodyParser } from '../request/read';\nimport { check, type StandardSchemaV1 } from '../schema/standard-schema';\nimport type { Socket } from '../ws/types';\nimport { chain, fail, routeContext } from './chain';\nimport type { SocketDefinition } from './definition';\nimport { routingError } from './send';\nimport type { MaybePromise, RequestContext } from './types';\n\n/** What the pipeline returns once a socket is open: Bun wants no response then. */\nexport const UPGRADED = Symbol('upgraded');\n\n/** What Bun keeps on each socket: its route, the context its hooks built, and its `Socket`. */\nexport interface SocketData {\n\treadonly definition: SocketDefinition;\n\treadonly ctx: Record<string, unknown>;\n\tsocket?: Socket<unknown, unknown>;\n}\n\n/** The upgrade request of a socket route: its hooks, its validation, then the upgrade. */\nexport async function upgradeSocket(\n\tdefinition: SocketDefinition,\n\trequest: RequestContext,\n\trawParams: Record<string, string>,\n\tparsers: readonly BodyParser[],\n): Promise<Response | typeof UPGRADED> {\n\tconst { ctx, set } = routeContext(definition, request, rawParams);\n\tconst server = request.server;\n\ttry {\n\t\treturn await chain<typeof UPGRADED>(\n\t\t\tdefinition,\n\t\t\trequest,\n\t\t\trawParams,\n\t\t\tset,\n\t\t\tctx,\n\t\t\tparsers,\n\t\t\tasync () => {\n\t\t\t\tif (server === undefined) {\n\t\t\t\t\treturn routingError(426, 'upgrade_required');\n\t\t\t\t}\n\t\t\t\tconst headers = new Headers(set.headers);\n\t\t\t\tif ((set as { touched?: () => boolean }).touched?.()) {\n\t\t\t\t\tfor (const cookie of set.cookies.toSetCookieHeaders()) {\n\t\t\t\t\t\theaders.append('set-cookie', cookie);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst data: SocketData = { definition, ctx };\n\t\t\t\tconst upgraded = server.upgrade(request.request, { headers, data });\n\t\t\t\treturn upgraded ? UPGRADED : routingError(426, 'upgrade_required');\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\treturn fail(definition, error, ctx);\n\t}\n}\n\n/** The `websocket` handler `Bun.serve` runs every open socket through. */\nexport function websocketHandler(\n\tvalidate: boolean,\n): Bun.WebSocketHandler<SocketData> {\n\tconst socketOf = (ws: Bun.ServerWebSocket<SocketData>) => {\n\t\tws.data.socket ??= createSocket(ws, validate);\n\t\treturn ws.data.socket;\n\t};\n\tconst guard = async (\n\t\tws: Bun.ServerWebSocket<SocketData>,\n\t\trun: () => MaybePromise<void>,\n\t) => {\n\t\ttry {\n\t\t\tawait run();\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t\tws.close(1011, 'internal error');\n\t\t}\n\t};\n\treturn {\n\t\topen: (ws) =>\n\t\t\tguard(ws, () =>\n\t\t\t\tws.data.definition.handlers.open?.(socketOf(ws) as never),\n\t\t\t),\n\t\tmessage: (ws, raw) =>\n\t\t\tguard(ws, async () => {\n\t\t\t\tconst { definition } = ws.data;\n\t\t\t\tconst socket = socketOf(ws);\n\t\t\t\tconst schema = definition.schema.message;\n\t\t\t\tlet message: unknown =\n\t\t\t\t\ttypeof raw === 'string' ? raw : new Uint8Array(raw);\n\t\t\t\tif (schema !== undefined) {\n\t\t\t\t\tconst parsed = parseMessage(message);\n\t\t\t\t\tif (!parsed.ok) {\n\t\t\t\t\t\tws.send(JSON.stringify(parsed.error));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst checked = await check(schema, parsed.value, 'message');\n\t\t\t\t\tif (!checked.ok) {\n\t\t\t\t\t\tconst error: ValidationErrorBody = {\n\t\t\t\t\t\t\terror: 'validation',\n\t\t\t\t\t\t\tissues: checked.issues,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tws.send(JSON.stringify(error));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tmessage = checked.value;\n\t\t\t\t}\n\t\t\t\tawait definition.handlers.message(socket as never, message as never);\n\t\t\t}),\n\t\tclose: (ws, code, reason) =>\n\t\t\tguard(ws, () =>\n\t\t\t\tws.data.definition.handlers.close?.(\n\t\t\t\t\tsocketOf(ws) as never,\n\t\t\t\t\tcode,\n\t\t\t\t\treason,\n\t\t\t\t),\n\t\t\t),\n\t\tdrain: (ws) =>\n\t\t\tguard(ws, () =>\n\t\t\t\tws.data.definition.handlers.drain?.(socketOf(ws) as never),\n\t\t\t),\n\t};\n}\n\nfunction parseMessage(\n\tmessage: unknown,\n):\n\t| { readonly ok: true; readonly value: unknown }\n\t| { readonly ok: false; readonly error: ValidationErrorBody } {\n\tif (typeof message !== 'string') return { ok: true, value: message };\n\ttry {\n\t\treturn { ok: true, value: JSON.parse(message) };\n\t} catch {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: {\n\t\t\t\terror: 'validation',\n\t\t\t\tissues: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttarget: 'message',\n\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\tcode: 'invalid_json',\n\t\t\t\t\t\tmessage: 'The message is not valid JSON',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t};\n\t}\n}\n\nfunction createSocket(\n\tws: Bun.ServerWebSocket<SocketData>,\n\tvalidate: boolean,\n): Socket<unknown, unknown> {\n\tconst schema: StandardSchemaV1 | undefined = ws.data.definition.schema.send;\n\tconst encode = async (message: unknown): Promise<string> => {\n\t\tif (schema === undefined || !validate) return JSON.stringify(message);\n\t\tconst checked = await check(schema, message, 'body');\n\t\tif (!checked.ok) {\n\t\t\tthrow new ResponseValidationError(\n\t\t\t\t'WS',\n\t\t\t\tws.data.definition.path,\n\t\t\t\t101,\n\t\t\t\tchecked.issues,\n\t\t\t);\n\t\t}\n\t\treturn JSON.stringify(checked.value);\n\t};\n\treturn {\n\t\tdata: ws.data.ctx,\n\t\tasync send(message) {\n\t\t\tws.send(await encode(message));\n\t\t},\n\t\tasync publish(topic, message) {\n\t\t\tws.publish(topic, await encode(message));\n\t\t},\n\t\tsubscribe: (topic) => ws.subscribe(topic),\n\t\tunsubscribe: (topic) => ws.unsubscribe(topic),\n\t\tisSubscribed: (topic) => ws.isSubscribed(topic),\n\t\tclose: (code, reason) => ws.close(code, reason),\n\t\traw: ws as Bun.ServerWebSocket<unknown>,\n\t};\n}\n",
21
- "/**\n * The whole of a request: the global hooks around it, routing, then the\n * route's own run or the socket's upgrade.\n */\nimport { handle } from './chain';\nimport type { Definition, Runtime } from './definition';\nimport { internalError, routingError } from './send';\nimport { UPGRADED, upgradeSocket } from './socket';\nimport type { RequestContext } from './types';\n\n/** The whole of a request: global hooks around the route's own pipeline. */\nexport async function serve(\n\truntime: Runtime,\n\trequest: Request,\n\tserver: Bun.Server<unknown> | undefined,\n\tpath: string | undefined,\n): Promise<Response> {\n\tconst url = new URL(request.url);\n\tconst ctx: RequestContext = {\n\t\trequest,\n\t\turl,\n\t\tserver,\n\t\tip: runtime.ip(request, server),\n\t\troute: undefined,\n\t\terror: undefined,\n\t};\n\tconst around = runtime.globals.around;\n\tconst upgrade = request.headers.get('upgrade')?.toLowerCase() === 'websocket';\n\tif (around.length === 0 || upgrade) return pipeline(runtime, ctx, path);\n\tconst run = (index: number): Promise<Response> => {\n\t\tconst hook = around[index];\n\t\tif (hook === undefined) return pipeline(runtime, ctx, path);\n\t\treturn hook(ctx, () => run(index + 1));\n\t};\n\ttry {\n\t\treturn await run(0);\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\treturn internalError();\n\t}\n}\n\n/** The `onRequest` hooks, the route, then the `onResponse` hooks. */\nasync function pipeline(\n\truntime: Runtime,\n\tctx: RequestContext,\n\tpath: string | undefined,\n): Promise<Response> {\n\tlet response: Response | typeof UPGRADED | undefined;\n\ttry {\n\t\tfor (const hook of runtime.globals.onRequest) {\n\t\t\tlet early = hook(ctx);\n\t\t\tif (early instanceof Promise) early = await early;\n\t\t\tif (early instanceof Response) {\n\t\t\t\tresponse = early;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tresponse ??= await route(runtime, ctx, path);\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\tresponse = internalError();\n\t}\n\tif (response === UPGRADED) return undefined as never;\n\tfor (const hook of runtime.globals.onResponse) {\n\t\ttry {\n\t\t\tlet replaced = hook(response, ctx);\n\t\t\tif (replaced instanceof Promise) replaced = await replaced;\n\t\t\tif (replaced instanceof Response) response = replaced;\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n\treturn response;\n}\n\n/**\n * The route the request reached, run: the socket a `websocket` upgrade\n * asks for, a `GET` for a `HEAD` no route takes, or the 404, 405 or 426\n * when none answers.\n */\nasync function route(\n\truntime: Runtime,\n\tctx: RequestContext,\n\tpath: string | undefined,\n): Promise<Response | typeof UPGRADED> {\n\tconst { router, globals } = runtime;\n\tconst { request, url } = ctx;\n\tconst upgrade = request.headers.get('upgrade')?.toLowerCase() === 'websocket';\n\tconst find = (\n\t\tmethod: string,\n\t):\n\t\t| { readonly value: Definition; readonly params: Record<string, string> }\n\t\t| { readonly allowed: readonly string[] }\n\t\t| undefined => {\n\t\tif (path === undefined) {\n\t\t\tconst pages = globals.pages.size === 0 ? undefined : globals.pages.keys();\n\t\t\treturn router.match(method, url.pathname, pages);\n\t\t}\n\t\tconst methods = router.methodsAt(path);\n\t\tif (methods === undefined) return undefined;\n\t\tconst value = methods.get(method);\n\t\tif (value !== undefined) {\n\t\t\treturn { value, params: router.paramsAt(path, url.pathname) };\n\t\t}\n\t\treturn { allowed: [...methods.keys()] };\n\t};\n\n\tif (upgrade) {\n\t\tconst socket = find('WS');\n\t\tif (\n\t\t\tsocket !== undefined &&\n\t\t\t'value' in socket &&\n\t\t\tsocket.value.kind === 'ws'\n\t\t) {\n\t\t\t(ctx as { route: string | undefined }).route = socket.value.path;\n\t\t\treturn upgradeSocket(socket.value, ctx, socket.params, globals.parsers);\n\t\t}\n\t}\n\tlet match = find(request.method);\n\tlet head = false;\n\tif (request.method === 'HEAD' && match !== undefined && 'allowed' in match) {\n\t\tconst get = find('GET');\n\t\tif (get !== undefined && 'value' in get) {\n\t\t\tmatch = get;\n\t\t\thead = true;\n\t\t}\n\t}\n\tif (match === undefined) return routingError(404, 'not_found');\n\tif ('allowed' in match) {\n\t\tconst allowed = match.allowed.filter((method) => method !== 'WS');\n\t\tif (allowed.length === 0) return routingError(426, 'upgrade_required');\n\t\treturn routingError(405, 'method_not_allowed', allowed);\n\t}\n\tconst definition = match.value;\n\t(ctx as { route: string | undefined }).route = definition.path;\n\tif (definition.kind === 'ws') return routingError(426, 'upgrade_required');\n\tconst response = await handle(\n\t\tdefinition,\n\t\tctx,\n\t\tmatch.params,\n\t\tglobals.parsers,\n\t\truntime.validateResponses,\n\t);\n\treturn head\n\t\t? new Response(null, {\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t})\n\t\t: response;\n}\n",
22
- "import type { AnyReply } from '../reply/reply';\nimport type { BodyParser } from '../request/read';\nimport { joinPath, shapeOf } from '../router/paths';\nimport { Router } from '../router/router';\nimport { fileHandler, staticHandler } from '../static/serve';\nimport type {\n\tFileOptions,\n\tFileSource,\n\tStaticOptions,\n\tStaticReply,\n} from '../static/types';\nimport type { JoinPath, RoutePath } from '../types/path';\nimport type {\n\tSocketContext,\n\tSocketEntryOf,\n\tSocketHandlers,\n\tSocketMessage,\n\tSocketSchema,\n\tSocketSend,\n} from '../ws/types';\nimport type {\n\tAroundHook,\n\tChainHook,\n\tDeriveHook,\n\tErrorHook,\n\tRequestHook,\n\tResponseHook,\n\tRouteDefinition,\n\tRuntime,\n\tSocketDefinition,\n\tStartHook,\n\tStopHook,\n\tWrapHook,\n} from './definition';\nimport { serve } from './pipeline';\nimport type { OperationMethod, RouteOperation } from './route-operation';\nimport { type SocketData, websocketHandler } from './socket';\nimport type {\n\tBaseContext,\n\tContext,\n\tEmpty,\n\tHandlerResult,\n\tMaybePromise,\n\tMethod,\n\tOutcome,\n\tOutcomeOf,\n\tProvidedBy,\n\tRouteEntryOf,\n\tRouteRecord,\n\tRouteSchema,\n\tValidSchema,\n} from './types';\n\n/** The route a static directory is served at: its path, then a wildcard. */\ntype StaticPath<Path extends string> = Path extends '/' ? '/*' : `${Path}/*`;\n\nexport interface AlxiaOptions<Prefix extends string> {\n\t/** Prepended to the path of every route declared on this app. */\n\treadonly prefix?: Prefix;\n\t/**\n\t * Whether a reply is checked against the schema its route declares for\n\t * its status, and sent as that schema's output: an unknown key the\n\t * schema strips never leaves the server. On by default; a reply that\n\t * fails is answered with a 500.\n\t */\n\treadonly validateResponses?: boolean;\n\t/**\n\t * Reads the client's address. By default, the address of the connection;\n\t * behind a proxy you trust, read its header instead.\n\t */\n\treadonly ip?: (\n\t\trequest: Request,\n\t\tserver: Bun.Server<unknown> | undefined,\n\t) => string | undefined;\n}\n\nexport interface ListenOptions {\n\treadonly port?: number | string;\n\treadonly hostname?: string;\n\treadonly development?: boolean;\n\treadonly idleTimeout?: number;\n\treadonly maxRequestBodySize?: number;\n\treadonly tls?: Bun.TLSOptions;\n}\n\n/** A route method: `app.get(path, schema, handler)` or `app.get(path, handler)`. */\nexport interface RouteMethod<\n\tM extends Method,\n\tCtx extends object,\n\tRoutes extends object,\n\tPrefix extends string,\n\tShortcuts extends AnyReply,\n> {\n\t<\n\t\tconst Path extends RoutePath,\n\t\tSchema extends RouteSchema,\n\t\tResult extends HandlerResult<Schema>,\n\t>(\n\t\tpath: Path,\n\t\tschema: Schema & ValidSchema<JoinPath<Prefix, Path>, Schema>,\n\t\thandler: (\n\t\t\tctx: Context<Ctx, JoinPath<Prefix, Path>, Schema>,\n\t\t) => MaybePromise<Result>,\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes & RouteEntryOf<M, JoinPath<Prefix, Path>, Schema, Result, Shortcuts>,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\t<const Path extends RoutePath, Result extends AnyReply>(\n\t\tpath: Path,\n\t\thandler: (\n\t\t\tctx: Context<Ctx, JoinPath<Prefix, Path>, Empty>,\n\t\t) => MaybePromise<Result>,\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes & RouteEntryOf<M, JoinPath<Prefix, Path>, Empty, Result, Shortcuts>,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n}\n\n/** The routes of a plugin, under the prefix of the app it is used by. */\ntype Prefixed<Prefix extends string, Routes, Shortcuts> = {\n\treadonly [Path in keyof Routes as Path extends string\n\t\t? JoinPath<Prefix, Path>\n\t\t: never]: {\n\t\treadonly [M in keyof Routes[Path]]: Routes[Path][M] extends RouteRecord<\n\t\t\tinfer Input,\n\t\t\tinfer Output\n\t\t>\n\t\t\t? RouteRecord<Input, Output | OutcomeOf<Shortcuts>>\n\t\t\t: Routes[Path][M];\n\t};\n};\n\n/** Any app, whatever it holds. */\nexport type AnyAlxia = Alxia<any, any, any, any>;\n\n/**\n * A plugin written as a function: it receives the app and returns it, with\n * global hooks added. A plugin that adds to the context or declares routes\n * is an app of its own, given to `use`.\n */\nexport type Plugin = <App extends AnyAlxia>(app: App) => App;\n\n/**\n * An app: its routes, and the hooks they run.\n *\n * Every method returns the app itself, typed with what it added, so declare\n * it in one chain and export its type for the client:\n *\n * ```ts\n * const app = alxia()\n * .get('/users/:id', { params: UserId, response: { 200: User, 404: NotFound } },\n * ({ params, reply }) => { ... });\n * export type App = typeof app;\n * ```\n *\n * A route hook (`derive`, `decorate`, `onError`) applies to the routes\n * declared after it, never before: the order of the chain is the order of\n * the request. A global hook (`onRequest`, `onResponse`, `onStart`,\n * `onStop`, `parser`) applies to the whole app, wherever it is declared.\n */\nexport class Alxia<\n\tCtx extends object = Empty,\n\tRoutes extends object = Empty,\n\tPrefix extends string = '',\n\tShortcuts extends AnyReply = never,\n> {\n\t/** Never set: carries the route table to `typeof app`, which the client reads. */\n\tdeclare readonly '~routes': Routes;\n\t/** Never set: carries what a route declared next reads, for `ContextOf`. */\n\tdeclare readonly '~context': Ctx;\n\n\treadonly #prefix: string;\n\t/** The routes, the global hooks and the options a request is served with. */\n\t#runtime: Runtime;\n\treadonly #routes: RouteDefinition[] = [];\n\treadonly #sockets: SocketDefinition[] = [];\n\t#derive: ChainHook[] = [];\n\t#onError: ErrorHook[] = [];\n\t#server: Bun.Server<unknown> | undefined;\n\t#websocket: Bun.WebSocketHandler<SocketData> | undefined;\n\n\tconstructor(options: AlxiaOptions<Prefix> = {}) {\n\t\tthis.#prefix = options.prefix ?? '';\n\t\tthis.#runtime = {\n\t\t\trouter: new Router(),\n\t\t\tglobals: {\n\t\t\t\taround: [],\n\t\t\t\tonRequest: [],\n\t\t\t\tonResponse: [],\n\t\t\t\tonStart: [],\n\t\t\t\tonStop: [],\n\t\t\t\tparsers: [],\n\t\t\t\tpages: new Map(),\n\t\t\t},\n\t\t\tvalidateResponses: options.validateResponses ?? true,\n\t\t\tip:\n\t\t\t\toptions.ip ??\n\t\t\t\t((request, server) => server?.requestIP(request)?.address ?? undefined),\n\t\t};\n\t\tif (this.#prefix !== '' && !/^\\/.*[^/]$/.test(this.#prefix)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`The prefix \"${this.#prefix}\" must start with \"/\" and not end with one`,\n\t\t\t);\n\t\t}\n\t}\n\n\treadonly get = this.#method('GET') as RouteMethod<\n\t\t'GET',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly post = this.#method('POST') as RouteMethod<\n\t\t'POST',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly put = this.#method('PUT') as RouteMethod<\n\t\t'PUT',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly patch = this.#method('PATCH') as RouteMethod<\n\t\t'PATCH',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly delete = this.#method('DELETE') as RouteMethod<\n\t\t'DELETE',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly options = this.#method('OPTIONS') as RouteMethod<\n\t\t'OPTIONS',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly head = this.#method('HEAD') as RouteMethod<\n\t\t'HEAD',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\t/**\n\t * A route declared as data — `{ method, path, schema? }`, as an OpenAPI\n\t * code generator writes it — and its handler: the same route as\n\t * `app[method](path, schema, handler)`.\n\t */\n\treadonly route: OperationMethod<Ctx, Routes, Prefix, Shortcuts> = ((\n\t\toperation: RouteOperation,\n\t\thandler: RouteDefinition['handler'],\n\t) =>\n\t\tthis.#method(operation.method)(\n\t\t\toperation.path,\n\t\t\toperation.schema ?? {},\n\t\t\thandler,\n\t\t)) as never;\n\n\t/**\n\t * A `QUERY` route: a safe, idempotent read whose criteria travel in the\n\t * body, validated like a `POST`'s.\n\t */\n\treadonly query = this.#method('QUERY') as RouteMethod<\n\t\t'QUERY',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\n\t/**\n\t * A directory of files — or any `FileSource` — served under `path`: a\n\t * `GET` route at `path/*`, typed and documented like any other, every\n\t * hook around it.\n\t *\n\t * ```ts\n\t * app.static('/assets', './public', {\n\t * cacheControl: (path) => /\\.[0-9a-f]{8}\\./.test(path) ? 'public, max-age=31536000, immutable' : 'no-cache',\n\t * precompressed: ['br', 'gzip'],\n\t * });\n\t * app.static('/', './dist', { fallback: 'index.html' }); // a single-page app\n\t * ```\n\t *\n\t * A path that leaves the source, a dotfile, or no file is a 404. ETags\n\t * and `Last-Modified` answer 304s; a `Range` a 206.\n\t */\n\tstatic<const Path extends RoutePath>(\n\t\tpath: Path,\n\t\tsource: FileSource,\n\t\toptions: StaticOptions = {},\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes &\n\t\t\tRouteEntryOf<\n\t\t\t\t'GET',\n\t\t\t\tJoinPath<Prefix, StaticPath<Path>>,\n\t\t\t\tEmpty,\n\t\t\t\tStaticReply,\n\t\t\t\tShortcuts\n\t\t\t>,\n\t\tPrefix,\n\t\tShortcuts\n\t> {\n\t\tconst route = (path as string) === '/' ? '/*' : `${path}/*`;\n\t\t(this.get as unknown as (path: string, handler: unknown) => unknown)(\n\t\t\troute,\n\t\t\tstaticHandler(source, options),\n\t\t);\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * One file at `path`: a path on disk, read anew on each request, a `Blob`,\n\t * or a function answering one — `null` a 404. `/favicon.ico`,\n\t * `/robots.txt`, a generated sitemap.\n\t */\n\tfile<const Path extends RoutePath>(\n\t\tpath: Path,\n\t\tfile:\n\t\t\t| string\n\t\t\t| Blob\n\t\t\t| ((ctx: BaseContext & Ctx) => MaybePromise<Blob | null | undefined>),\n\t\toptions: FileOptions = {},\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes &\n\t\t\tRouteEntryOf<\n\t\t\t\t'GET',\n\t\t\t\tJoinPath<Prefix, Path>,\n\t\t\t\tEmpty,\n\t\t\t\tStaticReply,\n\t\t\t\tShortcuts\n\t\t\t>,\n\t\tPrefix,\n\t\tShortcuts\n\t> {\n\t\t(this.get as unknown as (path: string, handler: unknown) => unknown)(\n\t\t\tpath,\n\t\t\tfileHandler(file as Parameters<typeof fileHandler>[0], options),\n\t\t);\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A page of Bun's full-stack bundling: `import index from './index.html'`,\n\t * its scripts and styles bundled by Bun — with hot reloading under\n\t * `development` — and served by `Bun.serve` itself. So it needs `listen`,\n\t * and the app's hooks do not run around it; `app.fetch` answers it 404.\n\t */\n\tpage<const Path extends RoutePath>(path: Path, bundle: Bun.HTMLBundle): this {\n\t\tthis.#page(joinPath(this.#prefix, path), bundle);\n\t\treturn this;\n\t}\n\n\t#page(path: string, bundle: Bun.HTMLBundle): void {\n\t\tif (\n\t\t\tthis.#pageAt(path) !== undefined ||\n\t\t\tthis.#runtime.router.hasShape(path)\n\t\t) {\n\t\t\tthrow new TypeError(`page(): ${path} is already served`);\n\t\t}\n\t\tthis.#runtime.globals.pages.set(path, bundle);\n\t}\n\n\t/**\n\t * A WebSocket route. The upgrade request runs the hooks before it and is\n\t * validated as a route's; each message is then checked by `message`, and\n\t * each one sent by `send`. Open through `listen`, or a `Bun.serve` given\n\t * `fetch` and `websocket`: a socket needs a server.\n\t *\n\t * ```ts\n\t * app.ws('/rooms/:room', { message: Chat, send: Chat }, {\n\t * open: (socket) => socket.subscribe(socket.data.params.room),\n\t * message: (socket, chat) => socket.publish(socket.data.params.room, chat),\n\t * });\n\t * ```\n\t */\n\tws<const Path extends RoutePath, Schema extends SocketSchema = Empty>(\n\t\tpath: Path,\n\t\tschema: Schema,\n\t\thandlers: SocketHandlers<\n\t\t\tSocketContext<Ctx, JoinPath<Prefix, Path>, Schema>,\n\t\t\tSocketSend<Schema>,\n\t\t\tSocketMessage<Schema>\n\t\t>,\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes & SocketEntryOf<JoinPath<Prefix, Path>, Schema>,\n\t\tPrefix,\n\t\tShortcuts\n\t> {\n\t\tconst definition: SocketDefinition = {\n\t\t\tpath: joinPath(this.#prefix, path),\n\t\t\tschema,\n\t\t\thandlers: handlers as SocketDefinition['handlers'],\n\t\t\tderive: [...this.#derive],\n\t\t\tonError: [...this.#onError],\n\t\t};\n\t\tthis.#mount(definition);\n\t\treturn this as never;\n\t}\n\n\t/** Values every route after this reads from its context: a database, a logger. */\n\tdecorate<const Values extends object>(\n\t\tvalues: Values,\n\t): Alxia<Ctx & Values, Routes, Prefix, Shortcuts> {\n\t\tthis.#derive.push({ kind: 'derive', run: () => values });\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A hook run on every request to a route declared after it, before the\n\t * request is validated. What it returns is added to the context; a reply\n\t * it returns ends the request, and is added to the type of every such\n\t * route, so the client reads it:\n\t *\n\t * ```ts\n\t * .derive(async ({ request, reply }) => {\n\t * const user = await authenticate(request);\n\t * return user ? { user } : reply(401, { error: 'unauthenticated' as const });\n\t * })\n\t * ```\n\t */\n\tderive<Result>(\n\t\thook: (ctx: BaseContext & Ctx) => MaybePromise<Result>,\n\t): Alxia<\n\t\tCtx &\n\t\t\t(Exclude<Result, AnyReply> extends infer Added extends object\n\t\t\t\t? Added\n\t\t\t\t: Empty),\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts | Extract<Result, AnyReply>\n\t> {\n\t\tthis.#derive.push({ kind: 'derive', run: hook as DeriveHook });\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A hook around every route declared after it: `next()` runs the rest —\n\t * the hooks declared after this one, validation, the handler — and\n\t * resolves to the response. The hook returns it, another `Response`, or\n\t * a reply of its own, which is added to the type of every such route.\n\t * An error the rest throws reaches it first. A socket's upgrade skips it.\n\t *\n\t * ```ts\n\t * .wrap(async ({ request, reply }, next) =>\n\t * (await locks.tryRun(request, next)) ?? reply(409, { error: 'busy' as const }))\n\t * ```\n\t */\n\twrap<Result extends AnyReply | Response>(\n\t\thook: (\n\t\t\tctx: BaseContext & Ctx,\n\t\t\tnext: () => Promise<Response>,\n\t\t) => MaybePromise<Result>,\n\t): Alxia<Ctx, Routes, Prefix, Shortcuts | Extract<Result, AnyReply>> {\n\t\tthis.#derive.push({ kind: 'wrap', run: hook as unknown as WrapHook });\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A hook that turns an error thrown by a route declared after it into a\n\t * reply. Returning nothing lets the next one try; past the last, an\n\t * `HttpError` is answered as it says and anything else as a 500.\n\t */\n\tonError<Result extends AnyReply | undefined | void>(\n\t\thook: (\n\t\t\terror: unknown,\n\t\t\tctx: BaseContext & Partial<Ctx>,\n\t\t) => MaybePromise<Result>,\n\t): Alxia<Ctx, Routes, Prefix, Shortcuts | Extract<Result, AnyReply>> {\n\t\tthis.#onError.push(hook as unknown as ErrorHook);\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A global hook run on every request, before routing: a 404 included. A\n\t * `Response` it returns is sent as it is, and is no part of any route's\n\t * type: use it for what a typed client never asks — a CORS preflight, a\n\t * redirect to HTTPS. What a client must read belongs in `derive`.\n\t */\n\tonRequest(hook: RequestHook): this {\n\t\tthis.#runtime.globals.onRequest.push(hook);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A global hook run on every response, in the order declared: headers,\n\t * compression, logging. A `Response` it returns replaces the one sent;\n\t * keep its status, which the client's types promise.\n\t */\n\tonResponse(hook: ResponseHook): this {\n\t\tthis.#runtime.globals.onResponse.push(hook);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A global hook around every request, the first declared outermost.\n\t * `next()` runs everything else and resolves to the response; the hook\n\t * returns it, or another. A socket's upgrade runs outside it: there is no\n\t * response to wrap.\n\t *\n\t * ```ts\n\t * app.around(async (ctx, next) => {\n\t * const started = performance.now();\n\t * const response = await next();\n\t * console.log(ctx.route, performance.now() - started);\n\t * return response;\n\t * });\n\t * ```\n\t */\n\taround(hook: AroundHook): this {\n\t\tthis.#runtime.globals.around.push(hook);\n\t\treturn this;\n\t}\n\n\t/** Runs once `listen` has started the server. */\n\tonStart(hook: StartHook): this {\n\t\tthis.#runtime.globals.onStart.push(hook);\n\t\treturn this;\n\t}\n\n\t/** Runs when `stop` stops the server: close a pool, flush a log. */\n\tonStop(hook: StopHook): this {\n\t\tthis.#runtime.globals.onStop.push(hook);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Reads a body of `type` — a `content-type` prefix, or a pattern — for\n\t * every route with a `body` schema, before the built-in JSON, form and\n\t * text parsers.\n\t */\n\tparser(type: string | RegExp, parse: BodyParser['parse']): this {\n\t\tthis.#runtime.globals.parsers.push({ type, parse });\n\t\treturn this;\n\t}\n\n\t/**\n\t * Routes declared in a scope: the hooks `build` adds apply only to them.\n\t * The routes keep every hook declared on this app before the group.\n\t *\n\t * ```ts\n\t * app.group('/admin', (admin) => admin.derive(requireAdmin).get('/stats', ...));\n\t * ```\n\t */\n\tgroup<\n\t\tconst Path extends RoutePath,\n\t\tGroupRoutes extends object,\n\t\tGroupCtx extends object,\n\t\tGroupShortcuts extends AnyReply,\n\t>(\n\t\tprefix: Path,\n\t\tbuild: (\n\t\t\tgroup: Alxia<Ctx, Empty, JoinPath<Prefix, Path>, Shortcuts>,\n\t\t) => Alxia<GroupCtx, GroupRoutes, JoinPath<Prefix, Path>, GroupShortcuts>,\n\t): Alxia<Ctx, Routes & GroupRoutes, Prefix, Shortcuts>;\n\tgroup<\n\t\tGroupRoutes extends object,\n\t\tGroupCtx extends object,\n\t\tGroupShortcuts extends AnyReply,\n\t>(\n\t\tbuild: (\n\t\t\tgroup: Alxia<Ctx, Empty, Prefix, Shortcuts>,\n\t\t) => Alxia<GroupCtx, GroupRoutes, Prefix, GroupShortcuts>,\n\t): Alxia<Ctx, Routes & GroupRoutes, Prefix, Shortcuts>;\n\tgroup(\n\t\tprefixOrBuild: string | ((group: AnyAlxia) => AnyAlxia),\n\t\tmaybeBuild?: (group: AnyAlxia) => AnyAlxia,\n\t): AnyAlxia {\n\t\tconst [prefix, build] =\n\t\t\ttypeof prefixOrBuild === 'string'\n\t\t\t\t? [joinPath(this.#prefix, prefixOrBuild), maybeBuild]\n\t\t\t\t: [this.#prefix, prefixOrBuild];\n\t\tif (build === undefined) throw new TypeError('group(): build is missing');\n\t\tconst child = new Alxia({\n\t\t\tprefix,\n\t\t\tvalidateResponses: this.#runtime.validateResponses,\n\t\t});\n\t\tchild.#derive = [...this.#derive];\n\t\tchild.#onError = [...this.#onError];\n\t\tchild.#runtime = { ...child.#runtime, globals: this.#runtime.globals };\n\t\tconst before = new Set(this.#runtime.globals.pages.keys());\n\t\tconst built = build(child);\n\t\t// The child checks its pages against its own routes only.\n\t\tfor (const path of this.#runtime.globals.pages.keys()) {\n\t\t\tif (!before.has(path) && this.#runtime.router.hasShape(path)) {\n\t\t\t\tthrow new TypeError(`page(): ${path} is already served`);\n\t\t\t}\n\t\t}\n\t\tfor (const route of built.routes) this.#register(route);\n\t\tfor (const socket of built.sockets) this.#mount(socket);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A plugin. An app: its routes, under this app's prefix and behind this\n\t * app's hooks, and its hooks, which then apply to the routes declared on\n\t * this app after it — a plugin can be an `auth` that only derives a\n\t * `user`. Its global hooks become this app's. It is read once, here:\n\t * declare it completely before using it. A plugin made by `definePlugin`\n\t * names what it reads from this app's context: using it on an app that\n\t * does not give it is a compile error.\n\t *\n\t * Or a function, given this app, that returns it: a `Plugin`.\n\t */\n\tuse<Result extends AnyAlxia>(plugin: (app: this) => Result): Result;\n\tuse<\n\t\tPluginCtx extends object,\n\t\tPluginRoutes extends object,\n\t\tPluginPrefix extends string,\n\t\tPluginShortcuts extends AnyReply,\n\t\tPluginRequires = Empty,\n\t>(\n\t\tplugin: Alxia<PluginCtx, PluginRoutes, PluginPrefix, PluginShortcuts> & {\n\t\t\treadonly '~requires'?: PluginRequires;\n\t\t} & ProvidedBy<Ctx, PluginRequires>,\n\t): Alxia<\n\t\tCtx & PluginCtx,\n\t\tRoutes & Prefixed<Prefix, PluginRoutes, Shortcuts>,\n\t\tPrefix,\n\t\tShortcuts | PluginShortcuts\n\t>;\n\tuse(plugin: AnyAlxia | ((app: any) => AnyAlxia)): AnyAlxia {\n\t\tif (!(plugin instanceof Alxia)) return plugin(this);\n\t\tfor (const route of plugin.routes) {\n\t\t\tthis.#register({\n\t\t\t\t...route,\n\t\t\t\tpath: joinPath(this.#prefix, route.path),\n\t\t\t\tderive: [...this.#derive, ...route.derive],\n\t\t\t\tonError: [...route.onError, ...this.#onError],\n\t\t\t});\n\t\t}\n\t\tfor (const socket of plugin.sockets) {\n\t\t\tthis.#mount({\n\t\t\t\t...socket,\n\t\t\t\tpath: joinPath(this.#prefix, socket.path),\n\t\t\t\tderive: [...this.#derive, ...socket.derive],\n\t\t\t\tonError: [...socket.onError, ...this.#onError],\n\t\t\t});\n\t\t}\n\t\tthis.#derive = [...this.#derive, ...plugin.#derive];\n\t\tthis.#onError = [...plugin.#onError, ...this.#onError];\n\t\tif (plugin.#runtime.globals !== this.#runtime.globals) {\n\t\t\tconst globals = plugin.#runtime.globals;\n\t\t\tthis.#runtime.globals.around.push(...globals.around);\n\t\t\tthis.#runtime.globals.onRequest.push(...globals.onRequest);\n\t\t\tthis.#runtime.globals.onResponse.push(...globals.onResponse);\n\t\t\tthis.#runtime.globals.onStart.push(...globals.onStart);\n\t\t\tthis.#runtime.globals.onStop.push(...globals.onStop);\n\t\t\tthis.#runtime.globals.parsers.push(...globals.parsers);\n\t\t\tfor (const [path, bundle] of globals.pages) {\n\t\t\t\tthis.#page(joinPath(this.#prefix, path), bundle);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/** Every route, in the order declared: what `@alxia/openapi` documents. */\n\tget routes(): readonly RouteDefinition[] {\n\t\treturn this.#routes;\n\t}\n\n\t/** Every socket route, in the order declared. */\n\tget sockets(): readonly SocketDefinition[] {\n\t\treturn this.#sockets;\n\t}\n\n\t/** The server `listen` started, until `stop`. */\n\tget server(): Bun.Server<unknown> | undefined {\n\t\treturn this.#server;\n\t}\n\n\t/**\n\t * The app as a fetch handler: what `Bun.serve`, a test, or another\n\t * runtime calls. Bound, so `export default { fetch: app.fetch }` works.\n\t * Given the server, as `Bun.serve` gives it, it can open a socket.\n\t */\n\treadonly fetch = (\n\t\trequest: Request,\n\t\tserver?: Bun.Server<unknown>,\n\t): Promise<Response> => serve(this.#runtime, request, server, undefined);\n\n\t/**\n\t * The `websocket` handler `Bun.serve` opens this app's sockets with, beside\n\t * `fetch`: what `listen` passes, for a server started otherwise.\n\t *\n\t * ```ts\n\t * Bun.serve({ fetch: app.fetch, websocket: app.websocket });\n\t * ```\n\t */\n\tget websocket(): Bun.WebSocketHandler<SocketData> {\n\t\tthis.#websocket ??= websocketHandler(this.#runtime.validateResponses);\n\t\treturn this.#websocket;\n\t}\n\n\t/** A request to the app, in process: `app.request('/users/1')`. */\n\trequest(path: string, init?: RequestInit): Promise<Response> {\n\t\treturn this.fetch(new Request(new URL(path, 'http://localhost'), init));\n\t}\n\n\t/**\n\t * `Bun.serve` with this app: its paths go to Bun's own router, and what\n\t * none of them matches to `fetch`, which answers 404 or 405.\n\t *\n\t * Bun matches the request's target as it came, `/f/../a` and all, where\n\t * `fetch` reads its URL's pathname, `/a`. A path without parameters is\n\t * matched by Bun only by a target already in that form, so its route\n\t * answers; a request Bun gives to a path with parameters or a wildcard\n\t * is routed again as `fetch` routes it, so both choose alike, at the\n\t * cost of `fetch`'s routing on each such request.\n\t */\n\tlisten(options: ListenOptions | number = {}): Bun.Server<unknown> {\n\t\tconst settings = typeof options === 'number' ? { port: options } : options;\n\t\tconst routes: Record<\n\t\t\tstring,\n\t\t\t| Bun.HTMLBundle\n\t\t\t| ((request: Request, server: Bun.Server<unknown>) => Promise<Response>)\n\t\t> = {};\n\t\tfor (const [path] of this.#runtime.router.paths()) {\n\t\t\tconst routed = this.#runtime.router.isFixed(path) ? path : undefined;\n\t\t\troutes[path] = (request, server) =>\n\t\t\t\tserve(this.#runtime, request, server, routed);\n\t\t}\n\t\tfor (const [path, bundle] of this.#runtime.globals.pages) {\n\t\t\troutes[path] = bundle;\n\t\t}\n\t\tconst server = Bun.serve({\n\t\t\t...settings,\n\t\t\troutes,\n\t\t\tfetch: (request: Request, server: Bun.Server<unknown>) =>\n\t\t\t\tserve(this.#runtime, request, server, undefined),\n\t\t\twebsocket: this.websocket,\n\t\t} as Bun.Serve.Options<SocketData>) as Bun.Server<unknown>;\n\t\tthis.#server = server;\n\t\tfor (const hook of this.#runtime.globals.onStart) {\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => hook(server))\n\t\t\t\t.catch((error) => console.error(error));\n\t\t}\n\t\treturn server;\n\t}\n\n\t/** Stops the server `listen` started, then runs every `onStop` hook. */\n\tasync stop(closeActiveConnections = false): Promise<void> {\n\t\tconst server = this.#server;\n\t\tthis.#server = undefined;\n\t\tif (server !== undefined) await server.stop(closeActiveConnections);\n\t\tfor (const hook of this.#runtime.globals.onStop) await hook();\n\t}\n\n\t#method(method: Method) {\n\t\treturn (\n\t\t\tpath: string,\n\t\t\tschemaOrHandler: RouteSchema | RouteDefinition['handler'],\n\t\t\tmaybeHandler?: RouteDefinition['handler'],\n\t\t) => {\n\t\t\tconst [schema, handler] =\n\t\t\t\ttypeof schemaOrHandler === 'function'\n\t\t\t\t\t? [{}, schemaOrHandler]\n\t\t\t\t\t: [schemaOrHandler, maybeHandler];\n\t\t\tif (typeof handler !== 'function') {\n\t\t\t\tthrow new TypeError(`${method} ${path}: the handler is missing`);\n\t\t\t}\n\t\t\tthis.#register({\n\t\t\t\tmethod,\n\t\t\t\tpath: joinPath(this.#prefix, path),\n\t\t\t\tschema,\n\t\t\t\thandler,\n\t\t\t\tderive: [...this.#derive],\n\t\t\t\tonError: [...this.#onError],\n\t\t\t});\n\t\t\treturn this;\n\t\t};\n\t}\n\n\t#register(route: RouteDefinition): void {\n\t\tthis.#refusePage(route.method, route.path);\n\t\tthis.#runtime.router.add(route.method, route.path, {\n\t\t\tkind: 'http',\n\t\t\t...route,\n\t\t});\n\t\tthis.#routes.push(route);\n\t}\n\n\t/** `listen` serves a page before any route at its path: refuse the route. */\n\t#refusePage(method: string, path: string): void {\n\t\tif (this.#pageAt(path) !== undefined) {\n\t\t\tthrow new TypeError(`${method} ${path} is already served by a page`);\n\t\t}\n\t}\n\n\t/** The page declared at a path of the same shape as `path`. */\n\t#pageAt(path: string): string | undefined {\n\t\tconst shape = shapeOf(path);\n\t\tfor (const page of this.#runtime.globals.pages.keys()) {\n\t\t\tif (shapeOf(page) === shape) return page;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t#mount(socket: SocketDefinition): void {\n\t\tthis.#refusePage('WS', socket.path);\n\t\tthis.#runtime.router.add('WS', socket.path, { kind: 'ws', ...socket });\n\t\tthis.#sockets.push(socket);\n\t}\n}\n\n/** A new app. */\nexport function alxia<const Prefix extends '' | RoutePath = ''>(\n\toptions: AlxiaOptions<Prefix> = {},\n): Alxia<Empty, Empty, Prefix, never> {\n\treturn new Alxia(options);\n}\n\n/** The route table of an app, as the client reads it. */\nexport type RoutesOf<App> = App extends { readonly '~routes': infer Routes }\n\t? Routes\n\t: never;\n\n/**\n * What a route declared next on `App` reads: the context its hooks build —\n * `decorate`, `derive`, every plugin's — on top of the base context. A\n * GraphQL schema, a service, types its own context with it.\n */\nexport type ContextOf<App> = App extends { readonly '~context': infer Ctx }\n\t? BaseContext & Ctx\n\t: never;\n\nexport type { Outcome };\n",
23
- "import { type Alxia, type AnyAlxia, alxia } from './alxia';\nimport type { Empty, Requiring } from './types';\n\n/**\n * A plugin that reads what an earlier one added to the context. Name what it\n * needs, then build it on an app whose context already has it:\n *\n * ```ts\n * const tenant = definePlugin<{ user: { tenantId: string } }>()((app) =>\n * app.derive(({ user }) => ({ tenant: tenants.get(user.tenantId) })),\n * );\n *\n * alxia().use(auth).use(tenant); // compiles: auth derives a user, or answers 401\n * alxia().use(tenant); // a compile error: this app gives no `user`\n * ```\n *\n * The plugin is an app, given to `use` like any other, built once, here.\n * `use` checks the app's context against `Requires`, so the plugin's hooks\n * never run without what they read.\n */\nexport function definePlugin<Requires extends object = Empty>() {\n\treturn <Plugin extends AnyAlxia>(\n\t\tbuild: (app: Alxia<Requires>) => Plugin,\n\t): Plugin & Requiring<Requires> =>\n\t\tbuild(alxia() as unknown as Alxia<Requires>) as Plugin &\n\t\t\tRequiring<Requires>;\n}\n"
21
+ "import { ContentTooLargeError, type ValidationIssue } from '../errors/errors';\n\n/**\n * The query string as an object. A key given once is a string, a key given\n * more than once an array of them, so `z.array(...)` reads `?tag=a&tag=b`;\n * for a list that may hold one item, accept both (see the README).\n */\nexport function readQuery(url: URL): Record<string, string | string[]> {\n\tconst query: Record<string, string | string[]> = {};\n\tfor (const [key, value] of url.searchParams) {\n\t\tconst seen = query[key];\n\t\tif (seen === undefined) query[key] = value;\n\t\telse if (typeof seen === 'string') query[key] = [seen, value];\n\t\telse seen.push(value);\n\t}\n\treturn query;\n}\n\n/** The request headers as an object, names lowercased. */\nexport function readHeaders(headers: Headers): Record<string, string> {\n\tconst read: Record<string, string> = {};\n\tfor (const [key, value] of headers) read[key] = value;\n\treturn read;\n}\n\n/** The request cookies as an object. */\nexport function readCookies(headers: Headers): Record<string, string> {\n\tconst cookie = headers.get('cookie');\n\tif (cookie === null) return {};\n\treturn Object.fromEntries(new Bun.CookieMap(cookie));\n}\n\n/** A body parser an app adds, tried before the built-in ones. */\nexport interface BodyParser {\n\t/** A `content-type` it reads: a prefix, or a pattern. */\n\treadonly type: string | RegExp;\n\treadonly parse: (request: Request) => unknown;\n}\n\nfunction parserFor(\n\tparsers: readonly BodyParser[],\n\ttype: string,\n): BodyParser | undefined {\n\treturn parsers.find((parser) =>\n\t\ttypeof parser.type === 'string'\n\t\t\t? type.startsWith(parser.type)\n\t\t\t: parser.type.test(type),\n\t);\n}\n\nexport type ReadBody =\n\t| { readonly ok: true; readonly value: unknown }\n\t| { readonly ok: false; readonly issue: ValidationIssue };\n\n/**\n * The request body, read by its `content-type`: by a parser the app added,\n * else JSON, a form (an object of its fields, a field given more than once\n * an array), text, or the bytes. A body past the route's `bodyLimit` throws\n * a `ContentTooLargeError`, a custom parser's included.\n */\nexport async function readBody(\n\trequest: Request,\n\tparsers: readonly BodyParser[] = [],\n): Promise<ReadBody> {\n\tconst type = request.headers.get('content-type')?.toLowerCase() ?? '';\n\tconst custom = parserFor(parsers, type);\n\tif (custom !== undefined) {\n\t\ttry {\n\t\t\treturn { ok: true, value: await custom.parse(request) };\n\t\t} catch (error) {\n\t\t\tif (error instanceof ContentTooLargeError) throw error;\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tissue: {\n\t\t\t\t\ttarget: 'body',\n\t\t\t\t\tpath: [],\n\t\t\t\t\tcode: 'unreadable_body',\n\t\t\t\t\tmessage:\n\t\t\t\t\t\terror instanceof Error ? error.message : 'The body cannot be read',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\tif (type.includes('json')) {\n\t\tconst text = await request.text();\n\t\tif (text === '') return { ok: true, value: undefined };\n\t\ttry {\n\t\t\treturn { ok: true, value: JSON.parse(text) };\n\t\t} catch {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tissue: {\n\t\t\t\t\ttarget: 'body',\n\t\t\t\t\tpath: [],\n\t\t\t\t\tcode: 'invalid_json',\n\t\t\t\t\tmessage: 'The body is not valid JSON',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\tif (\n\t\ttype.startsWith('multipart/form-data') ||\n\t\ttype.startsWith('application/x-www-form-urlencoded')\n\t) {\n\t\tconst form = await request.formData();\n\t\tconst value: Record<string, FormDataEntryValue | FormDataEntryValue[]> = {};\n\t\tfor (const [key, entry] of form) {\n\t\t\tconst seen = value[key];\n\t\t\tif (seen === undefined) value[key] = entry;\n\t\t\telse if (Array.isArray(seen)) seen.push(entry);\n\t\t\telse value[key] = [seen, entry];\n\t\t}\n\t\treturn { ok: true, value };\n\t}\n\tif (type.startsWith('text/'))\n\t\treturn { ok: true, value: await request.text() };\n\tif (request.body === null) return { ok: true, value: undefined };\n\treturn { ok: true, value: await request.arrayBuffer() };\n}\n",
22
+ "/**\n * The context a route's hooks and handler read: the request, bounded by\n * the route's `bodyLimit`, its path parameters as they arrived, and what\n * it sets on its response.\n */\nimport { createReply, Reply } from '../reply/reply';\nimport { limitBody } from '../request/limit';\nimport type { RedirectStatus } from '../types/status';\nimport type { RouteDefinition, SocketDefinition } from './definition';\nimport type {\n\tBaseContext,\n\tRedirectFunction,\n\tRequestContext,\n\tResponseSettings,\n} from './types';\n\nconst redirect: RedirectFunction = (location, status) =>\n\tnew Reply(status ?? (302 as RedirectStatus), undefined, {\n\t\theaders: { location: String(location) },\n\t}) as never;\n\n/**\n * The context a route's hooks and handler read, and what they set on its\n * response. Under a `bodyLimit`, its `request` is the one whose body is\n * bounded: every reader of the body, core's or the handler's, counts.\n */\nexport function routeContext(\n\tdefinition: RouteDefinition | SocketDefinition,\n\trequest: RequestContext,\n\tpathParams: Record<string, string>,\n): { ctx: Record<string, unknown> & BaseContext; set: ResponseSettings } {\n\tlet cookies: Bun.CookieMap | undefined;\n\tconst set: ResponseSettings & { readonly touched: () => boolean } = {\n\t\theaders: new Headers(),\n\t\tget cookies() {\n\t\t\tcookies ??= new Bun.CookieMap();\n\t\t\treturn cookies;\n\t\t},\n\t\ttouched: () => cookies !== undefined,\n\t};\n\tconst limit = 'bodyLimit' in definition ? definition.bodyLimit : undefined;\n\tconst ctx: Record<string, unknown> & BaseContext = {\n\t\t...request,\n\t\t...(limit === undefined\n\t\t\t? {}\n\t\t\t: { request: limitBody(request.request, limit) }),\n\t\troute: definition.path,\n\t\tpathParams,\n\t\tset,\n\t\treply: createReply,\n\t\tredirect,\n\t};\n\treturn { ctx, set };\n}\n",
23
+ "/**\n * How a reply becomes a response: the headers and cookies the route set\n * merged with the reply's own, the body checked by the schema the route\n * declares for its status, and the answers the router gives on its own.\n */\nimport {\n\ttype InternalErrorBody,\n\tResponseValidationError,\n\ttype RoutingErrorBody,\n} from '../errors/errors';\nimport { vary } from '../reply/headers';\nimport { type AnyReply, Reply, toResponse } from '../reply/reply';\nimport { check, type StandardSchemaV1 } from '../schema/standard-schema';\nimport { isAsyncIterable } from '../sse/async-iterable';\nimport { isNamedEventStreamSchema, toFrames } from '../sse/named-events';\nimport type { RouteDefinition } from './definition';\nimport type { ResponseSchemas, ResponseSettings } from './types';\n\nconst internal: InternalErrorBody = { error: 'internal' };\n\n/** The 500 of a request that failed: its body says no more than `internal`. */\nexport function internalError(): Response {\n\treturn toResponse(500, internal, new Headers());\n}\n\n/** A reply as it is, with what the route set on its response. */\nexport function send(\n\treply: AnyReply,\n\tset: ResponseSettings,\n\tsignal?: AbortSignal,\n): Response {\n\tconst headers = new Headers(set.headers);\n\tif (reply.headers !== undefined) {\n\t\tfor (const [key, value] of new Headers(reply.headers)) {\n\t\t\t// A reply's Vary adds to the plugins': each said what it read.\n\t\t\tif (key === 'vary') {\n\t\t\t\tfor (const name of value.split(',')) vary(headers, name);\n\t\t\t} else if (key === 'set-cookie') {\n\t\t\t\t// Each cookie is its own header: setting would keep the last.\n\t\t\t\theaders.append(key, value);\n\t\t\t} else headers.set(key, value);\n\t\t}\n\t}\n\tif ((set as { touched?: () => boolean }).touched?.()) {\n\t\tfor (const cookie of set.cookies.toSetCookieHeaders()) {\n\t\t\theaders.append('set-cookie', cookie);\n\t\t}\n\t}\n\treturn toResponse(reply.status, reply.body, headers, signal);\n}\n\n/**\n * A handler's reply, checked against the schema its route declares for its\n * status and sent as that schema's output. A status the route does not\n * declare, or a body its schema refuses, throws a `ResponseValidationError`.\n */\nexport async function sendDeclared(\n\troute: RouteDefinition,\n\treply: AnyReply,\n\tset: ResponseSettings,\n\tsignal: AbortSignal,\n\tvalidateResponses: boolean,\n): Promise<Response> {\n\tconst responses = route.schema.response;\n\tif (responses === undefined || isRedirect(reply)) {\n\t\treturn send(reply, set, signal);\n\t}\n\tconst checked = await checkReply(\n\t\troute.method,\n\t\troute.path,\n\t\tresponses,\n\t\treply,\n\t\tvalidateResponses,\n\t);\n\treturn send(checked, set, signal);\n}\n\n/**\n * `reply` checked against the schema `responses` declares for its status,\n * as that schema's output: what a handler's reply and an `onRefusal`\n * hook's go through. A status with no schema, or a body its schema\n * refuses, throws a `ResponseValidationError`.\n */\nexport async function checkReply(\n\tmethod: string,\n\tpath: string,\n\tresponses: ResponseSchemas,\n\treply: AnyReply,\n\tvalidateResponses: boolean,\n): Promise<AnyReply> {\n\tconst schema = responses[reply.status as keyof typeof responses];\n\tif (schema === undefined) {\n\t\tthrow ResponseValidationError.undeclared(method, path, reply.status);\n\t}\n\tif (!validateResponses) return framed(schema, reply);\n\tconst checked = await check(schema, reply.body, 'body');\n\tif (!checked.ok) {\n\t\tthrow new ResponseValidationError(\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\treply.status,\n\t\t\tchecked.issues,\n\t\t);\n\t}\n\treturn new Reply(reply.status, checked.value, {\n\t\theaders: reply.headers ?? {},\n\t});\n}\n\n/** What the router answers when no route takes the request. */\nexport function routingError(\n\tstatus: 404 | 405 | 426,\n\terror: RoutingErrorBody['error'],\n\tallowed?: readonly string[],\n): Response {\n\tconst headers = new Headers();\n\tif (allowed !== undefined) headers.set('allow', allowed.join(', '));\n\tconst body: RoutingErrorBody = { error };\n\treturn toResponse(status, body, headers);\n}\n\n/**\n * An unchecked reply as it is, but for a named event stream: its events\n * still need their `event:` lines, and their fields still refuse a line\n * break.\n */\nfunction framed(schema: StandardSchemaV1, reply: AnyReply): AnyReply {\n\tif (!isNamedEventStreamSchema(schema) || !isAsyncIterable(reply.body)) {\n\t\treturn reply;\n\t}\n\treturn new Reply(\n\t\treply.status,\n\t\ttoFrames(schema['~events'], reply.body, false),\n\t\t{ headers: reply.headers ?? {} },\n\t);\n}\n\nfunction isRedirect(reply: AnyReply): boolean {\n\treturn reply.status >= 300 && reply.status < 400 && reply.body === undefined;\n}\n",
24
+ "/**\n * A request the app refused before its handler ran, answered: by the\n * route's `onRefusal` hook, or by the default.\n */\nimport type {\n\tContentTooLargeBody,\n\tRefusal,\n\tValidationErrorBody,\n} from '../errors/errors';\nimport { Reply } from '../reply/reply';\nimport type { RouteDefinition, SocketDefinition } from './definition';\nimport { checkReply, send } from './send';\nimport type { BaseContext, ResponseSettings } from './types';\n\n/**\n * A refused request, answered by the route's `onRefusal` hook — its reply\n * checked by the schemas the hook declares — or, when it has none or\n * returns nothing, by the default of its kind: a 400 with the issues of a\n * `validation`, the 413 of a `body_limit`.\n */\nexport async function refuse(\n\tdefinition: RouteDefinition | SocketDefinition,\n\trefusal: Refusal,\n\tset: ResponseSettings,\n\tctx: BaseContext,\n\tvalidateResponses: boolean,\n): Promise<Response> {\n\tconst handler = definition.refusal;\n\tif (handler !== undefined) {\n\t\tlet reply = handler.hook(refusal, ctx);\n\t\tif (reply instanceof Promise) reply = await reply;\n\t\tconst method = 'method' in definition ? definition.method : 'WS';\n\t\tif (reply instanceof Reply) {\n\t\t\tif (handler.response !== undefined) {\n\t\t\t\treply = await checkReply(\n\t\t\t\t\tmethod,\n\t\t\t\t\tdefinition.path,\n\t\t\t\t\thandler.response,\n\t\t\t\t\treply,\n\t\t\t\t\tvalidateResponses,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn send(withContentType(reply, handler.contentType), set);\n\t\t}\n\t\tif (reply !== undefined) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${method} ${definition.path}: the onRefusal hook returned neither a reply nor nothing.`,\n\t\t\t);\n\t\t}\n\t}\n\treturn send(byDefault(refusal), set);\n}\n\n/** The reply a refusal gets when no hook answers it. */\nfunction byDefault(refusal: Refusal): Reply {\n\tswitch (refusal.kind) {\n\t\tcase 'validation': {\n\t\t\tconst body: ValidationErrorBody = {\n\t\t\t\terror: 'validation',\n\t\t\t\tissues: refusal.issues,\n\t\t\t};\n\t\t\treturn new Reply(400, body);\n\t\t}\n\t\tcase 'body_limit': {\n\t\t\tconst body: ContentTooLargeBody = {\n\t\t\t\terror: 'content_too_large',\n\t\t\t\tlimit: refusal.limit,\n\t\t\t};\n\t\t\treturn new Reply(413, body);\n\t\t}\n\t}\n}\n\n/** `reply` with `content-type` set to `type`, unless it sets one. */\nfunction withContentType(reply: Reply, type: string | undefined): Reply {\n\tif (type === undefined) return reply;\n\tconst headers = new Headers(reply.headers);\n\tif (headers.has('content-type')) return reply;\n\theaders.set('content-type', type);\n\treturn new Reply(reply.status, reply.body, { headers });\n}\n",
25
+ "/**\n * A route's own run, once the router has found it: its context, its hooks\n * in the order declared, the request validated, the handler, and the\n * `onError` hooks when any of it throws.\n */\nimport {\n\tContentTooLargeError,\n\tHttpError,\n\ttype RequestPart,\n\ttype ValidationIssue,\n} from '../errors/errors';\nimport { Reply } from '../reply/reply';\nimport {\n\ttype BodyParser,\n\treadBody,\n\treadCookies,\n\treadHeaders,\n\treadQuery,\n} from '../request/read';\nimport { check } from '../schema/standard-schema';\nimport { routeContext } from './context';\nimport type { RouteDefinition, SocketDefinition } from './definition';\nimport { refuse } from './refusal';\nimport { internalError, send, sendDeclared } from './send';\nimport type { BaseContext, RequestContext, ResponseSettings } from './types';\n\n/**\n * Runs the hooks of a route in order — a `derive` adds to the context or\n * ends the request, a `wrap` runs the rest inside it — then validates the\n * request, then `last`. A socket's upgrade skips the `wrap` hooks: it has\n * no response to wrap.\n */\nexport async function chain<Last>(\n\tdefinition: RouteDefinition | SocketDefinition,\n\trequest: RequestContext,\n\trawParams: Record<string, string>,\n\tset: ResponseSettings,\n\tctx: Record<string, unknown> & BaseContext,\n\tparsers: readonly BodyParser[],\n\tvalidateResponses: boolean,\n\tlast: () => Promise<Response | Last>,\n): Promise<Response | Last> {\n\tconst hooks = definition.derive;\n\tconst socket = !('method' in definition);\n\tconst signal = request.request.signal;\n\tconst step = async (index: number): Promise<Response | Last> => {\n\t\tconst hook = hooks[index];\n\t\tif (hook === undefined) {\n\t\t\tconst refused = await validate(\n\t\t\t\tdefinition,\n\t\t\t\trequest,\n\t\t\t\trawParams,\n\t\t\t\tset,\n\t\t\t\tctx,\n\t\t\t\tparsers,\n\t\t\t\tvalidateResponses,\n\t\t\t);\n\t\t\treturn refused ?? last();\n\t\t}\n\t\tif (hook.kind === 'wrap') {\n\t\t\tif (socket) return step(index + 1);\n\t\t\tlet wrapped = hook.run(ctx, () => step(index + 1) as Promise<Response>);\n\t\t\tif (wrapped instanceof Promise) wrapped = await wrapped;\n\t\t\treturn wrapped instanceof Reply ? send(wrapped, set, signal) : wrapped;\n\t\t}\n\t\tlet added = hook.run(ctx);\n\t\tif (added instanceof Promise) added = await added;\n\t\tif (added instanceof Reply) return send(added, set, signal);\n\t\tif (added !== null && typeof added === 'object') {\n\t\t\tObject.assign(ctx, added);\n\t\t}\n\t\treturn step(index + 1);\n\t};\n\treturn step(0);\n}\n\n/** The request checked by the route's schemas: the response that refuses it, or nothing. */\nasync function validate(\n\tdefinition: RouteDefinition | SocketDefinition,\n\trequest: RequestContext,\n\trawParams: Record<string, string>,\n\tset: ResponseSettings,\n\tctx: Record<string, unknown> & BaseContext,\n\tparsers: readonly BodyParser[],\n\tvalidateResponses: boolean,\n): Promise<Response | undefined> {\n\tconst { schema } = definition;\n\tconst issues: ValidationIssue[] = [];\n\tlet part: RequestPart | undefined;\n\tconst parts = [\n\t\t['params', schema.params, () => rawParams],\n\t\t['query', schema.query, () => readQuery(request.url)],\n\t\t['headers', schema.headers, () => readHeaders(request.request.headers)],\n\t\t['cookies', schema.cookies, () => readCookies(request.request.headers)],\n\t] as const;\n\tfor (const [target, partSchema, read] of parts) {\n\t\tconst raw = read();\n\t\tif (partSchema === undefined) {\n\t\t\tctx[target] = raw;\n\t\t\tcontinue;\n\t\t}\n\t\tconst checked = await check(partSchema, raw, target);\n\t\tif (checked.ok) ctx[target] = checked.value;\n\t\telse {\n\t\t\tpart ??= target;\n\t\t\tissues.push(...checked.issues);\n\t\t}\n\t}\n\tctx['body'] = undefined;\n\tconst bodySchema = 'body' in schema ? schema.body : undefined;\n\tif (bodySchema !== undefined) {\n\t\tconst body = await readBody(ctx.request, parsers);\n\t\tif (!body.ok) {\n\t\t\tpart ??= 'body';\n\t\t\tissues.push(body.issue);\n\t\t} else {\n\t\t\tconst checked = await check(bodySchema, body.value, 'body');\n\t\t\tif (checked.ok) ctx['body'] = checked.value;\n\t\t\telse {\n\t\t\t\tpart ??= 'body';\n\t\t\t\tissues.push(...checked.issues);\n\t\t\t}\n\t\t}\n\t}\n\tif (part === undefined) return undefined;\n\treturn refuse(\n\t\tdefinition,\n\t\t{ kind: 'validation', part, issues },\n\t\tset,\n\t\tctx,\n\t\tvalidateResponses,\n\t);\n}\n\n/** A route's request, from its hooks to its handler's reply, sent. */\nexport async function handle(\n\troute: RouteDefinition,\n\trequest: RequestContext,\n\trawParams: Record<string, string>,\n\tparsers: readonly BodyParser[],\n\tvalidateResponses: boolean,\n): Promise<Response> {\n\tconst { ctx, set } = routeContext(route, request, rawParams);\n\ttry {\n\t\treturn await chain(\n\t\t\troute,\n\t\t\trequest,\n\t\t\trawParams,\n\t\t\tset,\n\t\t\tctx,\n\t\t\tparsers,\n\t\t\tvalidateResponses,\n\t\t\tasync () => {\n\t\t\t\tlet reply = route.handler(ctx as never);\n\t\t\t\tif (reply instanceof Promise) reply = await reply;\n\t\t\t\tif (!(reply instanceof Reply)) {\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`${route.method} ${route.path}: the handler returned no reply. ` +\n\t\t\t\t\t\t\t'Return ctx.reply(status, body).',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn sendDeclared(\n\t\t\t\t\troute,\n\t\t\t\t\treply,\n\t\t\t\t\tset,\n\t\t\t\t\trequest.request.signal,\n\t\t\t\t\tvalidateResponses,\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\t(request as { error: unknown }).error = error;\n\t\treturn fail(route, error, ctx, validateResponses);\n\t}\n}\n\n/**\n * An error a route threw, answered by its `onError` hooks in order; past\n * the last, an `HttpError` as it says and anything else as a 500. A body\n * past the route's `bodyLimit` is a refusal instead, answered as\n * `refuse` answers one: by the `onRefusal` hook in force, or its 413.\n */\nexport async function fail(\n\tdefinition: RouteDefinition | SocketDefinition,\n\terror: unknown,\n\tctx: BaseContext,\n\tvalidateResponses = true,\n): Promise<Response> {\n\tif (error instanceof ContentTooLargeError) {\n\t\ttry {\n\t\t\treturn await refuse(\n\t\t\t\tdefinition,\n\t\t\t\t{ kind: 'body_limit', limit: error.limit },\n\t\t\t\tctx.set,\n\t\t\t\tctx,\n\t\t\t\tvalidateResponses,\n\t\t\t);\n\t\t} catch (thrown) {\n\t\t\t// The hook threw answering it: a 500, as a validation refusal's is.\n\t\t\tconsole.error(thrown);\n\t\t\treturn internalError();\n\t\t}\n\t}\n\tfor (const hook of definition.onError) {\n\t\tlet handled = hook(error, ctx);\n\t\tif (handled instanceof Promise) handled = await handled;\n\t\tif (handled instanceof Reply) return send(handled, ctx.set);\n\t}\n\tif (error instanceof HttpError) {\n\t\treturn send(new Reply(error.status, error.body), ctx.set);\n\t}\n\tconsole.error(error);\n\treturn internalError();\n}\n",
26
+ "/**\n * A socket route: the upgrade request, run through the route's hooks and\n * validated as a route's, then each message checked by its schema and each\n * one sent checked by its own.\n */\nimport {\n\tResponseValidationError,\n\ttype ValidationErrorBody,\n} from '../errors/errors';\nimport type { BodyParser } from '../request/read';\nimport { check, type StandardSchemaV1 } from '../schema/standard-schema';\nimport type { Socket } from '../ws/types';\nimport { chain, fail } from './chain';\nimport { routeContext } from './context';\nimport type { SocketDefinition } from './definition';\nimport { routingError } from './send';\nimport type { MaybePromise, RequestContext } from './types';\n\n/** What the pipeline returns once a socket is open: Bun wants no response then. */\nexport const UPGRADED = Symbol('upgraded');\n\n/** What Bun keeps on each socket: its route, the context its hooks built, and its `Socket`. */\nexport interface SocketData {\n\treadonly definition: SocketDefinition;\n\treadonly ctx: Record<string, unknown>;\n\tsocket?: Socket<unknown, unknown>;\n}\n\n/** The upgrade request of a socket route: its hooks, its validation, then the upgrade. */\nexport async function upgradeSocket(\n\tdefinition: SocketDefinition,\n\trequest: RequestContext,\n\trawParams: Record<string, string>,\n\tparsers: readonly BodyParser[],\n\tvalidateResponses: boolean,\n): Promise<Response | typeof UPGRADED> {\n\tconst { ctx, set } = routeContext(definition, request, rawParams);\n\tconst server = request.server;\n\ttry {\n\t\treturn await chain<typeof UPGRADED>(\n\t\t\tdefinition,\n\t\t\trequest,\n\t\t\trawParams,\n\t\t\tset,\n\t\t\tctx,\n\t\t\tparsers,\n\t\t\tvalidateResponses,\n\t\t\tasync () => {\n\t\t\t\tif (server === undefined) {\n\t\t\t\t\treturn routingError(426, 'upgrade_required');\n\t\t\t\t}\n\t\t\t\tconst headers = new Headers(set.headers);\n\t\t\t\tif ((set as { touched?: () => boolean }).touched?.()) {\n\t\t\t\t\tfor (const cookie of set.cookies.toSetCookieHeaders()) {\n\t\t\t\t\t\theaders.append('set-cookie', cookie);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst data: SocketData = { definition, ctx };\n\t\t\t\tconst upgraded = server.upgrade(request.request, { headers, data });\n\t\t\t\treturn upgraded ? UPGRADED : routingError(426, 'upgrade_required');\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\treturn fail(definition, error, ctx);\n\t}\n}\n\n/** The `websocket` handler `Bun.serve` runs every open socket through. */\nexport function websocketHandler(\n\tvalidate: boolean,\n): Bun.WebSocketHandler<SocketData> {\n\tconst socketOf = (ws: Bun.ServerWebSocket<SocketData>) => {\n\t\tws.data.socket ??= createSocket(ws, validate);\n\t\treturn ws.data.socket;\n\t};\n\tconst guard = async (\n\t\tws: Bun.ServerWebSocket<SocketData>,\n\t\trun: () => MaybePromise<void>,\n\t) => {\n\t\ttry {\n\t\t\tawait run();\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t\tws.close(1011, 'internal error');\n\t\t}\n\t};\n\treturn {\n\t\topen: (ws) =>\n\t\t\tguard(ws, () =>\n\t\t\t\tws.data.definition.handlers.open?.(socketOf(ws) as never),\n\t\t\t),\n\t\tmessage: (ws, raw) =>\n\t\t\tguard(ws, async () => {\n\t\t\t\tconst { definition } = ws.data;\n\t\t\t\tconst socket = socketOf(ws);\n\t\t\t\tconst schema = definition.schema.message;\n\t\t\t\tlet message: unknown =\n\t\t\t\t\ttypeof raw === 'string' ? raw : new Uint8Array(raw);\n\t\t\t\tif (schema !== undefined) {\n\t\t\t\t\tconst parsed = parseMessage(message);\n\t\t\t\t\tif (!parsed.ok) {\n\t\t\t\t\t\tws.send(JSON.stringify(parsed.error));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst checked = await check(schema, parsed.value, 'message');\n\t\t\t\t\tif (!checked.ok) {\n\t\t\t\t\t\tconst error: ValidationErrorBody = {\n\t\t\t\t\t\t\terror: 'validation',\n\t\t\t\t\t\t\tissues: checked.issues,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tws.send(JSON.stringify(error));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tmessage = checked.value;\n\t\t\t\t}\n\t\t\t\tawait definition.handlers.message(socket as never, message as never);\n\t\t\t}),\n\t\tclose: (ws, code, reason) =>\n\t\t\tguard(ws, () =>\n\t\t\t\tws.data.definition.handlers.close?.(\n\t\t\t\t\tsocketOf(ws) as never,\n\t\t\t\t\tcode,\n\t\t\t\t\treason,\n\t\t\t\t),\n\t\t\t),\n\t\tdrain: (ws) =>\n\t\t\tguard(ws, () =>\n\t\t\t\tws.data.definition.handlers.drain?.(socketOf(ws) as never),\n\t\t\t),\n\t};\n}\n\nfunction parseMessage(\n\tmessage: unknown,\n):\n\t| { readonly ok: true; readonly value: unknown }\n\t| { readonly ok: false; readonly error: ValidationErrorBody } {\n\tif (typeof message !== 'string') return { ok: true, value: message };\n\ttry {\n\t\treturn { ok: true, value: JSON.parse(message) };\n\t} catch {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: {\n\t\t\t\terror: 'validation',\n\t\t\t\tissues: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttarget: 'message',\n\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\tcode: 'invalid_json',\n\t\t\t\t\t\tmessage: 'The message is not valid JSON',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t};\n\t}\n}\n\nfunction createSocket(\n\tws: Bun.ServerWebSocket<SocketData>,\n\tvalidate: boolean,\n): Socket<unknown, unknown> {\n\tconst schema: StandardSchemaV1 | undefined = ws.data.definition.schema.send;\n\tconst encode = async (message: unknown): Promise<string> => {\n\t\tif (schema === undefined || !validate) return JSON.stringify(message);\n\t\tconst checked = await check(schema, message, 'body');\n\t\tif (!checked.ok) {\n\t\t\tthrow new ResponseValidationError(\n\t\t\t\t'WS',\n\t\t\t\tws.data.definition.path,\n\t\t\t\t101,\n\t\t\t\tchecked.issues,\n\t\t\t);\n\t\t}\n\t\treturn JSON.stringify(checked.value);\n\t};\n\treturn {\n\t\tdata: ws.data.ctx,\n\t\tasync send(message) {\n\t\t\tws.send(await encode(message));\n\t\t},\n\t\tasync publish(topic, message) {\n\t\t\tws.publish(topic, await encode(message));\n\t\t},\n\t\tsubscribe: (topic) => ws.subscribe(topic),\n\t\tunsubscribe: (topic) => ws.unsubscribe(topic),\n\t\tisSubscribed: (topic) => ws.isSubscribed(topic),\n\t\tclose: (code, reason) => ws.close(code, reason),\n\t\traw: ws as Bun.ServerWebSocket<unknown>,\n\t};\n}\n",
27
+ "/**\n * The whole of a request: the global hooks around it, routing, then the\n * route's own run or the socket's upgrade.\n */\nimport { handle } from './chain';\nimport type { Definition, Runtime } from './definition';\nimport { internalError, routingError } from './send';\nimport { UPGRADED, upgradeSocket } from './socket';\nimport type { RequestContext } from './types';\n\n/** The whole of a request: global hooks around the route's own pipeline. */\nexport async function serve(\n\truntime: Runtime,\n\trequest: Request,\n\tserver: Bun.Server<unknown> | undefined,\n\tpath: string | undefined,\n): Promise<Response> {\n\tconst url = new URL(request.url);\n\tconst ctx: RequestContext = {\n\t\trequest,\n\t\turl,\n\t\tserver,\n\t\tip: runtime.ip(request, server),\n\t\troute: undefined,\n\t\terror: undefined,\n\t};\n\tconst around = runtime.globals.around;\n\tconst upgrade = request.headers.get('upgrade')?.toLowerCase() === 'websocket';\n\tif (around.length === 0 || upgrade) return pipeline(runtime, ctx, path);\n\tconst run = (index: number): Promise<Response> => {\n\t\tconst hook = around[index];\n\t\tif (hook === undefined) return pipeline(runtime, ctx, path);\n\t\treturn hook(ctx, () => run(index + 1));\n\t};\n\ttry {\n\t\treturn await run(0);\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\treturn internalError();\n\t}\n}\n\n/** The `onRequest` hooks, the route, then the `onResponse` hooks. */\nasync function pipeline(\n\truntime: Runtime,\n\tctx: RequestContext,\n\tpath: string | undefined,\n): Promise<Response> {\n\tlet response: Response | typeof UPGRADED | undefined;\n\ttry {\n\t\tfor (const hook of runtime.globals.onRequest) {\n\t\t\tlet early = hook(ctx);\n\t\t\tif (early instanceof Promise) early = await early;\n\t\t\tif (early instanceof Response) {\n\t\t\t\tresponse = early;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tresponse ??= await route(runtime, ctx, path);\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\tresponse = internalError();\n\t}\n\tif (response === UPGRADED) return undefined as never;\n\tfor (const hook of runtime.globals.onResponse) {\n\t\ttry {\n\t\t\tlet replaced = hook(response, ctx);\n\t\t\tif (replaced instanceof Promise) replaced = await replaced;\n\t\t\tif (replaced instanceof Response) response = replaced;\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n\treturn response;\n}\n\n/**\n * The route the request reached, run: the socket a `websocket` upgrade\n * asks for, a `GET` for a `HEAD` no route takes, or the 404, 405 or 426\n * when none answers.\n */\nasync function route(\n\truntime: Runtime,\n\tctx: RequestContext,\n\tpath: string | undefined,\n): Promise<Response | typeof UPGRADED> {\n\tconst { router, globals } = runtime;\n\tconst { request, url } = ctx;\n\tconst upgrade = request.headers.get('upgrade')?.toLowerCase() === 'websocket';\n\tconst find = (\n\t\tmethod: string,\n\t):\n\t\t| { readonly value: Definition; readonly params: Record<string, string> }\n\t\t| { readonly allowed: readonly string[] }\n\t\t| undefined => {\n\t\tif (path === undefined) {\n\t\t\tconst pages = globals.pages.size === 0 ? undefined : globals.pages.keys();\n\t\t\treturn router.match(method, url.pathname, pages);\n\t\t}\n\t\tconst methods = router.methodsAt(path);\n\t\tif (methods === undefined) return undefined;\n\t\tconst value = methods.get(method);\n\t\tif (value !== undefined) {\n\t\t\treturn { value, params: router.paramsAt(path, url.pathname) };\n\t\t}\n\t\treturn { allowed: [...methods.keys()] };\n\t};\n\n\tif (upgrade) {\n\t\tconst socket = find('WS');\n\t\tif (\n\t\t\tsocket !== undefined &&\n\t\t\t'value' in socket &&\n\t\t\tsocket.value.kind === 'ws'\n\t\t) {\n\t\t\t(ctx as { route: string | undefined }).route = socket.value.path;\n\t\t\treturn upgradeSocket(\n\t\t\t\tsocket.value,\n\t\t\t\tctx,\n\t\t\t\tsocket.params,\n\t\t\t\tglobals.parsers,\n\t\t\t\truntime.validateResponses,\n\t\t\t);\n\t\t}\n\t}\n\tlet match = find(request.method);\n\tlet head = false;\n\tif (request.method === 'HEAD' && match !== undefined && 'allowed' in match) {\n\t\tconst get = find('GET');\n\t\tif (get !== undefined && 'value' in get) {\n\t\t\tmatch = get;\n\t\t\thead = true;\n\t\t}\n\t}\n\tif (match === undefined) return routingError(404, 'not_found');\n\tif ('allowed' in match) {\n\t\tconst allowed = match.allowed.filter((method) => method !== 'WS');\n\t\tif (allowed.length === 0) return routingError(426, 'upgrade_required');\n\t\treturn routingError(405, 'method_not_allowed', allowed);\n\t}\n\tconst definition = match.value;\n\t(ctx as { route: string | undefined }).route = definition.path;\n\tif (definition.kind === 'ws') return routingError(426, 'upgrade_required');\n\tconst response = await handle(\n\t\tdefinition,\n\t\tctx,\n\t\tmatch.params,\n\t\tglobals.parsers,\n\t\truntime.validateResponses,\n\t);\n\treturn head\n\t\t? new Response(null, {\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t})\n\t\t: response;\n}\n",
28
+ "import type { Refusal } from '../errors/errors';\nimport type { AnyReply, Reply } from '../reply/reply';\nimport { checkLimit } from '../request/limit';\nimport type { BodyParser } from '../request/read';\nimport { joinPath, shapeOf } from '../router/paths';\nimport { Router } from '../router/router';\nimport { fileHandler, staticHandler } from '../static/serve';\nimport type {\n\tFileOptions,\n\tFileSource,\n\tStaticOptions,\n\tStaticReply,\n} from '../static/types';\nimport type { JoinPath, RoutePath } from '../types/path';\nimport type { ClientErrorStatus } from '../types/status';\nimport type {\n\tSocketContext,\n\tSocketEntryOf,\n\tSocketHandlers,\n\tSocketMessage,\n\tSocketSchema,\n\tSocketSend,\n} from '../ws/types';\nimport type {\n\tAroundHook,\n\tChainHook,\n\tDeriveHook,\n\tErrorHook,\n\tRefusalHandler,\n\tRefusalHook,\n\tRequestHook,\n\tResponseHook,\n\tRouteDefinition,\n\tRuntime,\n\tSocketDefinition,\n\tStartHook,\n\tStopHook,\n\tWrapHook,\n} from './definition';\nimport { serve } from './pipeline';\nimport type { OperationMethod, RouteOperation } from './route-operation';\nimport { type SocketData, websocketHandler } from './socket';\nimport type {\n\tBaseContext,\n\tBehindShortcuts,\n\tBodyLimitShortcut,\n\tContext,\n\tDeclaredRefusal,\n\tDeclaredReply,\n\tEmpty,\n\tHandlerResult,\n\tMaybePromise,\n\tMethod,\n\tOutcome,\n\tProvidedBy,\n\tRefusalResponses,\n\tRefusalSchema,\n\tRefusalsOf,\n\tRefusing,\n\tRouteEntryOf,\n\tRouteRecord,\n\tRouteSchema,\n\tThenShortcuts,\n\tTypedReplyFunction,\n\tValidSchema,\n} from './types';\n\n/** The route a static directory is served at: its path, then a wildcard. */\ntype StaticPath<Path extends string> = Path extends '/' ? '/*' : `${Path}/*`;\n\nexport interface AlxiaOptions<Prefix extends string> {\n\t/** Prepended to the path of every route declared on this app. */\n\treadonly prefix?: Prefix;\n\t/**\n\t * Whether a reply is checked against the schema its route declares for\n\t * its status, and sent as that schema's output: an unknown key the\n\t * schema strips never leaves the server. On by default; a reply that\n\t * fails is answered with a 500.\n\t */\n\treadonly validateResponses?: boolean;\n\t/**\n\t * Reads the client's address. By default, the address of the connection;\n\t * behind a proxy you trust, read its header instead.\n\t */\n\treadonly ip?: (\n\t\trequest: Request,\n\t\tserver: Bun.Server<unknown> | undefined,\n\t) => string | undefined;\n}\n\nexport interface ListenOptions {\n\treadonly port?: number | string;\n\treadonly hostname?: string;\n\treadonly development?: boolean;\n\treadonly idleTimeout?: number;\n\treadonly maxRequestBodySize?: number;\n\treadonly tls?: Bun.TLSOptions;\n}\n\n/** A route method: `app.get(path, schema, handler)` or `app.get(path, handler)`. */\nexport interface RouteMethod<\n\tM extends Method,\n\tCtx extends object,\n\tRoutes extends object,\n\tPrefix extends string,\n\tShortcuts extends AnyReply,\n> {\n\t<\n\t\tconst Path extends RoutePath,\n\t\tSchema extends RouteSchema,\n\t\tResult extends HandlerResult<Schema>,\n\t>(\n\t\tpath: Path,\n\t\tschema: Schema & ValidSchema<JoinPath<Prefix, Path>, Schema>,\n\t\thandler: (\n\t\t\tctx: Context<Ctx, JoinPath<Prefix, Path>, Schema>,\n\t\t) => MaybePromise<Result>,\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes & RouteEntryOf<M, JoinPath<Prefix, Path>, Schema, Result, Shortcuts>,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\t<const Path extends RoutePath, Result extends AnyReply>(\n\t\tpath: Path,\n\t\thandler: (\n\t\t\tctx: Context<Ctx, JoinPath<Prefix, Path>, Empty>,\n\t\t) => MaybePromise<Result>,\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes & RouteEntryOf<M, JoinPath<Prefix, Path>, Empty, Result, Shortcuts>,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n}\n\n/** The routes of a plugin, under the prefix of the app it is used by. */\ntype Prefixed<Prefix extends string, Routes, Shortcuts> = {\n\treadonly [Path in keyof Routes as Path extends string\n\t\t? JoinPath<Prefix, Path>\n\t\t: never]: {\n\t\treadonly [M in keyof Routes[Path]]: Routes[Path][M] extends RouteRecord<\n\t\t\tinfer Input,\n\t\t\tinfer Output\n\t\t>\n\t\t\t? RouteRecord<Input, BehindShortcuts<Output, Shortcuts>>\n\t\t\t: Routes[Path][M];\n\t};\n};\n\n/** Any app, whatever it holds. */\nexport type AnyAlxia = Alxia<any, any, any, any>;\n\n/**\n * A plugin written as a function: it receives the app and returns it, with\n * global hooks added. A plugin that adds to the context or declares routes\n * is an app of its own, given to `use`.\n */\nexport type Plugin = <App extends AnyAlxia>(app: App) => App;\n\n/**\n * An app: its routes, and the hooks they run.\n *\n * Every method returns the app itself, typed with what it added, so declare\n * it in one chain and export its type for the client:\n *\n * ```ts\n * const app = alxia()\n * .get('/users/:id', { params: UserId, response: { 200: User, 404: NotFound } },\n * ({ params, reply }) => { ... });\n * export type App = typeof app;\n * ```\n *\n * A route hook (`derive`, `decorate`, `onError`, `onRefusal`) applies to the routes\n * declared after it, never before: the order of the chain is the order of\n * the request. A global hook (`onRequest`, `onResponse`, `onStart`,\n * `onStop`, `parser`) applies to the whole app, wherever it is declared.\n */\nexport class Alxia<\n\tCtx extends object = Empty,\n\tRoutes extends object = Empty,\n\tPrefix extends string = '',\n\tShortcuts extends AnyReply = never,\n> {\n\t/** Never set: carries the route table to `typeof app`, which the client reads. */\n\tdeclare readonly '~routes': Routes;\n\t/** Never set: carries what a route declared next reads, for `ContextOf`. */\n\tdeclare readonly '~context': Ctx;\n\n\treadonly #prefix: string;\n\t/** The routes, the global hooks and the options a request is served with. */\n\t#runtime: Runtime;\n\treadonly #routes: RouteDefinition[] = [];\n\treadonly #sockets: SocketDefinition[] = [];\n\t#derive: ChainHook[] = [];\n\t#onError: ErrorHook[] = [];\n\t#refusal: RefusalHandler | undefined;\n\t/** The `bodyLimit` of the routes declared next, unless theirs says otherwise. */\n\t#bodyLimit: number | undefined;\n\t#server: Bun.Server<unknown> | undefined;\n\t#websocket: Bun.WebSocketHandler<SocketData> | undefined;\n\n\tconstructor(options: AlxiaOptions<Prefix> = {}) {\n\t\tthis.#prefix = options.prefix ?? '';\n\t\tthis.#runtime = {\n\t\t\trouter: new Router(),\n\t\t\tglobals: {\n\t\t\t\taround: [],\n\t\t\t\tonRequest: [],\n\t\t\t\tonResponse: [],\n\t\t\t\tonStart: [],\n\t\t\t\tonStop: [],\n\t\t\t\tparsers: [],\n\t\t\t\tpages: new Map(),\n\t\t\t},\n\t\t\tvalidateResponses: options.validateResponses ?? true,\n\t\t\tip:\n\t\t\t\toptions.ip ??\n\t\t\t\t((request, server) => server?.requestIP(request)?.address ?? undefined),\n\t\t};\n\t\tif (this.#prefix !== '' && !/^\\/.*[^/]$/.test(this.#prefix)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`The prefix \"${this.#prefix}\" must start with \"/\" and not end with one`,\n\t\t\t);\n\t\t}\n\t}\n\n\treadonly get = this.#method('GET') as RouteMethod<\n\t\t'GET',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly post = this.#method('POST') as RouteMethod<\n\t\t'POST',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly put = this.#method('PUT') as RouteMethod<\n\t\t'PUT',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly patch = this.#method('PATCH') as RouteMethod<\n\t\t'PATCH',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly delete = this.#method('DELETE') as RouteMethod<\n\t\t'DELETE',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly options = this.#method('OPTIONS') as RouteMethod<\n\t\t'OPTIONS',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\treadonly head = this.#method('HEAD') as RouteMethod<\n\t\t'HEAD',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\t/**\n\t * A route declared as data — `{ method, path, schema? }`, as an OpenAPI\n\t * code generator writes it — and its handler: the same route as\n\t * `app[method](path, schema, handler)`.\n\t */\n\treadonly route: OperationMethod<Ctx, Routes, Prefix, Shortcuts> = ((\n\t\toperation: RouteOperation,\n\t\thandler: RouteDefinition['handler'],\n\t) =>\n\t\tthis.#method(operation.method)(\n\t\t\toperation.path,\n\t\t\toperation.schema ?? {},\n\t\t\thandler,\n\t\t)) as never;\n\n\t/**\n\t * A `QUERY` route: a safe, idempotent read whose criteria travel in the\n\t * body, validated like a `POST`'s.\n\t */\n\treadonly query = this.#method('QUERY') as RouteMethod<\n\t\t'QUERY',\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts\n\t>;\n\n\t/**\n\t * A directory of files — or any `FileSource` — served under `path`: a\n\t * `GET` route at `path/*`, typed and documented like any other, every\n\t * hook around it.\n\t *\n\t * ```ts\n\t * app.static('/assets', './public', {\n\t * cacheControl: (path) => /\\.[0-9a-f]{8}\\./.test(path) ? 'public, max-age=31536000, immutable' : 'no-cache',\n\t * precompressed: ['br', 'gzip'],\n\t * });\n\t * app.static('/', './dist', { fallback: 'index.html' }); // a single-page app\n\t * ```\n\t *\n\t * A path that leaves the source, a dotfile, or no file is a 404. ETags\n\t * and `Last-Modified` answer 304s; a `Range` a 206.\n\t */\n\tstatic<const Path extends RoutePath>(\n\t\tpath: Path,\n\t\tsource: FileSource,\n\t\toptions: StaticOptions = {},\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes &\n\t\t\tRouteEntryOf<\n\t\t\t\t'GET',\n\t\t\t\tJoinPath<Prefix, StaticPath<Path>>,\n\t\t\t\tEmpty,\n\t\t\t\tStaticReply,\n\t\t\t\tShortcuts\n\t\t\t>,\n\t\tPrefix,\n\t\tShortcuts\n\t> {\n\t\tconst route = (path as string) === '/' ? '/*' : `${path}/*`;\n\t\t(this.get as unknown as (path: string, handler: unknown) => unknown)(\n\t\t\troute,\n\t\t\tstaticHandler(source, options),\n\t\t);\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * One file at `path`: a path on disk, read anew on each request, a `Blob`,\n\t * or a function answering one — `null` a 404. `/favicon.ico`,\n\t * `/robots.txt`, a generated sitemap.\n\t */\n\tfile<const Path extends RoutePath>(\n\t\tpath: Path,\n\t\tfile:\n\t\t\t| string\n\t\t\t| Blob\n\t\t\t| ((ctx: BaseContext & Ctx) => MaybePromise<Blob | null | undefined>),\n\t\toptions: FileOptions = {},\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes &\n\t\t\tRouteEntryOf<\n\t\t\t\t'GET',\n\t\t\t\tJoinPath<Prefix, Path>,\n\t\t\t\tEmpty,\n\t\t\t\tStaticReply,\n\t\t\t\tShortcuts\n\t\t\t>,\n\t\tPrefix,\n\t\tShortcuts\n\t> {\n\t\t(this.get as unknown as (path: string, handler: unknown) => unknown)(\n\t\t\tpath,\n\t\t\tfileHandler(file as Parameters<typeof fileHandler>[0], options),\n\t\t);\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A page of Bun's full-stack bundling: `import index from './index.html'`,\n\t * its scripts and styles bundled by Bun — with hot reloading under\n\t * `development` — and served by `Bun.serve` itself. So it needs `listen`,\n\t * and the app's hooks do not run around it; `app.fetch` answers it 404.\n\t */\n\tpage<const Path extends RoutePath>(path: Path, bundle: Bun.HTMLBundle): this {\n\t\tthis.#page(joinPath(this.#prefix, path), bundle);\n\t\treturn this;\n\t}\n\n\t#page(path: string, bundle: Bun.HTMLBundle): void {\n\t\tif (\n\t\t\tthis.#pageAt(path) !== undefined ||\n\t\t\tthis.#runtime.router.hasShape(path)\n\t\t) {\n\t\t\tthrow new TypeError(`page(): ${path} is already served`);\n\t\t}\n\t\tthis.#runtime.globals.pages.set(path, bundle);\n\t}\n\n\t/**\n\t * A WebSocket route. The upgrade request runs the hooks before it and is\n\t * validated as a route's; each message is then checked by `message`, and\n\t * each one sent by `send`. Open through `listen`, or a `Bun.serve` given\n\t * `fetch` and `websocket`: a socket needs a server.\n\t *\n\t * ```ts\n\t * app.ws('/rooms/:room', { message: Chat, send: Chat }, {\n\t * open: (socket) => socket.subscribe(socket.data.params.room),\n\t * message: (socket, chat) => socket.publish(socket.data.params.room, chat),\n\t * });\n\t * ```\n\t */\n\tws<const Path extends RoutePath, Schema extends SocketSchema = Empty>(\n\t\tpath: Path,\n\t\tschema: Schema,\n\t\thandlers: SocketHandlers<\n\t\t\tSocketContext<Ctx, JoinPath<Prefix, Path>, Schema>,\n\t\t\tSocketSend<Schema>,\n\t\t\tSocketMessage<Schema>\n\t\t>,\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes & SocketEntryOf<JoinPath<Prefix, Path>, Schema>,\n\t\tPrefix,\n\t\tShortcuts\n\t> {\n\t\tconst definition: SocketDefinition = {\n\t\t\tpath: joinPath(this.#prefix, path),\n\t\t\tschema,\n\t\t\thandlers: handlers as SocketDefinition['handlers'],\n\t\t\tderive: [...this.#derive],\n\t\t\tonError: [...this.#onError],\n\t\t\trefusal: this.#refusal,\n\t\t};\n\t\tthis.#mount(definition);\n\t\treturn this as never;\n\t}\n\n\t/** Values every route after this reads from its context: a database, a logger. */\n\tdecorate<const Values extends object>(\n\t\tvalues: Values,\n\t): Alxia<Ctx & Values, Routes, Prefix, Shortcuts> {\n\t\tthis.#derive.push({ kind: 'derive', run: () => values });\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A hook run on every request to a route declared after it, before the\n\t * request is validated. What it returns is added to the context; a reply\n\t * it returns ends the request, and is added to the type of every such\n\t * route, so the client reads it:\n\t *\n\t * ```ts\n\t * .derive(async ({ request, reply }) => {\n\t * const user = await authenticate(request);\n\t * return user ? { user } : reply(401, { error: 'unauthenticated' as const });\n\t * })\n\t * ```\n\t */\n\tderive<Result>(\n\t\thook: (ctx: BaseContext & Ctx) => MaybePromise<Result>,\n\t): Alxia<\n\t\tCtx &\n\t\t\t(Exclude<Result, AnyReply> extends infer Added extends object\n\t\t\t\t? Added\n\t\t\t\t: Empty),\n\t\tRoutes,\n\t\tPrefix,\n\t\tShortcuts | Extract<Result, AnyReply>\n\t> {\n\t\tthis.#derive.push({ kind: 'derive', run: hook as DeriveHook });\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A hook around every route declared after it: `next()` runs the rest —\n\t * the hooks declared after this one, validation, the handler — and\n\t * resolves to the response. The hook returns it, another `Response`, or\n\t * a reply of its own, which is added to the type of every such route.\n\t * An error the rest throws reaches it first. A socket's upgrade skips it.\n\t *\n\t * ```ts\n\t * .wrap(async ({ request, reply }, next) =>\n\t * (await locks.tryRun(request, next)) ?? reply(409, { error: 'busy' as const }))\n\t * ```\n\t */\n\twrap<Result extends AnyReply | Response>(\n\t\thook: (\n\t\t\tctx: BaseContext & Ctx,\n\t\t\tnext: () => Promise<Response>,\n\t\t) => MaybePromise<Result>,\n\t): Alxia<Ctx, Routes, Prefix, Shortcuts | Extract<Result, AnyReply>> {\n\t\tthis.#derive.push({ kind: 'wrap', run: hook as unknown as WrapHook });\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * The most bytes the request body of every route declared after it may\n\t * hold, unless the route's own `bodyLimit` says otherwise. Inside a\n\t * group, only the group's routes. A body past it is refused with a 413\n\t * as soon as its `Content-Length` or the bytes counted pass the limit,\n\t * which is added to the type of every such route.\n\t *\n\t * ```ts\n\t * alxia()\n\t * .bodyLimit(64 * 1024) // every route below: 64 KiB\n\t * .post('/notes', { body: Note }, handler)\n\t * .post('/upload', { bodyLimit: 25 * 1024 * 1024 }, handler); // its own\n\t * ```\n\t */\n\tbodyLimit(\n\t\tbytes: number,\n\t): Alxia<Ctx, Routes, Prefix, Shortcuts | BodyLimitShortcut> {\n\t\tthis.#bodyLimit = checkLimit(bytes, 'bodyLimit()');\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A hook that turns an error thrown by a route declared after it into a\n\t * reply. Returning nothing lets the next one try; past the last, an\n\t * `HttpError` is answered as it says and anything else as a 500.\n\t */\n\tonError<Result extends AnyReply | undefined | void>(\n\t\thook: (\n\t\t\terror: unknown,\n\t\t\tctx: BaseContext & Partial<Ctx>,\n\t\t) => MaybePromise<Result>,\n\t): Alxia<Ctx, Routes, Prefix, Shortcuts | Extract<Result, AnyReply>> {\n\t\tthis.#onError.push(hook as unknown as ErrorHook);\n\t\treturn this as never;\n\t}\n\n\t/**\n\t * A hook that answers a request a route declared after it refuses\n\t * before its handler runs: one its schemas refuse, the default of which\n\t * is `400 { error: 'validation', issues }`, or one whose body passes its\n\t * `bodyLimit`, the default of which is\n\t * `413 { error: 'content_too_large', limit }`. The hook reads\n\t * the refusal — its `kind`: `validation`, with the `part` that failed\n\t * and the `issues`, or `body_limit`, with the route's `limit` — and\n\t * returns a reply with a 4xx status, or nothing for that kind's default.\n\t * The last one declared before a route is the one in force; a group's\n\t * stays inside it. Its reply replaces the default 400 in the type of\n\t * every such route that validates, so the client reads it:\n\t *\n\t * ```ts\n\t * .onRefusal((refusal) => refusal.kind === 'validation'\n\t * ? problem({ type: 'urn:example:invalid', status: 400, detail: `the ${refusal.part} is invalid` })\n\t * : problem({ type: 'urn:example:limit', status: 413, limit: refusal.limit }))\n\t * ```\n\t *\n\t * Given schemas first, its `reply` is typed by them, its reply is\n\t * checked and sent as their output, and `@alxia/openapi` documents it:\n\t *\n\t * ```ts\n\t * .onRefusal({ response: { 400: Problem }, contentType: 'application/problem+json' },\n\t * (refusal, { reply }) => reply(400, { type: 'urn:example:invalid', status: 400, detail: refusal.kind }))\n\t * ```\n\t */\n\tonRefusal<Result extends Reply<ClientErrorStatus, any> | undefined | void>(\n\t\thook: (refusal: Refusal, ctx: BaseContext & Ctx) => MaybePromise<Result>,\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\tExclude<Shortcuts, Refusing> | RefusalsOf<Extract<Result, AnyReply>, Result>\n\t>;\n\tonRefusal<\n\t\tResponses extends RefusalResponses,\n\t\tResult extends DeclaredReply<Responses> | undefined | void,\n\t>(\n\t\tschema: RefusalSchema<Responses>,\n\t\thook: (\n\t\t\trefusal: Refusal,\n\t\t\tctx: Omit<BaseContext, 'reply'> &\n\t\t\t\tCtx & { readonly reply: TypedReplyFunction<Responses> },\n\t\t) => MaybePromise<Result>,\n\t): Alxia<\n\t\tCtx,\n\t\tRoutes,\n\t\tPrefix,\n\t\t| Exclude<Shortcuts, Refusing>\n\t\t| RefusalsOf<DeclaredRefusal<Responses>, Result>\n\t>;\n\tonRefusal(\n\t\tschemaOrHook: RefusalSchema | ((refusal: Refusal, ctx: never) => unknown),\n\t\tmaybeHook?: (refusal: Refusal, ctx: never) => unknown,\n\t): AnyAlxia {\n\t\tif (typeof schemaOrHook === 'function') {\n\t\t\tthis.#refusal = { hook: schemaOrHook as RefusalHook };\n\t\t\treturn this;\n\t\t}\n\t\tif (typeof maybeHook !== 'function') {\n\t\t\tthrow new TypeError('onRefusal(): the hook is missing');\n\t\t}\n\t\tthis.#refusal = {\n\t\t\thook: maybeHook as RefusalHook,\n\t\t\tresponse: schemaOrHook.response,\n\t\t\t...(schemaOrHook.contentType === undefined\n\t\t\t\t? {}\n\t\t\t\t: { contentType: schemaOrHook.contentType }),\n\t\t};\n\t\treturn this;\n\t}\n\n\t/**\n\t * A global hook run on every request, before routing: a 404 included. A\n\t * `Response` it returns is sent as it is, and is no part of any route's\n\t * type: use it for what a typed client never asks — a CORS preflight, a\n\t * redirect to HTTPS. What a client must read belongs in `derive`.\n\t */\n\tonRequest(hook: RequestHook): this {\n\t\tthis.#runtime.globals.onRequest.push(hook);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A global hook run on every response, in the order declared: headers,\n\t * compression, logging. A `Response` it returns replaces the one sent;\n\t * keep its status, which the client's types promise.\n\t */\n\tonResponse(hook: ResponseHook): this {\n\t\tthis.#runtime.globals.onResponse.push(hook);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A global hook around every request, the first declared outermost.\n\t * `next()` runs everything else and resolves to the response; the hook\n\t * returns it, or another. A socket's upgrade runs outside it: there is no\n\t * response to wrap.\n\t *\n\t * ```ts\n\t * app.around(async (ctx, next) => {\n\t * const started = performance.now();\n\t * const response = await next();\n\t * console.log(ctx.route, performance.now() - started);\n\t * return response;\n\t * });\n\t * ```\n\t */\n\taround(hook: AroundHook): this {\n\t\tthis.#runtime.globals.around.push(hook);\n\t\treturn this;\n\t}\n\n\t/** Runs once `listen` has started the server. */\n\tonStart(hook: StartHook): this {\n\t\tthis.#runtime.globals.onStart.push(hook);\n\t\treturn this;\n\t}\n\n\t/** Runs when `stop` stops the server: close a pool, flush a log. */\n\tonStop(hook: StopHook): this {\n\t\tthis.#runtime.globals.onStop.push(hook);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Reads a body of `type` — a `content-type` prefix, or a pattern — for\n\t * every route with a `body` schema, before the built-in JSON, form and\n\t * text parsers.\n\t */\n\tparser(type: string | RegExp, parse: BodyParser['parse']): this {\n\t\tthis.#runtime.globals.parsers.push({ type, parse });\n\t\treturn this;\n\t}\n\n\t/**\n\t * Routes declared in a scope: the hooks `build` adds apply only to them.\n\t * The routes keep every hook declared on this app before the group.\n\t *\n\t * ```ts\n\t * app.group('/admin', (admin) => admin.derive(requireAdmin).get('/stats', ...));\n\t * ```\n\t */\n\tgroup<\n\t\tconst Path extends RoutePath,\n\t\tGroupRoutes extends object,\n\t\tGroupCtx extends object,\n\t\tGroupShortcuts extends AnyReply,\n\t>(\n\t\tprefix: Path,\n\t\tbuild: (\n\t\t\tgroup: Alxia<Ctx, Empty, JoinPath<Prefix, Path>, Shortcuts>,\n\t\t) => Alxia<GroupCtx, GroupRoutes, JoinPath<Prefix, Path>, GroupShortcuts>,\n\t): Alxia<Ctx, Routes & GroupRoutes, Prefix, Shortcuts>;\n\tgroup<\n\t\tGroupRoutes extends object,\n\t\tGroupCtx extends object,\n\t\tGroupShortcuts extends AnyReply,\n\t>(\n\t\tbuild: (\n\t\t\tgroup: Alxia<Ctx, Empty, Prefix, Shortcuts>,\n\t\t) => Alxia<GroupCtx, GroupRoutes, Prefix, GroupShortcuts>,\n\t): Alxia<Ctx, Routes & GroupRoutes, Prefix, Shortcuts>;\n\tgroup(\n\t\tprefixOrBuild: string | ((group: AnyAlxia) => AnyAlxia),\n\t\tmaybeBuild?: (group: AnyAlxia) => AnyAlxia,\n\t): AnyAlxia {\n\t\tconst [prefix, build] =\n\t\t\ttypeof prefixOrBuild === 'string'\n\t\t\t\t? [joinPath(this.#prefix, prefixOrBuild), maybeBuild]\n\t\t\t\t: [this.#prefix, prefixOrBuild];\n\t\tif (build === undefined) throw new TypeError('group(): build is missing');\n\t\tconst child = new Alxia({\n\t\t\tprefix,\n\t\t\tvalidateResponses: this.#runtime.validateResponses,\n\t\t});\n\t\tchild.#derive = [...this.#derive];\n\t\tchild.#onError = [...this.#onError];\n\t\tchild.#refusal = this.#refusal;\n\t\tchild.#bodyLimit = this.#bodyLimit;\n\t\tchild.#runtime = { ...child.#runtime, globals: this.#runtime.globals };\n\t\tconst before = new Set(this.#runtime.globals.pages.keys());\n\t\tconst built = build(child);\n\t\t// The child checks its pages against its own routes only.\n\t\tfor (const path of this.#runtime.globals.pages.keys()) {\n\t\t\tif (!before.has(path) && this.#runtime.router.hasShape(path)) {\n\t\t\t\tthrow new TypeError(`page(): ${path} is already served`);\n\t\t\t}\n\t\t}\n\t\tfor (const route of built.routes) this.#register(route);\n\t\tfor (const socket of built.sockets) this.#mount(socket);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A plugin. An app: its routes, under this app's prefix and behind this\n\t * app's hooks, and its hooks, which then apply to the routes declared on\n\t * this app after it — a plugin can be an `auth` that only derives a\n\t * `user`. Its global hooks become this app's. It is read once, here:\n\t * declare it completely before using it. A plugin made by `definePlugin`\n\t * names what it reads from this app's context: using it on an app that\n\t * does not give it is a compile error.\n\t *\n\t * Or a function, given this app, that returns it: a `Plugin`.\n\t */\n\tuse<Result extends AnyAlxia>(plugin: (app: this) => Result): Result;\n\tuse<\n\t\tPluginCtx extends object,\n\t\tPluginRoutes extends object,\n\t\tPluginPrefix extends string,\n\t\tPluginShortcuts extends AnyReply,\n\t\tPluginRequires = Empty,\n\t>(\n\t\tplugin: Alxia<PluginCtx, PluginRoutes, PluginPrefix, PluginShortcuts> & {\n\t\t\treadonly '~requires'?: PluginRequires;\n\t\t} & ProvidedBy<Ctx, PluginRequires>,\n\t): Alxia<\n\t\tCtx & PluginCtx,\n\t\tRoutes & Prefixed<Prefix, PluginRoutes, Shortcuts>,\n\t\tPrefix,\n\t\tThenShortcuts<Shortcuts, PluginShortcuts>\n\t>;\n\tuse(plugin: AnyAlxia | ((app: any) => AnyAlxia)): AnyAlxia {\n\t\tif (!(plugin instanceof Alxia)) return plugin(this);\n\t\tfor (const route of plugin.routes) {\n\t\t\tthis.#register({\n\t\t\t\t...route,\n\t\t\t\tpath: joinPath(this.#prefix, route.path),\n\t\t\t\tderive: [...this.#derive, ...route.derive],\n\t\t\t\tonError: [...route.onError, ...this.#onError],\n\t\t\t\trefusal: route.refusal ?? this.#refusal,\n\t\t\t});\n\t\t}\n\t\tfor (const socket of plugin.sockets) {\n\t\t\tthis.#mount({\n\t\t\t\t...socket,\n\t\t\t\tpath: joinPath(this.#prefix, socket.path),\n\t\t\t\tderive: [...this.#derive, ...socket.derive],\n\t\t\t\tonError: [...socket.onError, ...this.#onError],\n\t\t\t\trefusal: socket.refusal ?? this.#refusal,\n\t\t\t});\n\t\t}\n\t\tthis.#derive = [...this.#derive, ...plugin.#derive];\n\t\tthis.#onError = [...plugin.#onError, ...this.#onError];\n\t\tthis.#refusal = plugin.#refusal ?? this.#refusal;\n\t\tthis.#bodyLimit = plugin.#bodyLimit ?? this.#bodyLimit;\n\t\tif (plugin.#runtime.globals !== this.#runtime.globals) {\n\t\t\tconst globals = plugin.#runtime.globals;\n\t\t\tthis.#runtime.globals.around.push(...globals.around);\n\t\t\tthis.#runtime.globals.onRequest.push(...globals.onRequest);\n\t\t\tthis.#runtime.globals.onResponse.push(...globals.onResponse);\n\t\t\tthis.#runtime.globals.onStart.push(...globals.onStart);\n\t\t\tthis.#runtime.globals.onStop.push(...globals.onStop);\n\t\t\tthis.#runtime.globals.parsers.push(...globals.parsers);\n\t\t\tfor (const [path, bundle] of globals.pages) {\n\t\t\t\tthis.#page(joinPath(this.#prefix, path), bundle);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/** Every route, in the order declared: what `@alxia/openapi` documents. */\n\tget routes(): readonly RouteDefinition[] {\n\t\treturn this.#routes;\n\t}\n\n\t/** Every socket route, in the order declared. */\n\tget sockets(): readonly SocketDefinition[] {\n\t\treturn this.#sockets;\n\t}\n\n\t/** The server `listen` started, until `stop`. */\n\tget server(): Bun.Server<unknown> | undefined {\n\t\treturn this.#server;\n\t}\n\n\t/**\n\t * The app as a fetch handler: what `Bun.serve`, a test, or another\n\t * runtime calls. Bound, so `export default { fetch: app.fetch }` works.\n\t * Given the server, as `Bun.serve` gives it, it can open a socket.\n\t */\n\treadonly fetch = (\n\t\trequest: Request,\n\t\tserver?: Bun.Server<unknown>,\n\t): Promise<Response> => serve(this.#runtime, request, server, undefined);\n\n\t/**\n\t * The `websocket` handler `Bun.serve` opens this app's sockets with, beside\n\t * `fetch`: what `listen` passes, for a server started otherwise.\n\t *\n\t * ```ts\n\t * Bun.serve({ fetch: app.fetch, websocket: app.websocket });\n\t * ```\n\t */\n\tget websocket(): Bun.WebSocketHandler<SocketData> {\n\t\tthis.#websocket ??= websocketHandler(this.#runtime.validateResponses);\n\t\treturn this.#websocket;\n\t}\n\n\t/** A request to the app, in process: `app.request('/users/1')`. */\n\trequest(path: string, init?: RequestInit): Promise<Response> {\n\t\treturn this.fetch(new Request(new URL(path, 'http://localhost'), init));\n\t}\n\n\t/**\n\t * `Bun.serve` with this app: its paths go to Bun's own router, and what\n\t * none of them matches to `fetch`, which answers 404 or 405.\n\t *\n\t * Bun matches the request's target as it came, `/f/../a` and all, where\n\t * `fetch` reads its URL's pathname, `/a`. A path without parameters is\n\t * matched by Bun only by a target already in that form, so its route\n\t * answers; a request Bun gives to a path with parameters or a wildcard\n\t * is routed again as `fetch` routes it, so both choose alike, at the\n\t * cost of `fetch`'s routing on each such request.\n\t */\n\tlisten(options: ListenOptions | number = {}): Bun.Server<unknown> {\n\t\tconst settings = typeof options === 'number' ? { port: options } : options;\n\t\tconst routes: Record<\n\t\t\tstring,\n\t\t\t| Bun.HTMLBundle\n\t\t\t| ((request: Request, server: Bun.Server<unknown>) => Promise<Response>)\n\t\t> = {};\n\t\tfor (const [path] of this.#runtime.router.paths()) {\n\t\t\tconst routed = this.#runtime.router.isFixed(path) ? path : undefined;\n\t\t\troutes[path] = (request, server) =>\n\t\t\t\tserve(this.#runtime, request, server, routed);\n\t\t}\n\t\tfor (const [path, bundle] of this.#runtime.globals.pages) {\n\t\t\troutes[path] = bundle;\n\t\t}\n\t\tconst server = Bun.serve({\n\t\t\t...settings,\n\t\t\troutes,\n\t\t\tfetch: (request: Request, server: Bun.Server<unknown>) =>\n\t\t\t\tserve(this.#runtime, request, server, undefined),\n\t\t\twebsocket: this.websocket,\n\t\t} as Bun.Serve.Options<SocketData>) as Bun.Server<unknown>;\n\t\tthis.#server = server;\n\t\tfor (const hook of this.#runtime.globals.onStart) {\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => hook(server))\n\t\t\t\t.catch((error) => console.error(error));\n\t\t}\n\t\treturn server;\n\t}\n\n\t/** Stops the server `listen` started, then runs every `onStop` hook. */\n\tasync stop(closeActiveConnections = false): Promise<void> {\n\t\tconst server = this.#server;\n\t\tthis.#server = undefined;\n\t\tif (server !== undefined) await server.stop(closeActiveConnections);\n\t\tfor (const hook of this.#runtime.globals.onStop) await hook();\n\t}\n\n\t#method(method: Method) {\n\t\treturn (\n\t\t\tpath: string,\n\t\t\tschemaOrHandler: RouteSchema | RouteDefinition['handler'],\n\t\t\tmaybeHandler?: RouteDefinition['handler'],\n\t\t) => {\n\t\t\tconst [schema, handler] =\n\t\t\t\ttypeof schemaOrHandler === 'function'\n\t\t\t\t\t? [{}, schemaOrHandler]\n\t\t\t\t\t: [schemaOrHandler, maybeHandler];\n\t\t\tif (typeof handler !== 'function') {\n\t\t\t\tthrow new TypeError(`${method} ${path}: the handler is missing`);\n\t\t\t}\n\t\t\tconst full = joinPath(this.#prefix, path);\n\t\t\tconst bodyLimit =\n\t\t\t\tschema.bodyLimit === undefined\n\t\t\t\t\t? this.#bodyLimit\n\t\t\t\t\t: checkLimit(schema.bodyLimit, `${method} ${full}`);\n\t\t\tthis.#register({\n\t\t\t\tmethod,\n\t\t\t\tpath: full,\n\t\t\t\tschema,\n\t\t\t\t...(bodyLimit === undefined ? {} : { bodyLimit }),\n\t\t\t\thandler,\n\t\t\t\tderive: [...this.#derive],\n\t\t\t\tonError: [...this.#onError],\n\t\t\t\trefusal: this.#refusal,\n\t\t\t});\n\t\t\treturn this;\n\t\t};\n\t}\n\n\t#register(route: RouteDefinition): void {\n\t\tthis.#refusePage(route.method, route.path);\n\t\tthis.#runtime.router.add(route.method, route.path, {\n\t\t\tkind: 'http',\n\t\t\t...route,\n\t\t});\n\t\tthis.#routes.push(route);\n\t}\n\n\t/** `listen` serves a page before any route at its path: refuse the route. */\n\t#refusePage(method: string, path: string): void {\n\t\tif (this.#pageAt(path) !== undefined) {\n\t\t\tthrow new TypeError(`${method} ${path} is already served by a page`);\n\t\t}\n\t}\n\n\t/** The page declared at a path of the same shape as `path`. */\n\t#pageAt(path: string): string | undefined {\n\t\tconst shape = shapeOf(path);\n\t\tfor (const page of this.#runtime.globals.pages.keys()) {\n\t\t\tif (shapeOf(page) === shape) return page;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t#mount(socket: SocketDefinition): void {\n\t\tthis.#refusePage('WS', socket.path);\n\t\tthis.#runtime.router.add('WS', socket.path, { kind: 'ws', ...socket });\n\t\tthis.#sockets.push(socket);\n\t}\n}\n\n/** A new app. */\nexport function alxia<const Prefix extends '' | RoutePath = ''>(\n\toptions: AlxiaOptions<Prefix> = {},\n): Alxia<Empty, Empty, Prefix, never> {\n\treturn new Alxia(options);\n}\n\n/** The route table of an app, as the client reads it. */\nexport type RoutesOf<App> = App extends { readonly '~routes': infer Routes }\n\t? Routes\n\t: never;\n\n/**\n * What a route declared next on `App` reads: the context its hooks build —\n * `decorate`, `derive`, every plugin's — on top of the base context. A\n * GraphQL schema, a service, types its own context with it.\n */\nexport type ContextOf<App> = App extends { readonly '~context': infer Ctx }\n\t? BaseContext & Ctx\n\t: never;\n\nexport type { Outcome };\n",
29
+ "import { type Alxia, type AnyAlxia, alxia } from './alxia';\nimport type { Empty, Requiring } from './types';\n\n/**\n * A plugin that reads what an earlier one added to the context. Name what it\n * needs, then build it on an app whose context already has it:\n *\n * ```ts\n * const tenant = definePlugin<{ user: { tenantId: string } }>()((app) =>\n * app.derive(({ user }) => ({ tenant: tenants.get(user.tenantId) })),\n * );\n *\n * alxia().use(auth).use(tenant); // compiles: auth derives a user, or answers 401\n * alxia().use(tenant); // a compile error: this app gives no `user`\n * ```\n *\n * The plugin is an app, given to `use` like any other, built once, here.\n * `use` checks the app's context against `Requires`, so the plugin's hooks\n * never run without what they read.\n */\nexport function definePlugin<Requires extends object = Empty>() {\n\treturn <Plugin extends AnyAlxia>(\n\t\tbuild: (app: Alxia<Requires>) => Plugin,\n\t): Plugin & Requiring<Requires> =>\n\t\tbuild(alxia() as unknown as Alxia<Requires>) as Plugin &\n\t\t\tRequiring<Requires>;\n}\n",
30
+ "/**\n * Problem details for HTTP APIs (RFC 9457, which obsoletes RFC 7807): a\n * JSON body sent as `application/problem+json`.\n */\nimport type { ClientErrorStatus, ServerErrorStatus } from '../types/status';\nimport { Reply, type ReplyInit } from './reply';\n\n/**\n * The members RFC 9457 defines. A problem may carry members of its own\n * beside them, its extensions: `problem()` keeps their types.\n */\nexport interface ProblemDetails<\n\tStatus extends ClientErrorStatus | ServerErrorStatus =\n\t\t| ClientErrorStatus\n\t\t| ServerErrorStatus,\n> {\n\t/** A URI naming the problem type; absent, it is `about:blank`. */\n\treadonly type?: string;\n\t/** A short summary of the problem type, the same for every occurrence. */\n\treadonly title?: string;\n\t/** The status of the response, which `problem()` replies with. */\n\treadonly status: Status;\n\t/** What went wrong with this occurrence. */\n\treadonly detail?: string;\n\t/** A URI naming this occurrence. */\n\treadonly instance?: string;\n}\n\n/**\n * A reply whose body is a problem, with `status` as its status and\n * `content-type: application/problem+json` unless `init` sets one. Any\n * other member is an extension, kept as given and in the body's type:\n *\n * ```ts\n * problem({ type: 'urn:ietf:params:jmap:error:limit', status: 413, limit: 'maxSizeRequest' });\n * ```\n */\nexport function problem<const Body extends ProblemDetails>(\n\tbody: Body,\n\tinit?: ReplyInit,\n): Reply<Body['status'], Body> {\n\tconst headers = new Headers(init?.headers);\n\tif (!headers.has('content-type')) {\n\t\theaders.set('content-type', 'application/problem+json');\n\t}\n\treturn new Reply(body.status, body, { ...init, headers });\n}\n"
24
31
  ],
25
- "mappings": ";AAgBA,IAAM,UAAU;AAChB,IAAM,YAAY;AAClB,IAAM,WAAW;AAeV,SAAS,WAAW,CAAC,MAA4B;AAAA,EACvD,IAAI,CAAC,KAAK,WAAW,GAAG,GAAG;AAAA,IAC1B,MAAM,IAAI,UAAU,mBAAmB,2BAA2B;AAAA,EACnE;AAAA,EACA,MAAM,QAAkB,CAAC;AAAA,EACzB,MAAM,WAAW,KAAK,MAAM,GAAG,EAAE,MAAM,CAAC;AAAA,EACxC,MAAM,QAAkB,CAAC;AAAA,EACzB,IAAI,SAAS;AAAA,EACb,IAAI,SAAS;AAAA,EACb,IAAI,QAAQ;AAAA,EAEZ,IAAI,cAAc;AAAA,EAClB,IAAI,YAAY;AAAA,EAChB,SAAS,QAAQ,CAAC,SAAS,UAAU;AAAA,IACpC,IAAI,YAAY,KAAK;AAAA,MACpB,IAAI,UAAU,SAAS,SAAS,GAAG;AAAA,QAClC,MAAM,IAAI,UAAU,IAAI,gCAAgC;AAAA,MACzD;AAAA,MACA,MAAM,KAAK,GAAG;AAAA,MACd,MAAM,KAAK,QAAQ;AAAA,MACnB,UAAU;AAAA,MACV,UAAU;AAAA,MACV,SAAS;AAAA,MACT,eAAe;AAAA,IAChB,EAAO,SAAI,QAAQ,WAAW,GAAG,GAAG;AAAA,MACnC,MAAM,OAAO,QAAQ,MAAM,CAAC;AAAA,MAC5B,IAAI,CAAC,qBAAqB,KAAK,IAAI,GAAG;AAAA,QACrC,MAAM,IAAI,UAAU,IAAI,YAAY,+BAA+B;AAAA,MACpE;AAAA,MACA,IAAI,MAAM,SAAS,IAAI,GAA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