routup 5.0.0-beta.2 → 5.0.0-beta.3

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-Tr9cHQaV.mjs","names":[],"sources":["../src/constants.ts","../src/response/helpers/cache.ts","../src/error/module.ts","../src/response/helpers/event-stream/utils.ts","../src/response/helpers/event-stream/module.ts","../src/utils/header.ts","../src/utils/object.ts","../src/utils/etag/module.ts","../src/utils/etag/utils.ts","../src/utils/trust-proxy/module.ts","../src/utils/is-instance.ts","../src/utils/mime.ts","../src/utils/method.ts","../src/utils/path.ts","../src/utils/url.ts","../src/response/helpers/header.ts","../src/response/helpers/utils.ts","../src/response/helpers/header-attachment.ts","../src/response/helpers/header-content-type.ts","../src/response/to-response.ts","../src/response/helpers/send-accepted.ts","../src/response/helpers/send-created.ts","../src/response/helpers/send-file.ts","../src/request/helpers/header.ts","../src/request/helpers/negotiator.ts","../src/request/helpers/header-accept.ts","../src/response/helpers/send-format.ts","../src/response/helpers/send-redirect.ts","../src/response/helpers/send-stream.ts","../src/event/module.ts","../src/dispatcher/module.ts","../src/error/is.ts","../src/error/create.ts","../src/handler/constants.ts","../src/hook/constants.ts","../src/hook/module.ts","../src/path/matcher.ts","../src/path/utils.ts","../src/handler/module.ts","../src/handler/core/define.ts","../src/handler/error/define.ts","../src/handler/adapters/node/define.ts","../src/handler/adapters/web/is.ts","../src/handler/adapters/web/define.ts","../src/handler/is.ts","../src/request/helpers/body.ts","../src/request/helpers/cache.ts","../src/request/helpers/header-accept-charset.ts","../src/request/helpers/header-accept-encoding.ts","../src/request/helpers/header-accept-language.ts","../src/request/helpers/header-content-type.ts","../src/request/helpers/hostname.ts","../src/request/helpers/ip.ts","../src/request/helpers/protocol.ts","../src/plugin/is.ts","../src/router/options.ts","../src/router/constants.ts","../src/router/utils.ts","../src/router/module.ts"],"sourcesContent":["export enum MethodName {\n GET = 'GET',\n POST = 'POST',\n PUT = 'PUT',\n PATCH = 'PATCH',\n DELETE = 'DELETE',\n OPTIONS = 'OPTIONS',\n HEAD = 'HEAD',\n}\n\nexport enum HeaderName {\n ACCEPT = 'accept',\n ACCEPT_CHARSET = 'accept-charset',\n ACCEPT_ENCODING = 'accept-encoding',\n ACCEPT_LANGUAGE = 'accept-language',\n ACCEPT_RANGES = 'accept-ranges',\n ALLOW = 'allow',\n CACHE_CONTROL = 'cache-control',\n CONTENT_DISPOSITION = 'content-disposition',\n CONTENT_ENCODING = 'content-encoding',\n CONTENT_LENGTH = 'content-length',\n CONTENT_RANGE = 'content-range',\n CONTENT_TYPE = 'content-type',\n CONNECTION = 'connection',\n COOKIE = 'cookie',\n ETag = 'etag',\n HOST = 'host',\n IF_MODIFIED_SINCE = 'if-modified-since',\n IF_NONE_MATCH = 'if-none-match',\n LAST_MODIFIED = 'last-modified',\n LOCATION = 'location',\n RANGE = 'range',\n RATE_LIMIT_LIMIT = 'ratelimit-limit',\n RATE_LIMIT_REMAINING = 'ratelimit-remaining',\n RATE_LIMIT_RESET = 'ratelimit-reset',\n RETRY_AFTER = 'retry-after',\n SET_COOKIE = 'set-cookie',\n TRANSFER_ENCODING = 'transfer-encoding',\n X_ACCEL_BUFFERING = 'x-accel-buffering',\n X_FORWARDED_HOST = 'x-forwarded-host',\n X_FORWARDED_FOR = 'x-forwarded-for',\n X_FORWARDED_PROTO = 'x-forwarded-proto',\n}\n","import type { IRoutupEvent } from '../../event/index.ts';\n\nexport type ResponseCacheHeadersOptions = {\n maxAge?: number,\n modifiedTime?: string | Date,\n cacheControls?: string[]\n};\n\nexport function setResponseCacheHeaders(event: IRoutupEvent, options?: ResponseCacheHeadersOptions) {\n options = options || {};\n\n const cacheControls = ['public'].concat(options.cacheControls || []);\n\n if (options.maxAge !== undefined) {\n cacheControls.push(`max-age=${+options.maxAge}`, `s-maxage=${+options.maxAge}`);\n }\n\n if (options.modifiedTime) {\n const modifiedTime = typeof options.modifiedTime === 'string' ?\n new Date(options.modifiedTime) :\n options.modifiedTime;\n\n event.response.headers.set('last-modified', modifiedTime.toUTCString());\n }\n\n event.response.headers.set('cache-control', cacheControls.join(', '));\n}\n","import { HTTPError } from '@ebec/http';\nimport type { HTTPErrorInput } from '@ebec/http';\n\nexport type { HTTPErrorInput };\n\nexport class RoutupError extends HTTPError {\n constructor(input: HTTPErrorInput = {}) {\n super(input);\n this.name = 'RoutupError';\n }\n}\n","import type { EventStreamMessage } from './types.ts';\n\nfunction stripNewlines(value: string) : string {\n return value.replace(/[\\r\\n]/g, '');\n}\n\nexport function serializeEventStreamMessage(message: EventStreamMessage): string {\n let result = '';\n\n if (message.id) {\n result += `id: ${stripNewlines(message.id)}\\n`;\n }\n\n if (message.event) {\n result += `event: ${stripNewlines(message.event)}\\n`;\n }\n\n if (\n typeof message.retry === 'number' &&\n Number.isInteger(message.retry)\n ) {\n result += `retry: ${message.retry}\\n`;\n }\n\n const lines = message.data.replace(/\\r/g, '').split('\\n');\n for (const line of lines) {\n result += `data: ${line}\\n`;\n }\n result += '\\n';\n\n return result;\n}\n","import { HeaderName } from '../../../constants.ts';\nimport type { IRoutupEvent } from '../../../event/index.ts';\nimport { RoutupError } from '../../../error/module.ts';\nimport type { EventStreamMessage } from './types.ts';\nimport { serializeEventStreamMessage } from './utils.ts';\n\nexport type EventStreamOptions = {\n maxMessageSize?: number,\n};\n\nexport type EventStreamHandle = {\n write(message: string | EventStreamMessage): void;\n end(): void;\n response: Response;\n};\n\nexport function createEventStream(\n event: IRoutupEvent,\n options?: EventStreamOptions,\n): EventStreamHandle {\n if (options?.maxMessageSize !== undefined) {\n if (!Number.isInteger(options.maxMessageSize) || options.maxMessageSize < 0) {\n throw new RoutupError('maxMessageSize must be a non-negative integer.');\n }\n }\n\n let controller: ReadableStreamDefaultController<Uint8Array>;\n let closed = false;\n const encoder = new TextEncoder();\n\n const stream = new ReadableStream<Uint8Array>({\n start(ctrl) {\n controller = ctrl;\n },\n cancel() {\n closed = true;\n },\n });\n\n const headers = new Headers(event.response.headers);\n headers.set(HeaderName.CONTENT_TYPE, 'text/event-stream');\n headers.set(HeaderName.CACHE_CONTROL, 'private, no-cache, no-store, no-transform, must-revalidate, max-age=0');\n headers.set(HeaderName.X_ACCEL_BUFFERING, 'no');\n headers.set(HeaderName.CONNECTION, 'keep-alive');\n\n const response = new Response(stream, {\n status: event.response.status,\n statusText: event.response.statusText,\n headers,\n });\n\n const handle: EventStreamHandle = {\n write(message: string | EventStreamMessage): void {\n if (closed) return;\n\n if (typeof message === 'string') {\n handle.write({ data: message });\n return;\n }\n\n const serialized = serializeEventStreamMessage(message);\n\n if (options?.maxMessageSize !== undefined) {\n const serializedSize = encoder.encode(serialized).byteLength;\n if (serializedSize > options.maxMessageSize) {\n return;\n }\n }\n\n controller.enqueue(encoder.encode(serialized));\n },\n\n end(): void {\n if (closed) return;\n\n closed = true;\n controller.close();\n },\n\n response,\n };\n\n return handle;\n}\n","export function sanitizeHeaderValue(value: string) : string {\n return value.replace(/[\\r\\n]/g, '');\n}","export function isObject(item: unknown) : item is Record<string, any> {\n return (\n !!item &&\n typeof item === 'object' &&\n !Array.isArray(item)\n );\n}\n\nexport function setProperty(\n record: Record<PropertyKey, any>,\n property: PropertyKey,\n value: any,\n): void {\n (record as any)[property] = value;\n}\n\nexport function getProperty<T = any>(\n req: Record<PropertyKey, any>,\n property: PropertyKey,\n): T {\n return (req as any)[property];\n}\n","import { Buffer } from 'node:buffer';\nimport { subtle } from 'uncrypto';\nimport { type Stats } from 'node:fs';\nimport { isObject } from '../object.ts';\nimport type { EtagOptions } from './type.ts';\n\n/**\n * Determine if object is a Stats object.\n *\n * @param {object} obj\n * @return {boolean}\n * @api private\n */\nfunction isStatsObject(obj: unknown) : obj is Stats {\n // quack quack\n return isObject(obj) &&\n 'ctime' in obj && Object.prototype.toString.call(obj.ctime) === '[object Date]' &&\n 'mtime' in obj && Object.prototype.toString.call(obj.mtime) === '[object Date]' &&\n 'ino' in obj && typeof obj.ino === 'number' &&\n 'size' in obj && typeof obj.size === 'number';\n}\n\nasync function sha1(str: string) : Promise<string> {\n const enc = new TextEncoder();\n const hash = await subtle.digest('SHA-1', enc.encode(str));\n\n return btoa(String.fromCharCode(...new Uint8Array(hash)));\n}\n\n/**\n * Generate an ETag.\n */\nexport async function generateETag(input: string | Buffer | Stats) : Promise<string> {\n if (isStatsObject(input)) {\n const mtime = input.mtime.getTime().toString(16);\n const size = input.size.toString(16);\n\n return `\"${size}-${mtime}\"`;\n }\n\n if (input.length === 0) {\n // fast-path empty\n return '\"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk\"';\n }\n\n const entity = Buffer.isBuffer(input) ?\n input.toString('utf-8') :\n input;\n\n // compute hash of entity\n const hash = await sha1(entity);\n\n return `\"${entity.length.toString(16)}-${hash.substring(0, 27)}\"`;\n}\n\n/**\n * Create a simple ETag.\n */\nexport async function createEtag(\n input: string | Buffer | Stats,\n options?: EtagOptions,\n) : Promise<string> {\n options = options || {};\n\n const weak = typeof options.weak === 'boolean' ?\n options.weak :\n isStatsObject(input);\n\n // generate entity tag\n const tag = await generateETag(input);\n\n return weak ?\n `W/${tag}` :\n tag;\n}\n","import { Buffer } from 'node:buffer';\nimport { merge } from 'smob';\nimport { isObject } from '../object.ts';\nimport { createEtag } from './module.ts';\nimport type { EtagFn, EtagOptions } from './type.ts';\n\nexport function buildEtagFn(input?: boolean | EtagOptions | EtagFn) : EtagFn {\n if (typeof input === 'function') {\n return input;\n }\n\n input = input ?? true;\n\n if (input === false) {\n return () => Promise.resolve(undefined);\n }\n\n let options : EtagOptions = { weak: true };\n\n if (isObject(input)) {\n options = merge(input, options);\n }\n\n return async (body: any, encoding?: BufferEncoding, size?: number) => {\n const buff = Buffer.isBuffer(body) ?\n body :\n Buffer.from(body, encoding);\n\n if (typeof options.threshold !== 'undefined') {\n size = size ?? Buffer.byteLength(buff);\n\n if (size <= options.threshold) {\n return undefined;\n }\n }\n\n return createEtag(buff, options);\n };\n}\n","import { compile } from 'proxy-addr';\nimport type { TrustProxyFn } from './type.ts';\n\nexport function buildTrustProxyFn(\n input?: boolean | number | string | string[] | TrustProxyFn,\n) : TrustProxyFn {\n if (typeof input === 'function') {\n return input;\n }\n\n if (input === true) {\n return () => true;\n }\n\n if (typeof input === 'number') {\n return (_address, hop) => hop < (input as number);\n }\n\n if (typeof input === 'string') {\n input = input.split(',')\n .map((value) => value.trim());\n }\n\n return compile(input || []);\n}\n","import { isObject } from './object.ts';\n\nexport function isInstance(\n input: unknown,\n sym: symbol,\n) {\n if (!isObject(input)) {\n return false;\n }\n\n return (input as { '@instanceof': symbol })['@instanceof'] === sym;\n}\n","import { get, getType } from 'mime-explorer';\n\nexport function getMimeType(type: string) : string | undefined {\n if (type.includes('/')) {\n return type;\n }\n\n return getType(type);\n}\n\nexport function getCharsetForMimeType(type: string) : string | undefined {\n if ((/^text\\/|^application\\/(javascript|json)/).test(type)) {\n return 'utf-8';\n }\n\n const meta = get(type);\n if (\n meta &&\n meta.charset\n ) {\n return meta.charset.toLowerCase();\n }\n\n return undefined;\n}\n","import type { MethodName } from '../constants.ts';\n\nexport function toMethodName(input: string | undefined) : MethodName | undefined;\nexport function toMethodName(input: string | undefined, alt: MethodName) : MethodName;\nexport function toMethodName(\n input?: string,\n alt?: MethodName,\n) : MethodName | undefined {\n if (input) {\n return input.toUpperCase() as MethodName;\n }\n\n return alt;\n}\n","/**\n * Based on https://github.com/unjs/pathe v1.1.1 (055f50a6f1131f4e5c56cf259dd8816168fba329)\n */\n\nfunction normalizeWindowsPath(input = '') {\n if (!input || !input.includes('\\\\')) {\n return input;\n }\n\n return input.replace(/\\\\/g, '/');\n}\n\nconst EXTNAME_RE = /.(\\.[^./]+)$/;\nexport function extname(input: string) {\n const match = EXTNAME_RE.exec(normalizeWindowsPath(input));\n return (match && match[1]) || '';\n}\n\nexport function basename(input: string, extension? :string) {\n const lastSegment = normalizeWindowsPath(input)\n .split('/')\n .pop();\n\n if (!lastSegment) {\n return input;\n }\n\n return extension && lastSegment.endsWith(extension) ?\n lastSegment.slice(0, -extension.length) :\n lastSegment;\n}\n","const TRAILING_SLASH_RE = /\\/$|\\/\\?/;\n\nexport function hasTrailingSlash(input = '', queryParams = false): boolean {\n if (!queryParams) {\n return input.endsWith('/');\n }\n\n return TRAILING_SLASH_RE.test(input);\n}\n\nexport function withoutTrailingSlash(input = '', queryParams = false): string {\n if (!queryParams) {\n return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || '/';\n }\n\n if (!hasTrailingSlash(input, true)) {\n return input || '/';\n }\n\n const [s0, ...s] = input.split('?');\n\n return (s0!.slice(0, -1) || '/') + (s.length ? `?${s.join('?')}` : '');\n}\n\nexport function withTrailingSlash(input = '', queryParams = false): string {\n if (!queryParams) {\n return input.endsWith('/') ? input : (`${input}/`);\n }\n\n if (hasTrailingSlash(input, true)) {\n return input || '/';\n }\n\n const [s0, ...s] = input.split('?');\n return `${s0}/${s.length ? `?${s.join('?')}` : ''}`;\n}\n\nexport function hasLeadingSlash(input = ''): boolean {\n return input.startsWith('/');\n}\n\nexport function withoutLeadingSlash(input = ''): string {\n return (hasLeadingSlash(input) ? input.substring(1) : input) || '/';\n}\n\nexport function withLeadingSlash(input = ''): string {\n return hasLeadingSlash(input) ? input : `/${input}`;\n}\n\nexport function cleanDoubleSlashes(input = ''): string {\n if (input.includes('://')) {\n return input.split('://')\n .map((str) => cleanDoubleSlashes(str))\n .join('://');\n }\n\n return input.replace(/\\/+/g, '/');\n}\n","import { sanitizeHeaderValue } from '../../utils/index.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\n\nexport function appendResponseHeader(\n event: IRoutupEvent,\n name: string,\n value: string | string[],\n) {\n const { headers } = event.response;\n\n if (Array.isArray(value)) {\n for (const v of value) {\n headers.append(name, sanitizeHeaderValue(v));\n }\n } else {\n headers.append(name, sanitizeHeaderValue(value));\n }\n}\n\nexport function appendResponseHeaderDirective(\n event: IRoutupEvent,\n name: string,\n value: string | string[],\n) {\n const { headers } = event.response;\n const existing = headers.get(name);\n\n if (!existing) {\n if (Array.isArray(value)) {\n headers.set(name, sanitizeHeaderValue(value.join('; ')));\n } else {\n headers.set(name, sanitizeHeaderValue(value));\n }\n return;\n }\n\n const directives = existing.split('; ');\n\n if (Array.isArray(value)) {\n directives.push(...value);\n } else {\n directives.push(value);\n }\n\n const unique = [...new Set(directives)];\n\n headers.set(name, sanitizeHeaderValue(unique.join('; ')));\n}\n","import { HeaderName } from '../../constants.ts';\nimport { extname, getCharsetForMimeType, getMimeType } from '../../utils/index.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\n\nexport function setResponseContentTypeByFileName(event: IRoutupEvent, fileName: string) {\n const ext = extname(fileName);\n if (ext) {\n let type = getMimeType(ext.substring(1));\n if (type) {\n const charset = getCharsetForMimeType(type);\n if (charset) {\n type += `; charset=${charset}`;\n }\n event.response.headers.set(HeaderName.CONTENT_TYPE, type);\n }\n }\n}\n","import { HeaderName } from '../../constants.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\nimport { setResponseContentTypeByFileName } from './utils.ts';\n\nfunction sanitizeFilename(filename: string) : string {\n return filename.replace(/[\\r\\n]/g, '');\n}\n\nfunction toAsciiFilename(filename: string) : string {\n // Strip non-ASCII characters and escape double quotes\n return filename.replace(/[^\\x20-\\x7E]/g, '').replace(/\"/g, '\\\\\"');\n}\n\nfunction encodeRfc5987(filename: string) : string {\n return encodeURIComponent(filename)\n .replace(/['()]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`)\n .replace(/\\*/g, '%2A');\n}\n\nexport function setResponseHeaderAttachment(event: IRoutupEvent, filename?: string) {\n if (typeof filename === 'string') {\n setResponseContentTypeByFileName(event, filename);\n }\n\n let disposition = 'attachment';\n\n if (filename) {\n const sanitized = sanitizeFilename(filename);\n const ascii = toAsciiFilename(sanitized);\n disposition += `; filename=\"${ascii}\"`;\n disposition += `; filename*=UTF-8''${encodeRfc5987(sanitized)}`;\n }\n\n event.response.headers.set(\n HeaderName.CONTENT_DISPOSITION,\n disposition,\n );\n}\n","import { HeaderName } from '../../constants.ts';\nimport { getMimeType } from '../../utils/index.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\n\nexport function setResponseHeaderContentType(event: IRoutupEvent, input: string, ifNotExists?: boolean) {\n if (ifNotExists) {\n const header = event.response.headers.get(HeaderName.CONTENT_TYPE);\n if (header) {\n return;\n }\n }\n\n const contentType = getMimeType(input);\n if (contentType) {\n event.response.headers.set(HeaderName.CONTENT_TYPE, contentType);\n }\n}\n","import type { IRoutupEvent } from '../event/index.ts';\n\nfunction stripWeakPrefix(etag: string): string {\n return etag.startsWith('W/') ? etag.slice(2) : etag;\n}\n\nasync function applyEtag(\n body: string,\n event: IRoutupEvent,\n headers: Headers,\n): Promise<Response | undefined> {\n const etagFn = event.routerOptions.etag;\n if (!etagFn) return undefined;\n\n const etag = await etagFn(body);\n if (!etag) return undefined;\n\n headers.set('etag', etag);\n\n const ifNoneMatch = event.headers.get('if-none-match');\n if (ifNoneMatch && (ifNoneMatch === '*' || ifNoneMatch.split(',').some((t) => stripWeakPrefix(t.trim()) === stripWeakPrefix(etag)))) {\n return new Response(null, {\n status: 304,\n headers,\n });\n }\n\n return undefined;\n}\n\nexport async function toResponse(\n value: unknown,\n event: IRoutupEvent,\n): Promise<Response | undefined> {\n if (value === undefined) {\n return undefined;\n }\n\n if (value === null) {\n return new Response(null, {\n status: event.response.status,\n statusText: event.response.statusText,\n headers: event.response.headers,\n });\n }\n\n if (value instanceof Response) {\n return value;\n }\n\n const {\n status,\n headers,\n statusText,\n } = event.response;\n\n if (typeof value === 'string') {\n if (!headers.has('content-type')) {\n headers.set('content-type', 'text/plain; charset=utf-8');\n }\n\n const cached = await applyEtag(value, event, headers);\n if (cached) return cached;\n\n return new Response(value, {\n status,\n statusText,\n headers,\n });\n }\n\n if (value instanceof ArrayBuffer || value instanceof Uint8Array) {\n if (!headers.has('content-type')) {\n headers.set('content-type', 'application/octet-stream');\n }\n return new Response(value as BodyInit, {\n status,\n statusText,\n headers,\n });\n }\n\n if (value instanceof ReadableStream) {\n return new Response(value, {\n status,\n statusText,\n headers,\n });\n }\n\n if (value instanceof Blob) {\n if (!headers.has('content-type')) {\n headers.set('content-type', value.type || 'application/octet-stream');\n }\n return new Response(value, {\n status,\n statusText,\n headers,\n });\n }\n\n // object/array/number/boolean — JSON serialize\n if (!headers.has('content-type')) {\n headers.set('content-type', 'application/json; charset=utf-8');\n }\n\n const json = JSON.stringify(value);\n\n const cached = await applyEtag(json, event, headers);\n if (cached) return cached;\n\n return new Response(json, {\n status,\n statusText,\n headers,\n });\n}\n","import type { IRoutupEvent } from '../../event/index.ts';\nimport { toResponse } from '../to-response.ts';\n\nexport async function sendAccepted(event: IRoutupEvent, data?: unknown): Promise<Response> {\n event.response.status = 202;\n event.response.statusText = 'Accepted';\n\n return await toResponse(data ?? '', event) as Response;\n}\n","import type { IRoutupEvent } from '../../event/index.ts';\nimport { toResponse } from '../to-response.ts';\n\nexport async function sendCreated(event: IRoutupEvent, data?: unknown): Promise<Response> {\n event.response.status = 201;\n event.response.statusText = 'Created';\n\n return await toResponse(data ?? '', event) as Response;\n}\n","import { HeaderName } from '../../constants.ts';\nimport { basename } from '../../utils/index.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\nimport { setResponseHeaderAttachment } from './header-attachment.ts';\nimport { setResponseContentTypeByFileName } from './utils.ts';\n\nexport type SendFileContentOptions = {\n end?: number,\n start?: number;\n};\n\nexport type SendFileStats = {\n size?: number,\n mtime?: Date | number | string,\n name?: string\n};\n\nexport type SendFileOptions = {\n stats: () => Promise<SendFileStats> | SendFileStats,\n content: (\n options: SendFileContentOptions,\n ) => Promise<ReadableStream | ArrayBuffer | Uint8Array> | ReadableStream | ArrayBuffer | Uint8Array,\n attachment?: boolean,\n name?: string\n};\n\nexport async function sendFile(\n event: IRoutupEvent,\n options: SendFileOptions,\n) : Promise<Response> {\n const stats = await options.stats();\n\n const name = options.name || stats.name;\n const { headers } = event.response;\n\n if (name) {\n const fileName = basename(name);\n\n if (options.attachment) {\n const dispositionHeader = headers.get(HeaderName.CONTENT_DISPOSITION);\n if (!dispositionHeader) {\n setResponseHeaderAttachment(event, fileName);\n }\n } else {\n setResponseContentTypeByFileName(event, fileName);\n }\n }\n\n const contentOptions : SendFileContentOptions = {};\n let statusCode = event.response.status;\n\n if (stats.size) {\n const rangeHeader = event.headers.get(HeaderName.RANGE);\n if (rangeHeader) {\n const [x, y] = rangeHeader.replace('bytes=', '')\n .split('-') as [string, string];\n\n const parsedStart = Number.parseInt(x, 10);\n const parsedEnd = Number.parseInt(y, 10);\n\n contentOptions.start = Number.isFinite(parsedStart) && parsedStart >= 0 ? parsedStart : 0;\n contentOptions.end = Number.isFinite(parsedEnd) && parsedEnd >= 0 ?\n Math.min(parsedEnd, stats.size - 1) :\n stats.size - 1;\n\n if (\n contentOptions.start >= stats.size ||\n contentOptions.start > contentOptions.end\n ) {\n const rangeHeaders = new Headers(headers);\n rangeHeaders.set(HeaderName.CONTENT_RANGE, `bytes */${stats.size}`);\n return new Response(null, {\n status: 416,\n statusText: event.response.statusText,\n headers: rangeHeaders,\n });\n }\n\n headers.set(HeaderName.CONTENT_RANGE, `bytes ${contentOptions.start}-${contentOptions.end}/${stats.size}`);\n headers.set(HeaderName.CONTENT_LENGTH, `${contentOptions.end - contentOptions.start + 1}`);\n statusCode = 206;\n } else {\n headers.set(HeaderName.CONTENT_LENGTH, `${stats.size}`);\n }\n\n headers.set(HeaderName.ACCEPT_RANGES, 'bytes');\n\n if (stats.mtime) {\n const mtime = new Date(stats.mtime);\n headers.set(HeaderName.LAST_MODIFIED, mtime.toUTCString());\n headers.set(HeaderName.ETag, `W/\"${stats.size}-${mtime.getTime()}\"`);\n }\n }\n\n const content = await options.content(contentOptions);\n\n return new Response(content as BodyInit, {\n status: statusCode,\n statusText: event.response.statusText,\n headers,\n });\n}\n","import type { IRoutupEvent } from '../../event/index.ts';\n\nexport function getRequestHeader(\n event: IRoutupEvent,\n name: string,\n) : string | null {\n return event.headers.get(name);\n}\n","import Negotiator from 'negotiator';\n\nimport type { IRoutupEvent } from '../../event/index.ts';\n\nconst NEGOTIATOR_KEY = /* @__PURE__ */ Symbol.for('routup:negotiator');\n\nfunction headersToPlainObject(headers: Headers) : Record<string, string> {\n const result: Record<string, string> = {};\n headers.forEach((value, key) => {\n result[key] = value;\n });\n return result;\n}\n\nexport function useRequestNegotiator(event: IRoutupEvent) : Negotiator {\n let value = event.store[NEGOTIATOR_KEY] as Negotiator | undefined;\n if (value) {\n return value;\n }\n\n value = new Negotiator({ headers: headersToPlainObject(event.headers) });\n event.store[NEGOTIATOR_KEY] = value;\n return value;\n}\n","import { HeaderName } from '../../constants.ts';\nimport { getMimeType } from '../../utils/index.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\nimport { getRequestHeader } from './header.ts';\nimport { useRequestNegotiator } from './negotiator.ts';\n\nexport function getRequestAcceptableContentTypes(event: IRoutupEvent) : string[] {\n const negotiator = useRequestNegotiator(event);\n\n return negotiator.mediaTypes();\n}\n\nexport function getRequestAcceptableContentType(event: IRoutupEvent, input?: string | string[]) : string | undefined {\n input = input || [];\n\n const items = Array.isArray(input) ? input : [input];\n\n if (items.length === 0) {\n return getRequestAcceptableContentTypes(event).shift();\n }\n\n const header = getRequestHeader(event, HeaderName.ACCEPT);\n if (!header) {\n return items[0];\n }\n\n let polluted = false;\n const mimeTypes : string[] = [];\n for (const item of items) {\n const mimeType = getMimeType(item);\n if (mimeType) {\n mimeTypes.push(mimeType);\n } else {\n polluted = true;\n }\n }\n\n const negotiator = useRequestNegotiator(event);\n const matches = negotiator.mediaTypes(mimeTypes);\n if (matches.length > 0) {\n if (polluted) {\n return items[0];\n }\n\n return items[mimeTypes.indexOf(matches[0]!)];\n }\n\n return undefined;\n}\n","import { getRequestAcceptableContentType } from '../../request/helpers/header-accept.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\n\ntype ResponseFormatHandler = () => Response | unknown;\n\ntype ResponseFormats = {\n default: ResponseFormatHandler,\n [key: string]: ResponseFormatHandler,\n};\n\nexport function sendFormat(event: IRoutupEvent, input: ResponseFormats): Response | unknown | undefined {\n const {\n default: formatDefault,\n ...formats\n } = input;\n\n const contentTypes = Object.keys(formats);\n\n if (contentTypes.length === 0) {\n return formatDefault();\n }\n\n const contentType = getRequestAcceptableContentType(event, contentTypes);\n if (contentType && formats[contentType]) {\n return formats[contentType]();\n }\n\n return formatDefault();\n}\n","import { RoutupError } from '../../error/module.ts';\nimport { sanitizeHeaderValue } from '../../utils/index.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\n\nfunction escapeHtml(str: string) : string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n}\n\nfunction isAllowedRedirectUrl(location: string) : boolean {\n // Block protocol-relative URLs (e.g. //evil.com)\n if (location.startsWith('//')) {\n return false;\n }\n\n if (location.startsWith('/') || location.startsWith('.')) {\n return true;\n }\n\n try {\n const url = new URL(location);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return true;\n }\n}\n\nexport function sendRedirect(event: IRoutupEvent, location: string, statusCode = 302): Response {\n if (!isAllowedRedirectUrl(location)) {\n throw new RoutupError({\n statusCode: 400,\n statusMessage: 'Invalid redirect URL scheme.',\n });\n }\n\n const sanitizedLocation = sanitizeHeaderValue(location);\n const escapedLoc = escapeHtml(location);\n const html = `<!DOCTYPE html><html><head><meta http-equiv=\"refresh\" content=\"0; url=${escapedLoc}\"></head></html>`;\n\n const headers = new Headers(event.response.headers);\n headers.set('location', sanitizedLocation);\n headers.set('content-type', 'text/html; charset=utf-8');\n headers.delete('content-length');\n\n const response = new Response(html, {\n status: statusCode,\n statusText: event.response.statusText,\n headers,\n });\n\n return response;\n}\n","import type { IRoutupEvent } from '../../event/index.ts';\n\nexport function sendStream(event: IRoutupEvent, stream: ReadableStream): Response {\n const {\n status,\n statusText,\n headers,\n } = event.response;\n\n return new Response(stream, {\n status,\n statusText,\n headers,\n });\n}\n","import type { RouterOptions } from '../router/types.ts';\nimport type {\n IRoutupEvent,\n RoutupRequest,\n RoutupResponse,\n} from './types.ts';\n\nexport type RoutupEventCreateContext = {\n request: RoutupRequest;\n params: Record<string, any>;\n path: string;\n method: string;\n mountPath: string;\n headers: Headers;\n searchParams: URLSearchParams;\n response: RoutupResponse;\n store: Record<string | symbol, unknown>;\n routerOptions: () => RouterOptions;\n next: (event: IRoutupEvent, error?: Error) => Promise<Response | undefined>;\n};\n\nexport class RoutupEvent implements IRoutupEvent {\n readonly request: RoutupRequest;\n\n readonly params: Record<string, any>;\n\n readonly path: string;\n\n readonly method: string;\n\n readonly mountPath: string;\n\n readonly headers: Headers;\n\n readonly searchParams: URLSearchParams;\n\n readonly response: RoutupResponse;\n\n readonly store: Record<string | symbol, unknown>;\n\n protected _context: RoutupEventCreateContext;\n\n protected _routerOptions?: RouterOptions;\n\n constructor(context: RoutupEventCreateContext) {\n this._context = context;\n this.request = context.request;\n this.params = context.params;\n this.path = context.path;\n this.method = context.method;\n this.mountPath = context.mountPath;\n this.headers = context.headers;\n this.searchParams = context.searchParams;\n this.response = context.response;\n this.store = context.store;\n }\n\n get routerOptions(): RouterOptions {\n if (!this._routerOptions) {\n this._routerOptions = this._context.routerOptions();\n }\n\n return this._routerOptions;\n }\n\n async next(error?: Error): Promise<Response | undefined> {\n return this._context.next(this, error);\n }\n}\n","import { FastURL } from 'srvx';\nimport type { RoutupError } from '../error/module.ts';\nimport type { RouterOptions, RouterPathNode } from '../router/types.ts';\nimport { toResponse } from '../response/index.ts';\nimport { buildEtagFn } from '../utils/index.ts';\nimport { RoutupEvent } from '../event/module.ts';\nimport type {\n IRoutupEvent,\n NextFn,\n RoutupRequest,\n RoutupResponse,\n} from '../event/types.ts';\nimport type { IDispatcherEvent } from './types.ts';\n\nexport class DispatcherEvent implements IDispatcherEvent {\n readonly request: RoutupRequest;\n\n params: Record<string, any>;\n\n path: string;\n\n readonly method: string;\n\n /**\n * Collected allowed methods (for OPTIONS).\n */\n methodsAllowed: string[];\n\n mountPath: string;\n\n error?: RoutupError;\n\n routerPath: RouterPathNode[];\n\n protected _dispatched: boolean;\n\n protected _response?: RoutupResponse;\n\n protected _store?: Record<string | symbol, unknown>;\n\n /**\n * Cached parsed URL (avoids double-parsing).\n */\n protected _url: InstanceType<typeof FastURL>;\n\n /**\n * Continuation function for middleware onion model.\n */\n protected _next?: (event: IRoutupEvent, error?: Error) => Promise<Response | undefined>;\n\n /**\n * Whether _next has already been called (guard against double-invocation).\n */\n protected _nextCalled: boolean;\n\n /**\n * The cached result of the next handler.\n */\n protected _nextResult?: Promise<Response | undefined>;\n\n // ------------------------------------------------------------------------\n\n constructor(request: RoutupRequest) {\n this.request = request;\n this._url = new FastURL(request.url);\n this.method = request.method;\n this.path = this._url.pathname;\n this.mountPath = '/';\n this.params = {};\n this.routerPath = [];\n this.methodsAllowed = [];\n this._dispatched = false;\n this._nextCalled = false;\n }\n\n // ------------------------------------------------------------------------\n\n get response(): RoutupResponse {\n if (!this._response) {\n this._response = { status: 200, headers: new Headers() };\n }\n\n return this._response;\n }\n\n get dispatched(): boolean {\n return this._dispatched;\n }\n\n set dispatched(value: boolean) {\n this._dispatched = value;\n }\n\n // ------------------------------------------------------------------------\n\n protected async next(event: IRoutupEvent, error?: Error): Promise<Response | undefined> {\n if (this._nextCalled) {\n return this._nextResult;\n }\n this._nextCalled = true;\n\n if (this._next) {\n this._nextResult = this._next(event, error);\n }\n\n return this._nextResult;\n }\n\n setNext(fn?: NextFn): void {\n if (fn) {\n this._next = async (event, error?: Error) => {\n const result = await fn(error);\n return toResponse(result, event);\n };\n } else {\n this._next = undefined;\n }\n\n this._nextCalled = false;\n this._nextResult = undefined;\n }\n\n // ------------------------------------------------------------------------\n\n build(): RoutupEvent {\n return new RoutupEvent({\n request: this.request,\n params: this.params,\n path: this.path,\n method: this.method,\n mountPath: this.mountPath,\n headers: this.request.headers,\n searchParams: new URLSearchParams(this._url.search),\n response: this.response,\n store: this.store,\n routerOptions: () => this.resolveOptions(),\n next: (event: IRoutupEvent, error?: Error) => this.next(event, error),\n });\n }\n\n // ------------------------------------------------------------------------\n\n protected get store(): Record<string | symbol, unknown> {\n if (!this._store) {\n this._store = Object.create(null) as Record<string | symbol, unknown>;\n }\n\n return this._store!;\n }\n\n protected resolveOptions(): RouterOptions {\n const resolved: RouterOptions = {\n trustProxy: () => false,\n subdomainOffset: 2,\n etag: buildEtagFn(),\n proxyIpMax: 0,\n };\n\n for (let i = 0; i < this.routerPath.length; i++) {\n const node = this.routerPath[i]!;\n const entries = Object.entries(node.options);\n for (const entry of entries) {\n const [key, value] = entry!;\n if (typeof value !== 'undefined') {\n (resolved as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n return resolved;\n }\n}\n","import { isHTTPError } from '@ebec/http';\nimport type { RoutupError } from './module.ts';\n\nexport function isError(input: unknown) : input is RoutupError {\n if (!isHTTPError(input)) {\n return false;\n }\n\n return (input as unknown as { name?: string }).name === 'RoutupError';\n}\n","import { isHTTPError } from '@ebec/http';\nimport type { HTTPErrorInput } from '@ebec/http';\nimport { isObject } from '../utils/index.ts';\nimport { isError } from './is.ts';\nimport { RoutupError } from './module.ts';\n\nfunction isNativeError(input: unknown): input is Error {\n return isObject(input) &&\n typeof (input as Record<string, unknown>).message === 'string' &&\n typeof (input as Record<string, unknown>).name === 'string';\n}\n\n/**\n * Create an internal error object by\n * - an existing RoutupError (returned as-is)\n * - an HTTPError (wrapped into a RoutupError preserving status)\n * - an Error (wrapped preserving message and cause)\n * - an options object (statusCode, statusMessage, etc.)\n * - a message string\n *\n * @param input\n */\nexport function createError(input: HTTPErrorInput | unknown) : RoutupError {\n if (isError(input)) {\n return input;\n }\n\n if (typeof input === 'string') {\n return new RoutupError(input);\n }\n\n if (isHTTPError(input)) {\n return new RoutupError({\n message: input.message,\n code: input.code,\n statusCode: input.statusCode,\n statusMessage: input.statusMessage,\n redirectURL: input.redirectURL,\n cause: input,\n });\n }\n\n if (isNativeError(input)) {\n return new RoutupError({\n message: input.message,\n cause: input,\n });\n }\n\n if (!isObject(input)) {\n return new RoutupError();\n }\n\n const options = { ...input as Record<string, unknown> };\n if (options.cause === undefined) {\n options.cause = input;\n }\n\n return new RoutupError(options as HTTPErrorInput);\n}\n","export enum HandlerType {\n CORE = 'core',\n ERROR = 'error',\n}\n\nexport const HandlerSymbol = /* @__PURE__ */ Symbol.for('Handler');\n","export enum HookName {\n REQUEST = 'request',\n RESPONSE = 'response',\n ERROR = 'error',\n\n CHILD_MATCH = 'childMatch',\n CHILD_DISPATCH_BEFORE = 'childDispatchBefore',\n CHILD_DISPATCH_AFTER = 'childDispatchAfter',\n}\n","import type { IDispatcherEvent } from '../dispatcher/types.ts';\nimport type { RoutupError } from '../error/module.ts';\nimport { HookName } from './constants.ts';\nimport type {\n HookDefaultListener,\n HookErrorListener,\n HookListener,\n HookUnsubscribeFn,\n} from './types.ts';\n\nexport class HookManager {\n protected items: Record<string, HookListener[]>;\n\n // --------------------------------------------------\n\n constructor() {\n this.items = {};\n }\n\n // --------------------------------------------------\n\n addListener(\n name: `${HookName}`,\n fn: HookListener,\n ): HookUnsubscribeFn {\n this.items[name] = this.items[name] || [];\n this.items[name].push(fn);\n\n return () => {\n this.removeListener(name, fn);\n };\n }\n\n removeListener(name: `${HookName}`): void;\n\n removeListener(name: `${HookName}`, fn: HookListener): void;\n\n removeListener(name: `${HookName}`, fn?: HookListener): void {\n if (!this.items[name]) {\n return;\n }\n\n if (typeof fn === 'undefined') {\n delete this.items[name];\n return;\n }\n\n if (typeof fn === 'function') {\n const index = this.items[name].indexOf(fn);\n if (index !== -1) {\n this.items[name].splice(index, 1);\n }\n }\n\n if (this.items[name].length === 0) {\n delete this.items[name];\n }\n }\n\n // --------------------------------------------------\n\n async trigger(\n name: `${HookName}`,\n event: IDispatcherEvent,\n ): Promise<void> {\n if (!this.items[name] || this.items[name].length === 0) {\n return;\n }\n\n try {\n for (let i = 0; i < this.items[name].length; i++) {\n const listener = this.items[name][i]!;\n await this.triggerListener(name, event, listener);\n\n if (event.dispatched) {\n if (event.error) {\n event.error = undefined;\n }\n return;\n }\n }\n } catch (e) {\n event.error = e as RoutupError;\n\n if (!this.isErrorListenerHook(name)) {\n await this.trigger(HookName.ERROR, event);\n\n if (event.dispatched) {\n if (event.error) {\n event.error = undefined;\n }\n }\n }\n }\n }\n\n private triggerListener(name: `${HookName}`, event: IDispatcherEvent, listener: HookListener) {\n if (this.isErrorListenerHook(name)) {\n if (event.error) {\n return (listener as HookErrorListener)(event);\n }\n return undefined;\n }\n\n return (listener as HookDefaultListener)(event);\n }\n\n private isErrorListenerHook(input: `${HookName}`) {\n return input === HookName.ERROR;\n }\n}\n","import type { Key } from 'path-to-regexp';\nimport { pathToRegexp } from 'path-to-regexp';\nimport type { Path, PathMatcherExecResult, PathMatcherOptions } from './type.ts';\n\nfunction decodeParam(val: unknown) {\n /* istanbul ignore next */\n if (typeof val !== 'string' || val.length === 0) {\n return val;\n }\n\n try {\n return decodeURIComponent(val);\n } catch {\n return val;\n }\n}\n\nexport class PathMatcher {\n protected path: Path;\n\n protected regexp : RegExp;\n\n protected regexpKeys : Key[] = [];\n\n protected regexpOptions: PathMatcherOptions;\n\n constructor(path: Path, options?: PathMatcherOptions) {\n this.path = path;\n\n this.regexpOptions = options || {};\n const regexp = pathToRegexp(path, options);\n\n this.regexp = regexp.regexp;\n this.regexpKeys = regexp.keys;\n }\n\n test(path: string) {\n return this.regexp.test(path);\n }\n\n exec(path: string) : PathMatcherExecResult | undefined {\n if (\n this.path === '/' &&\n this.regexpOptions.end === false\n ) {\n return {\n path: '/',\n params: Object.create(null),\n };\n }\n\n const match = this.regexp.exec(path);\n\n if (!match) {\n return undefined;\n }\n\n const params : Record<string, unknown> = Object.create(null);\n\n for (let i = 1; i < match.length; i++) {\n const key = this.regexpKeys[i - 1];\n if (!key) continue;\n const prop = key.name;\n const val = decodeParam(match[i]);\n\n if (typeof val !== 'undefined') {\n params[prop] = val;\n }\n }\n\n return {\n path: match[0],\n params,\n };\n }\n}\n","import type { Path } from './type.ts';\n\nexport function isPath(input: unknown): input is Path {\n return typeof input === 'string';\n}\n","import { MethodName } from '../constants.ts';\nimport type { IDispatcher, IDispatcherEvent } from '../dispatcher/index.ts';\nimport { createError, isError } from '../error/index.ts';\nimport { HookManager, HookName } from '../hook/index.ts';\nimport type { Path } from '../path/index.ts';\nimport { PathMatcher } from '../path/index.ts';\nimport { toResponse } from '../response/index.ts';\nimport { toMethodName, withLeadingSlash } from '../utils/index.ts';\nimport { HandlerSymbol, HandlerType } from './constants.ts';\nimport type { HandlerOptions } from './types.ts';\n\nexport class Handler implements IDispatcher {\n readonly '@instanceof' = HandlerSymbol;\n\n protected config: HandlerOptions;\n\n protected hookManager: HookManager;\n\n protected pathMatcher: PathMatcher | undefined;\n\n protected _method: MethodName | undefined;\n\n // --------------------------------------------------\n\n constructor(handler: HandlerOptions) {\n this.config = handler;\n this.hookManager = new HookManager();\n\n this.mountHooks();\n this.setPath(handler.path);\n }\n\n // --------------------------------------------------\n\n get type() {\n return this.config.type;\n }\n\n get path() {\n return this.config.path;\n }\n\n get method() {\n if (this._method || !this.config.method) {\n return this._method;\n }\n\n this._method = toMethodName(this.config.method);\n return this._method;\n }\n\n // --------------------------------------------------\n\n async dispatch(event: IDispatcherEvent): Promise<Response | undefined> {\n if (this.pathMatcher) {\n const pathMatch = this.pathMatcher.exec(event.path);\n if (pathMatch) {\n event.params = {\n ...event.params,\n ...pathMatch.params,\n };\n }\n }\n\n await this.hookManager.trigger(HookName.CHILD_DISPATCH_BEFORE, event);\n if (event.dispatched) {\n return undefined;\n }\n\n let response: Response | undefined;\n\n try {\n let result: unknown;\n const handlerEvent = event.build();\n\n if (this.config.type === HandlerType.ERROR) {\n if (event.error) {\n result = await this.config.fn(event.error, handlerEvent);\n }\n } else {\n result = await this.config.fn(handlerEvent);\n }\n\n response = await toResponse(result, handlerEvent);\n\n if (response) {\n event.dispatched = true;\n }\n } catch (e) {\n event.error = isError(e) ? e : createError(e);\n\n await this.hookManager.trigger(HookName.ERROR, event);\n\n if (event.dispatched) {\n event.error = undefined;\n } else {\n throw event.error;\n }\n }\n\n await this.hookManager.trigger(HookName.CHILD_DISPATCH_AFTER, event);\n\n return response;\n }\n\n // --------------------------------------------------\n\n matchPath(path: string): boolean {\n if (!this.pathMatcher) {\n return true;\n }\n\n return this.pathMatcher.test(path);\n }\n\n setPath(path?: Path): void {\n if (typeof path === 'string') {\n path = withLeadingSlash(path);\n }\n\n this.config.path = path;\n\n if (typeof path === 'undefined') {\n this.pathMatcher = undefined;\n return;\n }\n\n this.pathMatcher = new PathMatcher(path, { end: !!this.config.method });\n }\n\n // --------------------------------------------------\n\n matchMethod(method: `${MethodName}`): boolean {\n return !this.method ||\n method === this.method ||\n (\n method === MethodName.HEAD &&\n this.method === MethodName.GET\n );\n }\n\n setMethod(input?: `${MethodName}`): void {\n const method = toMethodName(input);\n\n this.config.method = method;\n this._method = method;\n }\n\n // --------------------------------------------------\n\n protected mountHooks() {\n if (this.config.onBefore) {\n this.hookManager.addListener(HookName.CHILD_DISPATCH_BEFORE, this.config.onBefore);\n }\n\n if (this.config.onAfter) {\n this.hookManager.addListener(HookName.CHILD_DISPATCH_AFTER, this.config.onAfter);\n }\n\n if (this.config.onError) {\n this.hookManager.addListener(HookName.ERROR, this.config.onError);\n }\n }\n}\n","import { HandlerType } from '../constants.ts';\nimport { Handler } from '../module.ts';\nimport type {\n CoreHandler,\n CoreHandlerOptions,\n} from './types.ts';\n\n/**\n * Create a request handler.\n *\n * @param input - Handler function `(event) => value` or options object `{ fn, path?, method? }`\n *\n * @example\n * ```typescript\n * // Shorthand — function only\n * router.get('/', defineCoreHandler((event) => 'Hello'));\n *\n * // Verbose — with path and method\n * router.use(defineCoreHandler({\n * path: '/users/:id',\n * method: 'GET',\n * fn: (event) => ({ id: event.params.id }),\n * }));\n * ```\n */\nexport function defineCoreHandler(input: Omit<CoreHandlerOptions, | 'type'>) : Handler;\n\nexport function defineCoreHandler(input: CoreHandler) : Handler;\n\nexport function defineCoreHandler(input: any) : Handler {\n if (typeof input === 'function') {\n return new Handler({\n type: HandlerType.CORE,\n fn: input,\n });\n }\n\n return new Handler({\n type: HandlerType.CORE,\n ...input,\n });\n}\n","import { HandlerType } from '../constants.ts';\nimport { Handler } from '../module.ts';\nimport type {\n ErrorHandler,\n ErrorHandlerOptions,\n} from './types.ts';\n\n/**\n * Create an error handler.\n *\n * Error handlers receive errors thrown by preceding handlers in the pipeline.\n *\n * @param input - Handler function `(error, event) => value` or options object `{ fn, path? }`\n *\n * @example\n * ```typescript\n * router.use(defineErrorHandler((error, event) => {\n * return { message: error.message };\n * }));\n * ```\n */\nexport function defineErrorHandler(input: Omit<ErrorHandlerOptions, 'type'>) : Handler;\n\nexport function defineErrorHandler(input: ErrorHandler) : Handler;\nexport function defineErrorHandler(input: any) : Handler {\n if (typeof input === 'function') {\n return new Handler({\n type: HandlerType.ERROR,\n fn: input,\n });\n }\n\n return new Handler({\n type: HandlerType.ERROR,\n ...input,\n });\n}\n","import type { IncomingMessage, ServerResponse } from 'node:http';\nimport type { IRoutupEvent } from '../../../event/index.ts';\nimport { RoutupError } from '../../../error/module.ts';\nimport { defineCoreHandler } from '../../core/index.ts';\nimport type { Handler } from '../../module.ts';\nimport type { CoreHandler } from '../../core/types.ts';\nimport type { NodeHandler, NodeMiddleware } from './types.ts';\n\nconst kHandled = /* @__PURE__ */ Symbol('handled');\n\nfunction callHandler(\n handler: NodeHandler,\n req: IncomingMessage,\n res: ServerResponse,\n): Promise<typeof kHandled | void> {\n return new Promise((resolve, reject) => {\n let settled = false;\n\n const onClose = () => settle(kHandled);\n const onFinish = () => settle(kHandled);\n const onError = (error: Error) => fail(error);\n\n function cleanup() {\n res.removeListener('close', onClose);\n res.removeListener('finish', onFinish);\n res.removeListener('error', onError);\n }\n\n function settle(value: typeof kHandled | void) {\n if (settled) return;\n settled = true;\n cleanup();\n resolve(value);\n }\n\n function fail(error: unknown) {\n if (settled) return;\n settled = true;\n cleanup();\n reject(error);\n }\n\n res.once('close', onClose);\n res.once('finish', onFinish);\n res.once('error', onError);\n\n try {\n Promise.resolve(handler(req, res))\n .then(() => settle(kHandled))\n .catch(fail);\n } catch (error) {\n fail(error);\n }\n });\n}\n\nfunction callMiddleware(\n handler: NodeMiddleware,\n req: IncomingMessage,\n res: ServerResponse,\n): Promise<typeof kHandled | void> {\n return new Promise((resolve, reject) => {\n let settled = false;\n\n const onClose = () => settle(kHandled);\n const onFinish = () => settle(kHandled);\n const onError = (error: Error) => fail(error);\n\n function cleanup() {\n res.removeListener('close', onClose);\n res.removeListener('finish', onFinish);\n res.removeListener('error', onError);\n }\n\n function settle(value: typeof kHandled | void) {\n if (settled) return;\n settled = true;\n cleanup();\n resolve(value);\n }\n\n function fail(error: unknown) {\n if (settled) return;\n settled = true;\n cleanup();\n reject(error);\n }\n\n res.once('close', onClose);\n res.once('finish', onFinish);\n res.once('error', onError);\n\n try {\n Promise.resolve(\n handler(req, res, (error) => {\n if (error) {\n fail(error);\n } else {\n settle(res.writableEnded || res.destroyed ? kHandled : undefined);\n }\n }),\n ).catch(fail);\n } catch (error) {\n fail(error);\n }\n });\n}\n\nfunction createNodeBridge(handler: NodeHandler | NodeMiddleware, isMiddleware: boolean): Handler {\n if (typeof handler !== 'function') {\n throw new RoutupError('fromNodeHandler/fromNodeMiddleware expects a function.');\n }\n\n return defineCoreHandler({\n fn: (async (event: IRoutupEvent) => {\n const node = event.request.runtime?.node;\n if (!node?.req || !node?.res) {\n throw new RoutupError('fromNodeHandler/fromNodeMiddleware requires a Node.js runtime.');\n }\n\n const req = node.req as unknown as IncomingMessage;\n const res = node.res as unknown as ServerResponse;\n\n const result = isMiddleware ?\n await callMiddleware(handler as NodeMiddleware, req, res) :\n await callHandler(handler as NodeHandler, req, res);\n\n if (result === kHandled) {\n return null;\n }\n\n return undefined;\n }) as CoreHandler,\n });\n}\n\n/**\n * Wraps a Node.js `(req, res)` handler for use in the routup pipeline.\n *\n * @example\n * ```typescript\n * import { fromNodeHandler } from 'routup/node';\n *\n * router.use(fromNodeHandler((req, res) => {\n * res.end('Hello');\n * }));\n * ```\n */\nexport function fromNodeHandler(handler: NodeHandler): Handler {\n return createNodeBridge(handler, false);\n}\n\n/**\n * Wraps a Node.js `(req, res, next)` middleware for use in the routup pipeline.\n *\n * @example\n * ```typescript\n * import cors from 'cors';\n * import { fromNodeMiddleware } from 'routup/node';\n *\n * router.use(fromNodeMiddleware(cors()));\n * ```\n */\nexport function fromNodeMiddleware(handler: NodeMiddleware): Handler {\n return createNodeBridge(handler, true);\n}\n","import { isObject } from '../../../utils/index.ts';\nimport type { WebHandler, WebHandlerProvider } from './types.ts';\n\nexport function isWebHandlerProvider(input: unknown): input is WebHandlerProvider {\n return isObject(input) &&\n typeof input.fetch === 'function';\n}\n\nexport function isWebHandler(input: unknown): input is WebHandler {\n return typeof input === 'function';\n}\n","import type { IRoutupEvent } from '../../../event/index.ts';\nimport { RoutupError } from '../../../error/index.ts';\nimport { defineCoreHandler } from '../../core/index.ts';\nimport type { Handler } from '../../module.ts';\nimport { isWebHandlerProvider } from './is.ts';\nimport type { WebHandler, WebHandlerProvider } from './types.ts';\n\n/**\n * Create a handler from a Web Fetch API-compatible function or object.\n *\n * Wraps an external app (e.g. Hono, another Router) so it can be mounted\n * via `router.use()`. The original request is passed through as-is.\n *\n * @param input - Fetch function `(request) => Response` or object with a `fetch` method\n *\n * @experimental\n *\n * @example\n * ```ts\n * // Mount an object with a fetch method\n * router.use('/api', fromWebHandler(honoApp));\n *\n * // Mount a plain fetch function\n * router.use('/proxy', fromWebHandler((req) => fetch(req)));\n * ```\n */\nexport function fromWebHandler(input: WebHandler) : Handler;\n\nexport function fromWebHandler(input: WebHandlerProvider) : Handler;\n\nexport function fromWebHandler(input: any) : Handler {\n if (isWebHandlerProvider(input)) {\n return fromWebHandler(input.fetch.bind(input));\n }\n\n if (typeof input !== 'function') {\n throw new RoutupError('fromWebHandler expects a function or an object with a fetch method.');\n }\n\n return defineCoreHandler({ fn: (event: IRoutupEvent) => input(event.request) });\n}\n","import { isInstance, isObject } from '../utils/index.ts';\nimport { HandlerSymbol } from './constants.ts';\nimport type { Handler } from './module.ts';\nimport type { HandlerOptions } from './types.ts';\n\nexport function isHandlerOptions(input: unknown) : input is HandlerOptions {\n return isObject(input) &&\n typeof input.fn === 'function' &&\n typeof input.type === 'string';\n}\n\nexport function isHandler(input: unknown): input is Handler {\n return isInstance(input, HandlerSymbol);\n}\n\n","import type { IRoutupEvent } from '../../event/index.ts';\n\nconst BODY_KEY = /* @__PURE__ */ Symbol.for('routup:body');\n\n/**\n * Read and parse the request body.\n *\n * - `application/x-www-form-urlencoded` → plain object (duplicate keys become arrays)\n * - `application/json` or other → attempts JSON parse, returns undefined on failure\n *\n * The result is cached on the event store — calling `readBody()` multiple\n * times returns the same parsed result.\n *\n * For binary or streaming access, use `event.request.arrayBuffer()`,\n * `event.request.blob()`, or `event.request.body` directly.\n *\n * @experimental\n */\nexport async function readBody<T = unknown>(event: IRoutupEvent): Promise<T | undefined> {\n if (BODY_KEY in event.store) {\n return event.store[BODY_KEY] as T;\n }\n\n const text = await event.request.text();\n\n let result: unknown | undefined;\n\n const contentType = event.headers.get('content-type') || '';\n if (contentType.includes('application/x-www-form-urlencoded')) {\n result = parseURLEncodedBody(text);\n } else {\n try {\n result = JSON.parse(text);\n } catch {\n result = undefined;\n }\n }\n\n event.store[BODY_KEY] = result;\n return result as T;\n}\n\nfunction parseURLEncodedBody(body: string): Record<string, unknown> {\n const form = new URLSearchParams(body);\n const parsed: Record<string, unknown> = Object.create(null);\n\n for (const [key, value] of form.entries()) {\n const existing = parsed[key];\n if (existing !== undefined) {\n if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n parsed[key] = [existing, value];\n }\n } else {\n parsed[key] = value;\n }\n }\n\n return parsed;\n}\n","import { HeaderName } from '../../constants.ts';\n\nimport type { IRoutupEvent } from '../../event/index.ts';\n\nexport function isRequestCacheable(event: IRoutupEvent, modifiedTime: string | Date) : boolean {\n const modifiedSince = event.headers.get(HeaderName.IF_MODIFIED_SINCE);\n if (!modifiedSince) {\n return false;\n }\n\n modifiedTime = typeof modifiedTime === 'string' ?\n new Date(modifiedTime) :\n modifiedTime;\n\n const sinceDate = new Date(modifiedSince);\n if (Number.isNaN(sinceDate.getTime()) || Number.isNaN(modifiedTime.getTime())) {\n return false;\n }\n\n return sinceDate >= modifiedTime;\n}\n","import type { IRoutupEvent } from '../../event/index.ts';\nimport { useRequestNegotiator } from './negotiator.ts';\n\nexport function getRequestAcceptableCharsets(event: IRoutupEvent) : string[] {\n const negotiator = useRequestNegotiator(event);\n\n return negotiator.charsets();\n}\n\nexport function getRequestAcceptableCharset(event: IRoutupEvent, input: string | string[]) : string | undefined {\n input = input || [];\n\n const items = Array.isArray(input) ? input : [input];\n\n if (items.length === 0) {\n return getRequestAcceptableCharsets(event).shift();\n }\n\n const negotiator = useRequestNegotiator(event);\n return negotiator.charsets(items).shift() || undefined;\n}\n","import type { IRoutupEvent } from '../../event/index.ts';\nimport { useRequestNegotiator } from './negotiator.ts';\n\nexport function getRequestAcceptableEncodings(event: IRoutupEvent) : string[] {\n const negotiator = useRequestNegotiator(event);\n return negotiator.encodings();\n}\n\nexport function getRequestAcceptableEncoding(event: IRoutupEvent, input: string | string[]) : string | undefined {\n input = input || [];\n\n const items = Array.isArray(input) ? input : [input];\n\n if (items.length === 0) {\n return getRequestAcceptableEncodings(event).shift();\n }\n\n const negotiator = useRequestNegotiator(event);\n return negotiator.encodings(items).shift() || undefined;\n}\n","import type { IRoutupEvent } from '../../event/index.ts';\nimport { useRequestNegotiator } from './negotiator.ts';\n\nexport function getRequestAcceptableLanguages(event: IRoutupEvent) : string[] {\n const negotiator = useRequestNegotiator(event);\n return negotiator.languages();\n}\n\nexport function getRequestAcceptableLanguage(event: IRoutupEvent, input?: string | string[]) : string | undefined {\n input = input || [];\n\n const items = Array.isArray(input) ? input : [input];\n\n if (items.length === 0) {\n return getRequestAcceptableLanguages(event).shift();\n }\n\n const negotiator = useRequestNegotiator(event);\n return negotiator.languages(items).shift() || undefined;\n}\n","import { HeaderName } from '../../constants.ts';\nimport { getMimeType } from '../../utils/index.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\nimport { getRequestHeader } from './header.ts';\n\nexport function matchRequestContentType(event: IRoutupEvent, contentType: string) : boolean {\n const header = getRequestHeader(event, HeaderName.CONTENT_TYPE);\n if (!header) {\n return true;\n }\n\n return header.split(';')[0]!.trim() === getMimeType(contentType);\n}\n","import { HeaderName } from '../../constants.ts';\nimport type { TrustProxyFn, TrustProxyInput } from '../../utils/index.ts';\nimport { buildTrustProxyFn } from '../../utils/index.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\n\nexport type RequestHostNameOptions = {\n trustProxy?: TrustProxyInput,\n};\n\nexport function getRequestHostName(event: IRoutupEvent, options: RequestHostNameOptions = {}) : string | undefined {\n let trustProxy : TrustProxyFn;\n if (typeof options.trustProxy !== 'undefined') {\n trustProxy = buildTrustProxyFn(options.trustProxy);\n } else {\n trustProxy = event.routerOptions.trustProxy;\n }\n\n let hostname = event.headers.get(HeaderName.X_FORWARDED_HOST);\n if (!hostname || !event.request.ip || !trustProxy(event.request.ip, 0)) {\n hostname = event.headers.get(HeaderName.HOST);\n } else if (hostname && hostname.includes(',')) {\n hostname = hostname.substring(0, hostname.indexOf(',')).trimEnd();\n }\n\n if (!hostname) {\n return undefined;\n }\n\n // IPv6 literal support\n const offset = hostname[0] === '[' ?\n hostname.indexOf(']') + 1 :\n 0;\n const index = hostname.indexOf(':', offset);\n\n const result = index !== -1 ?\n hostname.substring(0, index) :\n hostname;\n\n // Reject hostnames with obviously invalid characters\n // eslint-disable-next-line no-control-regex\n if (/[\\x00-\\x1F\\x7F\\s/@\\\\]/.test(result)) {\n return undefined;\n }\n\n return result;\n}\n","import { HeaderName } from '../../constants.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\nimport type { TrustProxyFn, TrustProxyInput } from '../../utils/index.ts';\nimport { buildTrustProxyFn } from '../../utils/index.ts';\n\nexport type RequestIpOptions = {\n trustProxy?: TrustProxyInput,\n};\n\n/**\n * Get the client IP address from the request.\n *\n * When `trustProxy` is configured, walks the `X-Forwarded-For` chain\n * and returns the rightmost untrusted address (the actual client IP).\n * Falls back to `event.request.ip` (the direct connection IP).\n */\nexport function getRequestIP(event: IRoutupEvent, options: RequestIpOptions = {}) : string | undefined {\n let trustProxy : TrustProxyFn;\n if (typeof options.trustProxy !== 'undefined') {\n trustProxy = buildTrustProxyFn(options.trustProxy);\n } else {\n trustProxy = event.routerOptions.trustProxy;\n }\n\n const socketAddr = event.request.ip;\n if (!socketAddr) {\n return undefined;\n }\n\n // Build address list: [socket IP, ...forwarded addresses (rightmost first)]\n const forwarded = event.headers.get(HeaderName.X_FORWARDED_FOR);\n const addrs: string[] = [socketAddr];\n\n if (forwarded) {\n const parts = forwarded.split(',');\n for (let i = parts.length - 1; i >= 0; i--) {\n const addr = parts[i]!.trim();\n if (addr) {\n addrs.push(addr);\n }\n }\n }\n\n // Walk from socket (leftmost) to client (rightmost),\n // stopping at the first untrusted address\n for (let i = 0; i < addrs.length - 1; i++) {\n if (!trustProxy(addrs[i]!, i)) {\n return addrs[i];\n }\n }\n\n // All proxies trusted — return the original client (last in chain)\n return addrs[addrs.length - 1];\n}\n","import { HeaderName } from '../../constants.ts';\nimport type { TrustProxyFn, TrustProxyInput } from '../../utils/index.ts';\nimport { buildTrustProxyFn } from '../../utils/index.ts';\nimport type { IRoutupEvent } from '../../event/index.ts';\n\nexport type RequestProtocolOptions = {\n trustProxy?: TrustProxyInput,\n default?: string,\n};\n\nexport function getRequestProtocol(\n event: IRoutupEvent,\n options: RequestProtocolOptions = {},\n) : string {\n let trustProxy : TrustProxyFn;\n if (typeof options.trustProxy !== 'undefined') {\n trustProxy = buildTrustProxyFn(options.trustProxy);\n } else {\n trustProxy = event.routerOptions.trustProxy;\n }\n\n // Derive protocol from the request URL scheme\n let protocol : string;\n try {\n const url = new URL(event.request.url);\n if (url.protocol === 'https:') {\n protocol = 'https';\n } else {\n protocol = 'http';\n }\n } catch {\n protocol = options.default || 'http';\n }\n\n if (!event.request.ip || !trustProxy(event.request.ip, 0)) {\n return protocol;\n }\n\n const header = event.headers.get(HeaderName.X_FORWARDED_PROTO);\n if (!header) {\n return protocol;\n }\n\n const index = header.indexOf(',');\n\n const forwarded = index !== -1 ?\n header.substring(0, index).trim().toLowerCase() :\n header.trim().toLowerCase();\n\n if (forwarded === 'http' || forwarded === 'https') {\n return forwarded;\n }\n\n return protocol;\n}\n","import { isObject } from '../utils/index.ts';\nimport type { Plugin } from './types.ts';\n\nexport function isPlugin(input: unknown): input is Plugin {\n if (!isObject(input)) {\n return false;\n }\n\n if (\n typeof input.name !== 'undefined' &&\n typeof input.name !== 'string'\n ) {\n return false;\n }\n\n return typeof input.install === 'function' &&\n input.install.length === 1;\n}\n","import { buildEtagFn, buildTrustProxyFn } from '../utils/index.ts';\nimport type { RouterOptions, RouterOptionsInput } from './types.ts';\n\nexport function normalizeRouterOptions(input: RouterOptionsInput): Partial<RouterOptions> {\n if (typeof input.etag !== 'undefined') {\n input.etag = buildEtagFn(input.etag);\n }\n\n if (typeof input.trustProxy !== 'undefined') {\n input.trustProxy = buildTrustProxyFn(input.trustProxy);\n }\n\n return input as Partial<RouterOptions>;\n}\n","export const RouterSymbol = /* @__PURE__ */ Symbol.for('Router');\n\nexport enum RouterPipelineStep {\n START,\n LOOKUP,\n CHILD_BEFORE,\n CHILD_DISPATCH,\n CHILD_AFTER,\n FINISH,\n}\n","import { isInstance } from '../utils/index.ts';\nimport { RouterSymbol } from './constants.ts';\nimport type { Router } from './module.ts';\n\nexport function isRouterInstance(input: unknown): input is Router {\n return isInstance(input, RouterSymbol);\n}\n\n/**\n * Check if the request accepts JSON responses.\n * Matches application/json and +json suffixes (e.g. application/vnd.api+json).\n * Returns true if no Accept header is present (API-first default).\n */\nexport function acceptsJson(request: Request): boolean {\n const accept = request.headers.get('accept');\n if (!accept) {\n return true;\n }\n\n return accept.includes('application/json') ||\n accept.includes('+json') ||\n accept.includes('*/*');\n}\n","import { distinctArray } from 'smob';\nimport { HeaderName, MethodName } from '../constants.ts';\nimport { DispatcherEvent } from '../dispatcher/index.ts';\nimport type { IDispatcherEvent } from '../dispatcher/index.ts';\nimport type { RoutupRequest } from '../event/index.ts';\nimport { createError } from '../error/index.ts';\nimport {\n Handler,\n type HandlerOptions,\n HandlerType,\n isHandler,\n isHandlerOptions,\n} from '../handler/index.ts';\nimport type {\n HookDefaultListener,\n HookErrorListener,\n HookListener,\n HookUnsubscribeFn,\n} from '../hook/index.ts';\nimport { HookManager, HookName } from '../hook/index.ts';\nimport type { Path } from '../path/index.ts';\nimport { PathMatcher, isPath } from '../path/index.ts';\nimport type { Plugin, PluginInstallContext } from '../plugin/index.ts';\nimport { isPlugin } from '../plugin/index.ts';\nimport { normalizeRouterOptions } from './options.ts';\nimport { cleanDoubleSlashes, withLeadingSlash, withoutTrailingSlash } from '../utils/index.ts';\nimport { RouterPipelineStep, RouterSymbol } from './constants.ts';\nimport type {\n IRouter,\n RouterOptions,\n RouterOptionsInput,\n RouterPipelineContext,\n} from './types.ts';\nimport { acceptsJson, isRouterInstance } from './utils.ts';\n\nexport class Router implements IRouter {\n readonly '@instanceof' = RouterSymbol;\n\n /**\n * A label for the router instance.\n */\n readonly name?: string;\n\n /**\n * Array of mounted layers, routes & routers.\n *\n * @protected\n */\n protected stack: (Router | Handler)[] = [];\n\n /**\n * Path matcher for the current mount path.\n *\n * @protected\n */\n protected pathMatcher: PathMatcher | undefined;\n\n /**\n * A hook manager.\n *\n * @protected\n */\n protected hookManager: HookManager;\n\n /**\n * Normalized options for this router instance.\n */\n protected _options: Partial<RouterOptions>;\n\n // --------------------------------------------------\n\n constructor(input: RouterOptionsInput = {}) {\n this.name = input.name;\n\n this.hookManager = new HookManager();\n this._options = normalizeRouterOptions(input);\n\n this.setPath(input.path);\n }\n\n // --------------------------------------------------\n\n matchPath(path: string): boolean {\n if (this.pathMatcher) {\n return this.pathMatcher.test(path);\n }\n\n return true;\n }\n\n setPath(value?: Path) {\n if (value === '/' || typeof value === 'undefined') {\n this.pathMatcher = undefined;\n return;\n }\n\n this.pathMatcher = new PathMatcher(\n withLeadingSlash(withoutTrailingSlash(`${value}`)),\n { end: false },\n );\n }\n\n // --------------------------------------------------\n\n /**\n * Public entry point — creates a DispatcherEvent from the request,\n * runs the pipeline, and returns a Response (with 404/500 fallbacks).\n */\n async fetch(request: RoutupRequest): Promise<Response> {\n const event = new DispatcherEvent(request);\n\n let response: Response | undefined;\n\n try {\n response = await this.dispatch(event);\n } catch (e) {\n event.error = createError(e);\n }\n\n if (response) {\n return response;\n }\n\n if (event.error) {\n const status = event.error.statusCode || 500;\n const message = event.error.statusMessage || 'Internal Server Error';\n return this.buildFallbackResponse(request, event, status, message);\n }\n\n return this.buildFallbackResponse(request, event, 404, 'Not Found');\n }\n\n protected buildFallbackResponse(request: RoutupRequest, event: IDispatcherEvent, status: number, message: string): Response {\n const headers = new Headers(event.response.headers);\n\n if (acceptsJson(request)) {\n headers.set('content-type', 'application/json; charset=utf-8');\n return new Response(JSON.stringify({ status, message }), {\n status,\n statusText: message,\n headers,\n });\n }\n\n headers.set('content-type', 'text/plain; charset=utf-8');\n return new Response(message, {\n status,\n statusText: message,\n headers,\n });\n }\n\n // --------------------------------------------------\n\n protected async executePipelineStep(context: RouterPipelineContext): Promise<void> {\n switch (context.step) {\n case RouterPipelineStep.START: {\n return this.executePipelineStepStart(context);\n }\n case RouterPipelineStep.LOOKUP: {\n return this.executePipelineStepLookup(context);\n }\n case RouterPipelineStep.CHILD_BEFORE: {\n return this.executePipelineStepChildBefore(context);\n }\n case RouterPipelineStep.CHILD_DISPATCH: {\n return this.executePipelineStepChildDispatch(context);\n }\n case RouterPipelineStep.CHILD_AFTER: {\n return this.executePipelineStepChildAfter(context);\n }\n case RouterPipelineStep.FINISH:\n default: {\n return this.executePipelineStepFinish(context);\n }\n }\n }\n\n protected async executePipelineStepStart(context: RouterPipelineContext): Promise<void> {\n await this.hookManager.trigger(HookName.REQUEST, context.event);\n\n if (context.event.dispatched) {\n context.step = RouterPipelineStep.FINISH;\n } else {\n context.step = RouterPipelineStep.LOOKUP;\n }\n\n return this.executePipelineStep(context);\n }\n\n protected async executePipelineStepLookup(context: RouterPipelineContext): Promise<void> {\n while (\n !context.event.dispatched &&\n context.stackIndex < this.stack.length\n ) {\n const item = this.stack[context.stackIndex]!;\n\n if (isHandler(item)) {\n if (\n (context.event.error && item.type === HandlerType.CORE) ||\n (!context.event.error && item.type === HandlerType.ERROR)\n ) {\n context.stackIndex++;\n continue;\n }\n\n const match = item.matchPath(context.event.path);\n\n if (match) {\n if (item.method) {\n context.event.methodsAllowed.push(item.method);\n }\n\n if (item.matchMethod(context.event.method as `${MethodName}`)) {\n await this.hookManager.trigger(HookName.CHILD_MATCH, context.event);\n\n if (context.event.dispatched) {\n context.step = RouterPipelineStep.FINISH;\n } else {\n context.step = RouterPipelineStep.CHILD_BEFORE;\n }\n\n return this.executePipelineStep(context);\n }\n }\n\n context.stackIndex++;\n continue;\n }\n\n const match = item.matchPath(context.event.path);\n\n if (match) {\n await this.hookManager.trigger(HookName.CHILD_MATCH, context.event);\n\n if (context.event.dispatched) {\n context.step = RouterPipelineStep.FINISH;\n } else {\n context.step = RouterPipelineStep.CHILD_BEFORE;\n }\n\n return this.executePipelineStep(context);\n }\n\n context.stackIndex++;\n }\n\n context.step = RouterPipelineStep.FINISH;\n return this.executePipelineStep(context);\n }\n\n protected async executePipelineStepChildBefore(context: RouterPipelineContext): Promise<void> {\n await this.hookManager.trigger(HookName.CHILD_DISPATCH_BEFORE, context.event);\n\n if (context.event.dispatched) {\n context.step = RouterPipelineStep.FINISH;\n } else {\n context.step = RouterPipelineStep.CHILD_DISPATCH;\n }\n\n return this.executePipelineStep(context);\n }\n\n protected async executePipelineStepChildAfter(context: RouterPipelineContext): Promise<void> {\n await this.hookManager.trigger(HookName.CHILD_DISPATCH_AFTER, context.event);\n\n if (context.event.dispatched) {\n context.step = RouterPipelineStep.FINISH;\n } else {\n context.step = RouterPipelineStep.LOOKUP;\n }\n\n return this.executePipelineStep(context);\n }\n\n protected async executePipelineStepChildDispatch(context: RouterPipelineContext): Promise<void> {\n if (\n context.event.dispatched ||\n typeof this.stack[context.stackIndex] === 'undefined'\n ) {\n context.step = RouterPipelineStep.FINISH;\n return this.executePipelineStep(context);\n }\n\n const item = this.stack[context.stackIndex]!;\n const { event } = context;\n\n try {\n event.setNext(async (error?: Error) => {\n if (error) {\n event.error = createError(error);\n }\n\n // Continue pipeline from the next stack item\n const nextContext: RouterPipelineContext = {\n step: RouterPipelineStep.LOOKUP,\n event,\n stackIndex: context.stackIndex + 1,\n response: undefined,\n };\n\n await this.executePipelineStep(nextContext);\n\n return nextContext.response;\n });\n\n const response = await item.dispatch(event);\n\n if (response) {\n context.response = response;\n event.dispatched = true;\n }\n } catch (e) {\n event.error = createError(e);\n\n await this.hookManager.trigger(HookName.ERROR, event);\n }\n\n context.stackIndex++;\n context.step = RouterPipelineStep.CHILD_AFTER;\n\n return this.executePipelineStep(context);\n }\n\n protected async executePipelineStepFinish(context: RouterPipelineContext): Promise<void> {\n if (context.event.error || context.event.dispatched) {\n return this.hookManager.trigger(HookName.RESPONSE, context.event);\n }\n\n if (\n !context.event.dispatched &&\n context.event.routerPath.length === 1 &&\n context.event.method &&\n context.event.method === MethodName.OPTIONS\n ) {\n if (context.event.methodsAllowed.includes(MethodName.GET)) {\n context.event.methodsAllowed.push(MethodName.HEAD);\n }\n\n distinctArray(context.event.methodsAllowed);\n\n const options = context.event.methodsAllowed\n .map((key) => key.toUpperCase())\n .join(',');\n\n const optionsHeaders = new Headers(context.event.response.headers);\n optionsHeaders.set(HeaderName.ALLOW, options);\n context.response = new Response(options, {\n status: context.event.response.status || 200,\n statusText: context.event.response.statusText,\n headers: optionsHeaders,\n });\n\n context.event.dispatched = true;\n }\n\n return this.hookManager.trigger(HookName.RESPONSE, context.event);\n }\n\n // --------------------------------------------------\n\n async dispatch(\n event: IDispatcherEvent,\n ): Promise<Response | undefined> {\n if (this.pathMatcher) {\n const output = this.pathMatcher.exec(event.path);\n if (typeof output !== 'undefined') {\n event.mountPath = cleanDoubleSlashes(`${event.mountPath}/${output.path}`);\n\n if (event.path === output.path) {\n event.path = '/';\n } else {\n event.path = withLeadingSlash(event.path.substring(output.path.length));\n }\n\n event.params = {\n ...event.params,\n ...output.params,\n };\n }\n }\n\n const context: RouterPipelineContext = {\n step: RouterPipelineStep.START,\n event,\n stackIndex: 0,\n };\n\n event.routerPath.push({ name: this.name, options: this._options });\n\n try {\n await this.executePipelineStep(context);\n } finally {\n event.routerPath.pop();\n }\n\n return context.response;\n }\n\n // --------------------------------------------------\n\n delete(...handlers: (Handler | HandlerOptions)[]): this;\n\n delete(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;\n\n delete(...input: (Path | Handler | HandlerOptions)[]): this {\n this.useForMethod(MethodName.DELETE, ...input);\n\n return this;\n }\n\n get(...handlers: (Handler | HandlerOptions)[]): this;\n\n get(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;\n\n get(...input: (Path | Handler | HandlerOptions)[]): this {\n this.useForMethod(MethodName.GET, ...input);\n\n return this;\n }\n\n post(...handlers: (Handler | HandlerOptions)[]): this;\n\n post(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;\n\n post(...input: (Path | Handler | HandlerOptions)[]): this {\n this.useForMethod(MethodName.POST, ...input);\n\n return this;\n }\n\n put(...handlers: (Handler | HandlerOptions)[]): this;\n\n put(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;\n\n put(...input: (Path | Handler | HandlerOptions)[]): this {\n this.useForMethod(MethodName.PUT, ...input);\n\n return this;\n }\n\n patch(...handlers: (Handler | HandlerOptions)[]): this;\n\n patch(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;\n\n patch(...input: (Path | Handler | HandlerOptions)[]): this {\n this.useForMethod(MethodName.PATCH, ...input);\n\n return this;\n }\n\n head(...handlers: (Handler | HandlerOptions)[]): this;\n\n head(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;\n\n head(...input: (Path | Handler | HandlerOptions)[]): this {\n this.useForMethod(MethodName.HEAD, ...input);\n\n return this;\n }\n\n options(...handlers: (Handler | HandlerOptions)[]): this;\n\n options(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;\n\n options(...input: (Path | Handler | HandlerOptions)[]): this {\n this.useForMethod(MethodName.OPTIONS, ...input);\n\n return this;\n }\n\n // --------------------------------------------------\n\n protected useForMethod(\n method: MethodName,\n ...input: (Path | Handler | HandlerOptions)[]\n ) {\n let path: Path | undefined;\n\n for (const element of input) {\n if (isPath(element)) {\n path = element;\n continue;\n }\n\n if (isHandlerOptions(element)) {\n if (path) {\n element.path = path;\n }\n\n element.method = method;\n\n this.use(element);\n\n continue;\n }\n\n if (isHandler(element)) {\n if (path) {\n element.setPath(path);\n }\n\n element.setMethod(method);\n\n this.use(element);\n }\n }\n }\n\n // --------------------------------------------------\n\n use(router: Router): this;\n\n use(handler: Handler | HandlerOptions): this;\n\n use(plugin: Plugin): this;\n\n use(path: Path, router: Router): this;\n\n use(path: Path, handler: Handler | HandlerOptions): this;\n\n use(path: Path, plugin: Plugin): this;\n\n use(...input: unknown[]): this {\n let path: Path | undefined;\n for (const item of input) {\n if (isPath(item)) {\n path = withLeadingSlash(item);\n continue;\n }\n\n if (isRouterInstance(item)) {\n if (path) {\n item.setPath(path);\n }\n this.stack.push(item);\n continue;\n }\n\n if (isHandlerOptions(item)) {\n item.path = path || item.path;\n\n this.stack.push(new Handler(item));\n continue;\n }\n\n if (isHandler(item)) {\n item.setPath(path || item.path);\n\n this.stack.push(item);\n continue;\n }\n\n if (isPlugin(item)) {\n if (path) {\n this.install(item, { path });\n } else {\n this.install(item);\n }\n }\n }\n\n return this;\n }\n\n // --------------------------------------------------\n protected install(\n plugin: Plugin,\n context: PluginInstallContext = {},\n ): this {\n const name = context.name || plugin.name;\n\n const router = new Router({ name });\n plugin.install(router);\n\n if (context.path) {\n this.use(context.path, router);\n } else {\n this.use(router);\n }\n\n return this;\n }\n\n //---------------------------------------------------------------------------------\n\n /**\n * Add a hook listener.\n *\n * @param name\n * @param fn\n */\n on(\n name: `${HookName.REQUEST}` |\n `${HookName.RESPONSE}` |\n `${HookName.CHILD_DISPATCH_BEFORE}` |\n `${HookName.CHILD_DISPATCH_AFTER}`,\n fn: HookDefaultListener\n ): HookUnsubscribeFn;\n\n on(\n name: `${HookName.CHILD_MATCH}`,\n fn: HookDefaultListener\n ): HookUnsubscribeFn;\n\n on(\n name: `${HookName.ERROR}`,\n fn: HookErrorListener\n ): HookUnsubscribeFn;\n\n on(name: `${HookName}`, fn: HookListener): HookUnsubscribeFn {\n return this.hookManager.addListener(name, fn);\n }\n\n /**\n * Remove single or all hook listeners.\n *\n * @param name\n */\n off(name: `${HookName}`): this;\n\n off(name: `${HookName}`, fn: HookListener): this;\n\n off(name: `${HookName}`, fn?: HookListener): this {\n if (typeof fn === 'undefined') {\n this.hookManager.removeListener(name);\n\n return this;\n }\n\n this.hookManager.removeListener(name, fn);\n return this;\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAY,aAAL,yBAAA,YAAA;AACH,YAAA,SAAA;AACA,YAAA,UAAA;AACA,YAAA,SAAA;AACA,YAAA,WAAA;AACA,YAAA,YAAA;AACA,YAAA,aAAA;AACA,YAAA,UAAA;;KACH;AAED,IAAY,aAAL,yBAAA,YAAA;AACH,YAAA,YAAA;AACA,YAAA,oBAAA;AACA,YAAA,qBAAA;AACA,YAAA,qBAAA;AACA,YAAA,mBAAA;AACA,YAAA,WAAA;AACA,YAAA,mBAAA;AACA,YAAA,yBAAA;AACA,YAAA,sBAAA;AACA,YAAA,oBAAA;AACA,YAAA,mBAAA;AACA,YAAA,kBAAA;AACA,YAAA,gBAAA;AACA,YAAA,YAAA;AACA,YAAA,UAAA;AACA,YAAA,UAAA;AACA,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AO,OAAO,aAAa;AAC3B,QAAK,YAAY,eAAe,KAAK;AAErC,UAAO;;AAGX,OAAK,YAAY,eAAe,MAAM,GAAG;AACzC,SAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routup",
3
- "version": "5.0.0-beta.2",
3
+ "version": "5.0.0-beta.3",
4
4
  "type": "module",
5
5
  "description": "Routup is a minimalistic http based routing framework.",
6
6
  "exports": {
@@ -8,8 +8,7 @@
8
8
  ".": {
9
9
  "node": {
10
10
  "types": "./dist/node.d.mts",
11
- "import": "./dist/node.mjs",
12
- "require": "./dist/node.cjs"
11
+ "import": "./dist/node.mjs"
13
12
  },
14
13
  "bun": {
15
14
  "types": "./dist/bun.d.mts",
@@ -25,14 +24,12 @@
25
24
  },
26
25
  "default": {
27
26
  "types": "./dist/generic.d.mts",
28
- "import": "./dist/generic.mjs",
29
- "require": "./dist/generic.cjs"
27
+ "import": "./dist/generic.mjs"
30
28
  }
31
29
  },
32
30
  "./node": {
33
31
  "types": "./dist/node.d.mts",
34
- "import": "./dist/node.mjs",
35
- "require": "./dist/node.cjs"
32
+ "import": "./dist/node.mjs"
36
33
  },
37
34
  "./bun": {
38
35
  "types": "./dist/bun.d.mts",
@@ -44,8 +41,7 @@
44
41
  },
45
42
  "./generic": {
46
43
  "types": "./dist/generic.d.mts",
47
- "import": "./dist/generic.mjs",
48
- "require": "./dist/generic.cjs"
44
+ "import": "./dist/generic.mjs"
49
45
  },
50
46
  "./cloudflare": {
51
47
  "types": "./dist/cloudflare.d.mts",
@@ -56,7 +52,6 @@
56
52
  "import": "./dist/service-worker.mjs"
57
53
  }
58
54
  },
59
- "main": "./dist/generic.cjs",
60
55
  "module": "./dist/generic.mjs",
61
56
  "types": "./dist/generic.d.mts",
62
57
  "files": [
@@ -108,7 +103,7 @@
108
103
  "path-to-regexp": "^8.4.2",
109
104
  "proxy-addr": "^2.0.7",
110
105
  "smob": "^1.5.0",
111
- "srvx": "^0.11.14",
106
+ "srvx": "^0.11.15",
112
107
  "uncrypto": "^0.1.3"
113
108
  },
114
109
  "devDependencies": {
@@ -116,13 +111,13 @@
116
111
  "@tada5hi/eslint-config": "^2.3.0",
117
112
  "@tada5hi/tsconfig": "^0.7.2",
118
113
  "@types/negotiator": "^0.6.4",
119
- "@types/node": "^25.1.0",
114
+ "@types/node": "^25.5.2",
120
115
  "@types/proxy-addr": "^2.0.3",
121
- "@vitest/coverage-v8": "^4.1.2",
122
- "eslint": "^10.1.0",
116
+ "@vitest/coverage-v8": "^4.1.3",
117
+ "eslint": "^10.2.0",
123
118
  "husky": "^9.1.7",
124
119
  "tsdown": "^0.21.5",
125
- "typescript": "^5.9.3",
120
+ "typescript": "^6.0.2",
126
121
  "typescript-eslint": "^8.57.2",
127
122
  "vitest": "^4.1.1"
128
123
  }
package/dist/bun.cjs DELETED
@@ -1,69 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-BTv-fDqY.cjs");
3
- let srvx_bun = require("srvx/bun");
4
- //#region src/_entries/bun.ts
5
- function serve(router, options) {
6
- return (0, srvx_bun.serve)({
7
- fetch: router.fetch.bind(router),
8
- ...options
9
- });
10
- }
11
- //#endregion
12
- exports.Handler = require_src.Handler;
13
- exports.HandlerSymbol = require_src.HandlerSymbol;
14
- exports.HandlerType = require_src.HandlerType;
15
- exports.HeaderName = require_src.HeaderName;
16
- exports.MethodName = require_src.MethodName;
17
- exports.PathMatcher = require_src.PathMatcher;
18
- exports.Router = require_src.Router;
19
- exports.RoutupError = require_src.RoutupError;
20
- exports.RoutupEvent = require_src.RoutupEvent;
21
- exports.appendResponseHeader = require_src.appendResponseHeader;
22
- exports.appendResponseHeaderDirective = require_src.appendResponseHeaderDirective;
23
- exports.createError = require_src.createError;
24
- exports.createEventStream = require_src.createEventStream;
25
- exports.defineCoreHandler = require_src.defineCoreHandler;
26
- exports.defineErrorHandler = require_src.defineErrorHandler;
27
- exports.fromNodeHandler = require_src.fromNodeHandler;
28
- exports.fromNodeMiddleware = require_src.fromNodeMiddleware;
29
- exports.fromWebHandler = require_src.fromWebHandler;
30
- exports.getRequestAcceptableCharset = require_src.getRequestAcceptableCharset;
31
- exports.getRequestAcceptableCharsets = require_src.getRequestAcceptableCharsets;
32
- exports.getRequestAcceptableContentType = require_src.getRequestAcceptableContentType;
33
- exports.getRequestAcceptableContentTypes = require_src.getRequestAcceptableContentTypes;
34
- exports.getRequestAcceptableEncoding = require_src.getRequestAcceptableEncoding;
35
- exports.getRequestAcceptableEncodings = require_src.getRequestAcceptableEncodings;
36
- exports.getRequestAcceptableLanguage = require_src.getRequestAcceptableLanguage;
37
- exports.getRequestAcceptableLanguages = require_src.getRequestAcceptableLanguages;
38
- exports.getRequestHeader = require_src.getRequestHeader;
39
- exports.getRequestHostName = require_src.getRequestHostName;
40
- exports.getRequestIP = require_src.getRequestIP;
41
- exports.getRequestProtocol = require_src.getRequestProtocol;
42
- exports.isError = require_src.isError;
43
- exports.isHandler = require_src.isHandler;
44
- exports.isHandlerOptions = require_src.isHandlerOptions;
45
- exports.isPath = require_src.isPath;
46
- exports.isPlugin = require_src.isPlugin;
47
- exports.isRequestCacheable = require_src.isRequestCacheable;
48
- exports.isResponseGone = require_src.isResponseGone;
49
- exports.isWebHandler = require_src.isWebHandler;
50
- exports.isWebHandlerProvider = require_src.isWebHandlerProvider;
51
- exports.matchRequestContentType = require_src.matchRequestContentType;
52
- exports.readBody = require_src.readBody;
53
- exports.sendAccepted = require_src.sendAccepted;
54
- exports.sendCreated = require_src.sendCreated;
55
- exports.sendFile = require_src.sendFile;
56
- exports.sendFormat = require_src.sendFormat;
57
- exports.sendRedirect = require_src.sendRedirect;
58
- exports.sendStream = require_src.sendStream;
59
- exports.serializeEventStreamMessage = require_src.serializeEventStreamMessage;
60
- exports.serve = serve;
61
- exports.setResponseCacheHeaders = require_src.setResponseCacheHeaders;
62
- exports.setResponseContentTypeByFileName = require_src.setResponseContentTypeByFileName;
63
- exports.setResponseGone = require_src.setResponseGone;
64
- exports.setResponseHeaderAttachment = require_src.setResponseHeaderAttachment;
65
- exports.setResponseHeaderContentType = require_src.setResponseHeaderContentType;
66
- exports.toResponse = require_src.toResponse;
67
- exports.useRequestNegotiator = require_src.useRequestNegotiator;
68
-
69
- //# sourceMappingURL=bun.cjs.map
package/dist/bun.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bun.cjs","names":[],"sources":["../src/_entries/bun.ts"],"sourcesContent":["import type { Server, ServerOptions } from 'srvx';\nimport { serve as srvxServe } from 'srvx/bun';\nimport type { Router } from '../router/module.ts';\n\nexport * from '../index.ts';\n\nexport function serve(router: Router, options?: Omit<ServerOptions, 'fetch'>): Server {\n return srvxServe({ fetch: router.fetch.bind(router), ...options });\n}\n"],"mappings":";;;;AAMA,SAAgB,MAAM,QAAgB,SAAgD;AAClF,SAAA,GAAA,SAAA,OAAiB;EAAE,OAAO,OAAO,MAAM,KAAK,OAAO;EAAE,GAAG;EAAS,CAAC"}
package/dist/bun.d.cts DELETED
@@ -1,8 +0,0 @@
1
- import { $ as RouterPipelineContext, A as sendAccepted, At as RoutupRequest, B as createEventStream, C as sendRedirect, Ct as PathMatcher, D as SendFileStats, Dt as IDispatcher, E as SendFileOptions, Et as PathMatcherOptions, F as isResponseGone, Ft as MethodName, G as isError, H as EventStreamMessage, I as setResponseGone, J as isPlugin, K as createError, L as serializeEventStreamMessage, M as setResponseHeaderAttachment, Mt as HTTPErrorInput, N as appendResponseHeader, Nt as RoutupError, O as sendFile, Ot as RoutupEvent, P as appendResponseHeaderDirective, Pt as HeaderName, Q as IRouter, R as EventStreamHandle, S as sendStream, St as isPath, T as SendFileContentOptions, Tt as PathMatcherExecResult, U as ResponseCacheHeadersOptions, V as EventStreamListener, W as setResponseCacheHeaders, X as PluginInstallContext, Y as Plugin, Z as PluginInstallFn, _ as getRequestHeader, _t as ErrorHandler, a as getRequestIP, at as WebHandler, b as toResponse, bt as HandlerSymbol, c as matchRequestContentType, ct as fromNodeMiddleware, d as getRequestAcceptableEncoding, dt as defineCoreHandler, et as isHandler, f as getRequestAcceptableEncodings, ft as CoreHandler, g as getRequestAcceptableContentTypes, gt as defineErrorHandler, h as getRequestAcceptableContentType, ht as HandlerOptions, i as RequestIpOptions, it as fromWebHandler, j as setResponseHeaderContentType, jt as RoutupResponse, k as sendCreated, kt as IRoutupEvent, l as getRequestAcceptableLanguage, lt as NodeHandler, m as getRequestAcceptableCharsets, mt as Handler, n as getRequestProtocol, nt as isWebHandler, o as RequestHostNameOptions, ot as WebHandlerProvider, p as getRequestAcceptableCharset, pt as CoreHandlerOptions, q as Router, r as useRequestNegotiator, rt as isWebHandlerProvider, s as getRequestHostName, st as fromNodeHandler, t as RequestProtocolOptions, tt as isHandlerOptions, u as getRequestAcceptableLanguages, ut as NodeMiddleware, v as isRequestCacheable, vt as ErrorHandlerOptions, w as sendFormat, wt as Path, x as setResponseContentTypeByFileName, xt as HandlerType, y as readBody, yt as HandlerBaseOptions, z as EventStreamOptions } from "./index-eUBZJk6a.cjs";
2
- import { Server, ServerOptions } from "srvx";
3
-
4
- //#region src/_entries/bun.d.ts
5
- declare function serve(router: Router, options?: Omit<ServerOptions, 'fetch'>): Server;
6
- //#endregion
7
- export { CoreHandler, CoreHandlerOptions, ErrorHandler, ErrorHandlerOptions, EventStreamHandle, EventStreamListener, EventStreamMessage, EventStreamOptions, HTTPErrorInput, Handler, HandlerBaseOptions, HandlerOptions, HandlerSymbol, HandlerType, HeaderName, IDispatcher, IRouter, IRoutupEvent, MethodName, NodeHandler, NodeMiddleware, Path, PathMatcher, PathMatcherExecResult, PathMatcherOptions, Plugin, PluginInstallContext, PluginInstallFn, RequestHostNameOptions, RequestIpOptions, RequestProtocolOptions, ResponseCacheHeadersOptions, Router, RouterPipelineContext, RoutupError, RoutupEvent, RoutupRequest, RoutupResponse, SendFileContentOptions, SendFileOptions, SendFileStats, WebHandler, WebHandlerProvider, appendResponseHeader, appendResponseHeaderDirective, createError, createEventStream, defineCoreHandler, defineErrorHandler, fromNodeHandler, fromNodeMiddleware, fromWebHandler, getRequestAcceptableCharset, getRequestAcceptableCharsets, getRequestAcceptableContentType, getRequestAcceptableContentTypes, getRequestAcceptableEncoding, getRequestAcceptableEncodings, getRequestAcceptableLanguage, getRequestAcceptableLanguages, getRequestHeader, getRequestHostName, getRequestIP, getRequestProtocol, isError, isHandler, isHandlerOptions, isPath, isPlugin, isRequestCacheable, isResponseGone, isWebHandler, isWebHandlerProvider, matchRequestContentType, readBody, sendAccepted, sendCreated, sendFile, sendFormat, sendRedirect, sendStream, serializeEventStreamMessage, serve, setResponseCacheHeaders, setResponseContentTypeByFileName, setResponseGone, setResponseHeaderAttachment, setResponseHeaderContentType, toResponse, useRequestNegotiator };
8
- //# sourceMappingURL=bun.d.cts.map
@@ -1,69 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-BTv-fDqY.cjs");
3
- let srvx_cloudflare = require("srvx/cloudflare");
4
- //#region src/_entries/cloudflare.ts
5
- function serve(router, options) {
6
- return (0, srvx_cloudflare.serve)({
7
- fetch: router.fetch.bind(router),
8
- ...options
9
- });
10
- }
11
- //#endregion
12
- exports.Handler = require_src.Handler;
13
- exports.HandlerSymbol = require_src.HandlerSymbol;
14
- exports.HandlerType = require_src.HandlerType;
15
- exports.HeaderName = require_src.HeaderName;
16
- exports.MethodName = require_src.MethodName;
17
- exports.PathMatcher = require_src.PathMatcher;
18
- exports.Router = require_src.Router;
19
- exports.RoutupError = require_src.RoutupError;
20
- exports.RoutupEvent = require_src.RoutupEvent;
21
- exports.appendResponseHeader = require_src.appendResponseHeader;
22
- exports.appendResponseHeaderDirective = require_src.appendResponseHeaderDirective;
23
- exports.createError = require_src.createError;
24
- exports.createEventStream = require_src.createEventStream;
25
- exports.defineCoreHandler = require_src.defineCoreHandler;
26
- exports.defineErrorHandler = require_src.defineErrorHandler;
27
- exports.fromNodeHandler = require_src.fromNodeHandler;
28
- exports.fromNodeMiddleware = require_src.fromNodeMiddleware;
29
- exports.fromWebHandler = require_src.fromWebHandler;
30
- exports.getRequestAcceptableCharset = require_src.getRequestAcceptableCharset;
31
- exports.getRequestAcceptableCharsets = require_src.getRequestAcceptableCharsets;
32
- exports.getRequestAcceptableContentType = require_src.getRequestAcceptableContentType;
33
- exports.getRequestAcceptableContentTypes = require_src.getRequestAcceptableContentTypes;
34
- exports.getRequestAcceptableEncoding = require_src.getRequestAcceptableEncoding;
35
- exports.getRequestAcceptableEncodings = require_src.getRequestAcceptableEncodings;
36
- exports.getRequestAcceptableLanguage = require_src.getRequestAcceptableLanguage;
37
- exports.getRequestAcceptableLanguages = require_src.getRequestAcceptableLanguages;
38
- exports.getRequestHeader = require_src.getRequestHeader;
39
- exports.getRequestHostName = require_src.getRequestHostName;
40
- exports.getRequestIP = require_src.getRequestIP;
41
- exports.getRequestProtocol = require_src.getRequestProtocol;
42
- exports.isError = require_src.isError;
43
- exports.isHandler = require_src.isHandler;
44
- exports.isHandlerOptions = require_src.isHandlerOptions;
45
- exports.isPath = require_src.isPath;
46
- exports.isPlugin = require_src.isPlugin;
47
- exports.isRequestCacheable = require_src.isRequestCacheable;
48
- exports.isResponseGone = require_src.isResponseGone;
49
- exports.isWebHandler = require_src.isWebHandler;
50
- exports.isWebHandlerProvider = require_src.isWebHandlerProvider;
51
- exports.matchRequestContentType = require_src.matchRequestContentType;
52
- exports.readBody = require_src.readBody;
53
- exports.sendAccepted = require_src.sendAccepted;
54
- exports.sendCreated = require_src.sendCreated;
55
- exports.sendFile = require_src.sendFile;
56
- exports.sendFormat = require_src.sendFormat;
57
- exports.sendRedirect = require_src.sendRedirect;
58
- exports.sendStream = require_src.sendStream;
59
- exports.serializeEventStreamMessage = require_src.serializeEventStreamMessage;
60
- exports.serve = serve;
61
- exports.setResponseCacheHeaders = require_src.setResponseCacheHeaders;
62
- exports.setResponseContentTypeByFileName = require_src.setResponseContentTypeByFileName;
63
- exports.setResponseGone = require_src.setResponseGone;
64
- exports.setResponseHeaderAttachment = require_src.setResponseHeaderAttachment;
65
- exports.setResponseHeaderContentType = require_src.setResponseHeaderContentType;
66
- exports.toResponse = require_src.toResponse;
67
- exports.useRequestNegotiator = require_src.useRequestNegotiator;
68
-
69
- //# sourceMappingURL=cloudflare.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloudflare.cjs","names":[],"sources":["../src/_entries/cloudflare.ts"],"sourcesContent":["import type { Server, ServerOptions } from 'srvx';\nimport { serve as srvxServe } from 'srvx/cloudflare';\nimport type { Router } from '../router/module.ts';\n\nexport * from '../index.ts';\n\nexport function serve(router: Router, options?: Omit<ServerOptions, 'fetch'>): Server {\n return srvxServe({ fetch: router.fetch.bind(router), ...options });\n}\n"],"mappings":";;;;AAMA,SAAgB,MAAM,QAAgB,SAAgD;AAClF,SAAA,GAAA,gBAAA,OAAiB;EAAE,OAAO,OAAO,MAAM,KAAK,OAAO;EAAE,GAAG;EAAS,CAAC"}
@@ -1,8 +0,0 @@
1
- import { $ as RouterPipelineContext, A as sendAccepted, At as RoutupRequest, B as createEventStream, C as sendRedirect, Ct as PathMatcher, D as SendFileStats, Dt as IDispatcher, E as SendFileOptions, Et as PathMatcherOptions, F as isResponseGone, Ft as MethodName, G as isError, H as EventStreamMessage, I as setResponseGone, J as isPlugin, K as createError, L as serializeEventStreamMessage, M as setResponseHeaderAttachment, Mt as HTTPErrorInput, N as appendResponseHeader, Nt as RoutupError, O as sendFile, Ot as RoutupEvent, P as appendResponseHeaderDirective, Pt as HeaderName, Q as IRouter, R as EventStreamHandle, S as sendStream, St as isPath, T as SendFileContentOptions, Tt as PathMatcherExecResult, U as ResponseCacheHeadersOptions, V as EventStreamListener, W as setResponseCacheHeaders, X as PluginInstallContext, Y as Plugin, Z as PluginInstallFn, _ as getRequestHeader, _t as ErrorHandler, a as getRequestIP, at as WebHandler, b as toResponse, bt as HandlerSymbol, c as matchRequestContentType, ct as fromNodeMiddleware, d as getRequestAcceptableEncoding, dt as defineCoreHandler, et as isHandler, f as getRequestAcceptableEncodings, ft as CoreHandler, g as getRequestAcceptableContentTypes, gt as defineErrorHandler, h as getRequestAcceptableContentType, ht as HandlerOptions, i as RequestIpOptions, it as fromWebHandler, j as setResponseHeaderContentType, jt as RoutupResponse, k as sendCreated, kt as IRoutupEvent, l as getRequestAcceptableLanguage, lt as NodeHandler, m as getRequestAcceptableCharsets, mt as Handler, n as getRequestProtocol, nt as isWebHandler, o as RequestHostNameOptions, ot as WebHandlerProvider, p as getRequestAcceptableCharset, pt as CoreHandlerOptions, q as Router, r as useRequestNegotiator, rt as isWebHandlerProvider, s as getRequestHostName, st as fromNodeHandler, t as RequestProtocolOptions, tt as isHandlerOptions, u as getRequestAcceptableLanguages, ut as NodeMiddleware, v as isRequestCacheable, vt as ErrorHandlerOptions, w as sendFormat, wt as Path, x as setResponseContentTypeByFileName, xt as HandlerType, y as readBody, yt as HandlerBaseOptions, z as EventStreamOptions } from "./index-eUBZJk6a.cjs";
2
- import { Server, ServerOptions } from "srvx";
3
-
4
- //#region src/_entries/cloudflare.d.ts
5
- declare function serve(router: Router, options?: Omit<ServerOptions, 'fetch'>): Server;
6
- //#endregion
7
- export { CoreHandler, CoreHandlerOptions, ErrorHandler, ErrorHandlerOptions, EventStreamHandle, EventStreamListener, EventStreamMessage, EventStreamOptions, HTTPErrorInput, Handler, HandlerBaseOptions, HandlerOptions, HandlerSymbol, HandlerType, HeaderName, IDispatcher, IRouter, IRoutupEvent, MethodName, NodeHandler, NodeMiddleware, Path, PathMatcher, PathMatcherExecResult, PathMatcherOptions, Plugin, PluginInstallContext, PluginInstallFn, RequestHostNameOptions, RequestIpOptions, RequestProtocolOptions, ResponseCacheHeadersOptions, Router, RouterPipelineContext, RoutupError, RoutupEvent, RoutupRequest, RoutupResponse, SendFileContentOptions, SendFileOptions, SendFileStats, WebHandler, WebHandlerProvider, appendResponseHeader, appendResponseHeaderDirective, createError, createEventStream, defineCoreHandler, defineErrorHandler, fromNodeHandler, fromNodeMiddleware, fromWebHandler, getRequestAcceptableCharset, getRequestAcceptableCharsets, getRequestAcceptableContentType, getRequestAcceptableContentTypes, getRequestAcceptableEncoding, getRequestAcceptableEncodings, getRequestAcceptableLanguage, getRequestAcceptableLanguages, getRequestHeader, getRequestHostName, getRequestIP, getRequestProtocol, isError, isHandler, isHandlerOptions, isPath, isPlugin, isRequestCacheable, isResponseGone, isWebHandler, isWebHandlerProvider, matchRequestContentType, readBody, sendAccepted, sendCreated, sendFile, sendFormat, sendRedirect, sendStream, serializeEventStreamMessage, serve, setResponseCacheHeaders, setResponseContentTypeByFileName, setResponseGone, setResponseHeaderAttachment, setResponseHeaderContentType, toResponse, useRequestNegotiator };
8
- //# sourceMappingURL=cloudflare.d.cts.map