@orieljs/routing 0.1.0-alpha.1 → 0.1.0-alpha.2
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.
- package/dist/index.d.ts +5 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -117,6 +117,11 @@ declare class BaseRouter implements Router {
|
|
|
117
117
|
permanentRedirect(from: string, to: string): RouteDefinition;
|
|
118
118
|
/** Route.view('/about', 'pages.about', data): GET/HEAD; route parameters are merged into the view data. */
|
|
119
119
|
view(uri: string, view: string, data?: Record<string, unknown>): RouteDefinition;
|
|
120
|
+
/**
|
|
121
|
+
* Route.inertia('/about', 'About', props): GET/HEAD; renders the page through the InertiaFactory (resolved when
|
|
122
|
+
* the route runs, so Routing needs no Inertia import). Route parameters are merged into the props.
|
|
123
|
+
*/
|
|
124
|
+
inertia(uri: string, component: string, props?: Record<string, unknown>): RouteDefinition;
|
|
120
125
|
resource(name: string, controller: Class<unknown>, options?: ResourceOptions): void;
|
|
121
126
|
apiResource(name: string, controller: Class<unknown>, options?: ResourceOptions): void;
|
|
122
127
|
/** Matches any GET path no other route matches. Always tried last. */
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// BaseRouter.ts
|
|
2
2
|
import {
|
|
3
3
|
CurrentRoute as CurrentRoute2,
|
|
4
|
+
InertiaFactory,
|
|
4
5
|
UrlGenerator,
|
|
5
6
|
ViewFactory
|
|
6
7
|
} from "@orieljs/contracts";
|
|
@@ -643,6 +644,23 @@ var BaseRouter = class {
|
|
|
643
644
|
holder.route = this.addRoute(["GET", "HEAD"], uri, action);
|
|
644
645
|
return holder.route;
|
|
645
646
|
}
|
|
647
|
+
/**
|
|
648
|
+
* Route.inertia('/about', 'About', props): GET/HEAD; renders the page through the InertiaFactory (resolved when
|
|
649
|
+
* the route runs, so Routing needs no Inertia import). Route parameters are merged into the props.
|
|
650
|
+
*/
|
|
651
|
+
inertia(uri, component, props = {}) {
|
|
652
|
+
const holder = {};
|
|
653
|
+
const action = (...values) => {
|
|
654
|
+
const parameters = Object.fromEntries(holder.route.parameters.map((parameter, index) => [parameter.name, values[index]]));
|
|
655
|
+
const container = currentContainer2() ?? this.container;
|
|
656
|
+
if (container === void 0 || !container.bound(InertiaFactory)) {
|
|
657
|
+
throw new RoutingError(`Cannot render Inertia page [${component}]: no InertiaFactory is bound.`);
|
|
658
|
+
}
|
|
659
|
+
return container.make(InertiaFactory).render(component, { ...props, ...parameters });
|
|
660
|
+
};
|
|
661
|
+
holder.route = this.addRoute(["GET", "HEAD"], uri, action);
|
|
662
|
+
return holder.route;
|
|
663
|
+
}
|
|
646
664
|
resource(name, controller, options = {}) {
|
|
647
665
|
this.#registerResource(name, controller, options, false);
|
|
648
666
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../BaseRouter.ts","../dispatch.ts","../bindings.ts","../errors.ts","../middleware.ts","../toResponse.ts","../RouteDefinition.ts","../GroupRegistrar.ts","../resource.ts","../BaseUrlGenerator.ts","../facade.ts","../routeFiles.ts","../RoutingServiceProvider.ts"],"sourcesContent":["import {\n CurrentRoute,\n UrlGenerator,\n ViewFactory,\n type Class,\n type Container,\n type ControllerAction,\n type HttpRequest,\n type MiddlewareClass,\n type MiddlewareReference,\n type ResourceOptions,\n type RouteAction,\n type RouteClosure,\n type Router,\n} from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport { dispatchRoute } from './dispatch'\nimport { RoutingError } from './errors'\nimport { ALL_VERBS, GroupRegistrar, mergeGroup, type GroupAttributes } from './GroupRegistrar'\nimport { resourceRoutes } from './resource'\nimport { compareRoutes, RouteDefinition, type RouteHandler } from './RouteDefinition'\n\nexport type RouteBinder = (value: string) => unknown | Promise<unknown>\n\n/** Laravel's Illuminate\\Routing\\Router: registration, groups, patterns, bindings, middleware aliases/groups and dispatch. */\nexport class BaseRouter implements Router {\n readonly #routes: RouteDefinition[] = []\n #sorted: RouteDefinition[] | undefined\n readonly #groupStack: GroupAttributes[] = []\n readonly #patterns: Record<string, string> = {}\n #patternVersion = 0\n readonly #aliases: Record<string, MiddlewareClass> = {}\n readonly #groups: Record<string, MiddlewareReference[]> = { web: [], api: [] }\n readonly #binders = new Map<string, RouteBinder>()\n readonly #models = new Map<string, Class<unknown>>()\n\n /** `container` is the application; request-time lookups use the current (request) container first. */\n constructor(protected readonly container?: Container) {}\n\n get<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['GET', 'HEAD'], uri, action)\n }\n\n post<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['POST'], uri, action)\n }\n\n put<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['PUT'], uri, action)\n }\n\n patch<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['PATCH'], uri, action)\n }\n\n delete<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['DELETE'], uri, action)\n }\n\n options<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['OPTIONS'], uri, action)\n }\n\n any<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(ALL_VERBS, uri, action)\n }\n\n match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(methods, uri, action)\n }\n\n /** Registers a route with the current group's prefix, name prefix, middleware and controller. GET implies HEAD. */\n addRoute(methods: readonly string[], uri: string, action: RouteHandler, options: { fallback?: boolean } = {}): RouteDefinition {\n const group = this.#groupStack.at(-1) ?? {}\n const verbs = methods.map((method) => method.toUpperCase())\n if (verbs.includes('GET') && !verbs.includes('HEAD')) verbs.push('HEAD')\n if (typeof action === 'string' && group.controller === undefined) {\n throw new RoutingError(\n `Route action [${action}] needs a controller. Use Route.controller(X).group(...) or pass [Controller, '${action}'].`,\n )\n }\n const prefix = (group.prefix ?? '').replace(/^\\/+|\\/+$/g, '')\n const path = uri.replace(/^\\/+|\\/+$/g, '')\n const route = new RouteDefinition(verbs, [prefix, path].filter((part) => part !== '').join('/'), action, {\n ...(group.as !== undefined && { namePrefix: group.as }),\n ...(group.middleware !== undefined && { middleware: group.middleware }),\n ...(group.controller !== undefined && { controller: group.controller }),\n ...(options.fallback === true && { fallback: true }),\n })\n this.#routes.push(route)\n this.#sorted = undefined\n return route\n }\n\n /** Route.redirect('/here', '/there'): any verb, 302 by default; '{param}' in the target is filled from the URI. */\n redirect(from: string, to: string, status = 302): RouteDefinition {\n const holder: { route?: RouteDefinition } = {}\n const action = (...values: unknown[]) => {\n const parameters = new Map(holder.route!.parameters.map((parameter, index) => [parameter.name, values[index]]))\n const target = to.replace(/\\{(\\w+)\\??\\}/g, (_match, name: string) => {\n const value = parameters.get(name)\n return value === undefined || value === null ? '' : encodeURIComponent(String(value))\n })\n const container = currentContainer() ?? this.container\n const location = container?.bound(UrlGenerator) ? container.make(UrlGenerator).to(target) : target\n return new Response(null, { status, headers: { Location: location } })\n }\n holder.route = this.any(from, action)\n return holder.route\n }\n\n permanentRedirect(from: string, to: string): RouteDefinition {\n return this.redirect(from, to, 301)\n }\n\n /** Route.view('/about', 'pages.about', data): GET/HEAD; route parameters are merged into the view data. */\n view(uri: string, view: string, data: Record<string, unknown> = {}): RouteDefinition {\n const holder: { route?: RouteDefinition } = {}\n const action = (...values: unknown[]) => {\n const parameters = Object.fromEntries(holder.route!.parameters.map((parameter, index) => [parameter.name, values[index]]))\n const container = currentContainer() ?? this.container\n if (container === undefined) throw new RoutingError(`Cannot render view [${view}]: no container is available.`)\n return container.make(ViewFactory).make(view, { ...data, ...parameters })\n }\n holder.route = this.addRoute(['GET', 'HEAD'], uri, action)\n return holder.route\n }\n\n resource(name: string, controller: Class<unknown>, options: ResourceOptions = {}): void {\n this.#registerResource(name, controller, options, false)\n }\n\n apiResource(name: string, controller: Class<unknown>, options: ResourceOptions = {}): void {\n this.#registerResource(name, controller, options, true)\n }\n\n /** Matches any GET path no other route matches. Always tried last. */\n fallback(action: RouteAction): RouteDefinition {\n return this.addRoute(['GET', 'HEAD'], '{fallbackPlaceholder}', action, { fallback: true })\n }\n\n prefix(prefix: string): GroupRegistrar {\n return new GroupRegistrar(this).prefix(prefix)\n }\n\n name(prefix: string): GroupRegistrar {\n return new GroupRegistrar(this).name(prefix)\n }\n\n middleware(...middleware: MiddlewareReference[]): GroupRegistrar {\n return new GroupRegistrar(this).middleware(...middleware)\n }\n\n controller(controller: Class<unknown>): GroupRegistrar {\n return new GroupRegistrar(this).controller(controller)\n }\n\n /**\n * Laravel's Route::group(attributes, callback). A synchronous callback's attributes are popped before this\n * returns, so an unawaited group never leaks into later routes; an async callback keeps them until it settles.\n */\n group(attributes: GroupAttributes, routes: () => void | Promise<void>): Promise<void> {\n const entry = mergeGroup(this.#groupStack.at(-1) ?? {}, attributes)\n this.#groupStack.push(entry)\n const pop = () => {\n const index = this.#groupStack.lastIndexOf(entry)\n if (index !== -1) this.#groupStack.splice(index, 1)\n }\n let result: void | Promise<void>\n try {\n result = routes()\n } catch (error) {\n pop()\n throw error\n }\n if (result instanceof Promise) return result.finally(pop)\n pop()\n return Promise.resolve()\n }\n\n model(parameter: string, model: Class<unknown>): void {\n this.#models.set(parameter, model)\n }\n\n bind(parameter: string, resolver: RouteBinder): void {\n this.#binders.set(parameter, resolver)\n }\n\n pattern(parameter: string, pattern: string): void {\n this.#patterns[parameter] = pattern\n this.#patternVersion++\n }\n\n patterns(patterns: Record<string, string>): void {\n for (const [parameter, pattern] of Object.entries(patterns)) this.pattern(parameter, pattern)\n }\n\n getPatterns(): Readonly<Record<string, string>> {\n return { ...this.#patterns }\n }\n\n /** Bumped by pattern(); routes recompile their matcher when it changes. */\n getPatternVersion(): number {\n return this.#patternVersion\n }\n\n getBinder(parameter: string): RouteBinder | undefined {\n return this.#binders.get(parameter)\n }\n\n getModel(parameter: string): Class<unknown> | undefined {\n return this.#models.get(parameter)\n }\n\n aliasMiddleware(name: string, middleware: MiddlewareClass): this {\n this.#aliases[name] = middleware\n return this\n }\n\n /** The middleware aliases (Laravel's Router::getMiddleware()). */\n getMiddleware(): Record<string, MiddlewareClass> {\n return { ...this.#aliases }\n }\n\n middlewareGroup(name: string, middleware: MiddlewareReference[]): this {\n this.#groups[name] = [...middleware]\n return this\n }\n\n pushMiddlewareToGroup(group: string, middleware: MiddlewareReference): this {\n const list = (this.#groups[group] ??= [])\n if (!list.includes(middleware)) list.push(middleware)\n return this\n }\n\n prependMiddlewareToGroup(group: string, middleware: MiddlewareReference): this {\n const list = (this.#groups[group] ??= [])\n if (!list.includes(middleware)) list.unshift(middleware)\n return this\n }\n\n hasMiddlewareGroup(name: string): boolean {\n return Object.hasOwn(this.#groups, name)\n }\n\n getMiddlewareGroups(): Record<string, MiddlewareReference[]> {\n return Object.fromEntries(Object.entries(this.#groups).map(([name, list]) => [name, [...list]]))\n }\n\n /** Every route, in registration order. */\n getRoutes(): readonly RouteDefinition[] {\n return [...this.#routes]\n }\n\n /** Routes in matching order: static segments first, fallbacks last (cached until a route is added). */\n getRoutesByMatchOrder(): readonly RouteDefinition[] {\n return (this.#sorted ??= [...this.#routes].sort(compareRoutes))\n }\n\n /** The last route registered with this name wins, as in Laravel. */\n getByName(name: string): RouteDefinition | undefined {\n return this.#routes.findLast((route) => route.getName() === name)\n }\n\n has(...names: string[]): boolean {\n return names.every((name) => this.getByName(name) !== undefined)\n }\n\n /** The route matched for the current request (read from the request scope). */\n current(): RouteDefinition | undefined {\n const container = currentContainer()\n if (container === undefined || !container.bound(CurrentRoute)) return undefined\n return container.make(CurrentRoute).route as RouteDefinition\n }\n\n currentRouteName(): string | undefined {\n return this.current()?.getName()\n }\n\n /** Match, bind and run the route middleware and action (Router.dispatch; called by the Http kernel). */\n dispatch(request: HttpRequest): Promise<Response> {\n return dispatchRoute(this, request, this.container)\n }\n\n #registerResource(name: string, controller: Class<unknown>, options: ResourceOptions, api: boolean): void {\n for (const entry of resourceRoutes(name, options, api)) {\n this.addRoute(entry.verbs, entry.uri, [controller, entry.method] as RouteAction).name(entry.name)\n }\n }\n}\n","import { CurrentRoute, type Class, type Container, type HttpRequest, type OrielError } from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport type { BaseRouter } from './BaseRouter'\nimport { orderForBindings, substituteBindings } from './bindings'\nimport { MethodNotAllowedHttpError, NotFoundHttpError, RoutingError } from './errors'\nimport { resolveMiddleware, runMiddleware } from './middleware'\nimport { normalizePath, type RouteDefinition } from './RouteDefinition'\n\n/** [Controller, 'missing'] (Laravel's BadMethodCallException). */\nexport class ControllerMethodNotFoundError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'ControllerMethodNotFoundError'\n constructor(controller: string, method: string) {\n super(`Method ${controller}::${method} does not exist.`)\n }\n}\n\n// Duplicated in Pipeline's BasePipeline.ts on purpose: Http, Routing and Pipeline may not import each other.\nconst isClass = (value: unknown): value is Class<object> =>\n typeof value === 'function' && /^class[\\s{]/.test(Function.prototype.toString.call(value))\n\ntype Match = { route: RouteDefinition; values: Record<string, string | undefined> } | { response: Response }\n\nfunction findRoute(router: BaseRouter, request: HttpRequest): Match {\n const method = request.method().toUpperCase()\n const path = normalizePath(new URL(request.raw.url).pathname)\n const patterns = router.getPatterns()\n const version = router.getPatternVersion()\n const allowed = new Set<string>()\n for (const route of router.getRoutesByMatchOrder()) {\n const values = route.match(path, patterns, version)\n if (values === undefined) continue\n if (route.methods.includes(method)) return { route, values }\n // A fallback never turns an unknown POST into a 405.\n if (!route.isFallback) for (const verb of route.methods) allowed.add(verb)\n }\n if (allowed.size > 0) {\n // Laravel's automatic OPTIONS response.\n if (method === 'OPTIONS') return { response: new Response(null, { status: 200, headers: { Allow: [...allowed].join(', ') } }) }\n throw new MethodNotAllowedHttpError(method, request.path(), [...allowed])\n }\n throw new NotFoundHttpError(request.path())\n}\n\n/** Calls the route action with the parameters in URI order. Controllers are built by the request scope. */\nasync function runAction(scope: Container, route: RouteDefinition, parameters: Record<string, unknown>): Promise<unknown> {\n const args = route.parameters.map((parameter) => parameters[parameter.name])\n const action = route.action\n if (typeof action === 'function' && !isClass(action)) return (action as (...values: unknown[]) => unknown)(...args)\n const [cls, method] =\n typeof action === 'string'\n ? [route.controller as Class<object>, action]\n : isClass(action)\n ? [action, '__invoke']\n : [action[0] as Class<object>, String(action[1])]\n const controller = scope.make(cls) as Record<string, unknown>\n const handler = controller[method]\n if (typeof handler !== 'function') throw new ControllerMethodNotFoundError(cls.name, method)\n return (handler as (...values: unknown[]) => unknown).apply(controller, args)\n}\n\n/**\n * Router::dispatch: match, record the current route in the request scope, then run the route middleware and the\n * action. Matching errors (404/405) are thrown for the kernel's stage to render.\n */\nexport async function dispatchRoute(router: BaseRouter, request: HttpRequest, container?: Container): Promise<Response> {\n const scope = currentContainer() ?? container\n if (scope === undefined) throw new RoutingError('Cannot dispatch a request: no container is available.')\n const match = findRoute(router, request)\n if ('response' in match) return match.response\n const { route, values } = match\n\n const state: CurrentRoute = { route, parameters: { ...values }, middleware: [] }\n scope.instance(CurrentRoute, state)\n\n const middleware = resolveMiddleware(\n route.gatherMiddleware(),\n route.excludedMiddleware(),\n router.getMiddleware(),\n router.getMiddlewareGroups(),\n )\n const ordered = orderForBindings(router, middleware)\n return runMiddleware(scope, request, ordered.middleware, state.middleware, () => runAction(scope, route, state.parameters), {\n at: ordered.at,\n run: async () => void Object.assign(state.parameters, await substituteBindings(router, route, values, scope)),\n })\n}\n","import { RouteModelResolver, type Container, type MiddlewareClass } from '@orieljs/contracts'\nimport { BindingResolutionError } from '@orieljs/container'\nimport { Str } from '@orieljs/support'\nimport type { BaseRouter } from './BaseRouter'\nimport { RouteModelNotFoundError } from './errors'\nimport { resolveMiddleware, type ResolvedMiddleware } from './middleware'\nimport type { RouteDefinition } from './RouteDefinition'\n\n/**\n * Laravel's $middlewarePriority around SubstituteBindings: the `web`/`api` group middleware and the `auth`/`guest`\n * aliases run before binding, every other route middleware after it (so `can:` sees the models, and a guest is\n * redirected before any lookup). Returns the middleware in that order (stable within each part) and the index\n * where the binding stage runs.\n */\nexport function orderForBindings(\n router: BaseRouter,\n middleware: readonly ResolvedMiddleware[],\n): { middleware: ResolvedMiddleware[]; at: number } {\n const aliases = router.getMiddleware()\n const groups = router.getMiddlewareGroups()\n const early = new Set<MiddlewareClass>()\n for (const name of ['auth', 'guest']) if (Object.hasOwn(aliases, name)) early.add(aliases[name]!)\n for (const group of ['web', 'api']) {\n try {\n for (const entry of resolveMiddleware([group], [], aliases, groups)) early.add(entry.cls)\n } catch {\n // A group naming an unknown alias fails the routes that use it, when they resolve their middleware.\n }\n }\n const before = middleware.filter((entry) => early.has(entry.cls))\n const after = middleware.filter((entry) => !early.has(entry.cls))\n return { middleware: [...before, ...after], at: before.length }\n}\n\n/**\n * Laravel's SubstituteBindings, run as a route stage (see orderForBindings), in URI order:\n * 1. Route.bind(name, fn): the callback's result, whatever it is\n * 2. Route.model(name, Model): RouteModelResolver.resolveExplicit(); nothing found → 404\n * 3. implicit: RouteModelResolver.resolve(name, value, field); undefined keeps the string, null → 404\n * Missing optional parameters stay undefined. Without a resolver, implicit binding is skipped.\n */\nexport async function substituteBindings(\n router: BaseRouter,\n route: RouteDefinition,\n values: Readonly<Record<string, string | undefined>>,\n container: Container,\n): Promise<Record<string, unknown>> {\n const resolver = container.bound(RouteModelResolver) ? container.make(RouteModelResolver) : undefined\n const bound: Record<string, unknown> = {}\n for (const { name, field } of route.parameters) {\n const value = values[name]\n if (value === undefined) {\n bound[name] = undefined\n continue\n }\n const binder = router.getBinder(name)\n if (binder !== undefined) {\n bound[name] = await binder(value)\n continue\n }\n const model = router.getModel(name)\n if (model !== undefined) {\n if (resolver === undefined) {\n throw new BindingResolutionError(\n `Route.model('${name}', ${model.name}) needs a RouteModelResolver. Is the Database service provider registered?`,\n )\n }\n const found = await resolver.resolveExplicit(model, value, field)\n if (found === null || found === undefined) throw new RouteModelNotFoundError(model.name, value)\n bound[name] = found\n continue\n }\n if (resolver !== undefined) {\n const found = await resolver.resolve(name, value, field)\n if (found === null) throw new RouteModelNotFoundError(Str.studly(name), value)\n bound[name] = found === undefined ? value : found\n continue\n }\n bound[name] = value\n }\n return bound\n}\n","import type { ModelNotFoundError, OrielError } from '@orieljs/contracts'\n\n/** No route matches the path (Symfony's NotFoundHttpException). */\nexport class NotFoundHttpError extends Error implements OrielError {\n readonly kind = 'Http' as const\n readonly status = 404\n override readonly name = 'NotFoundHttpError'\n constructor(path: string) {\n super(`The route ${path} could not be found.`)\n }\n}\n\n/** The path exists, but not for this method. */\nexport class MethodNotAllowedHttpError extends Error implements OrielError {\n readonly kind = 'Http' as const\n readonly status = 405\n readonly headers: Record<string, string>\n override readonly name = 'MethodNotAllowedHttpError'\n constructor(method: string, path: string, allowed: string[]) {\n super(`The ${method} method is not supported for route ${path}. Supported methods: ${allowed.join(', ')}.`)\n this.headers = { Allow: allowed.join(', ') }\n }\n}\n\n/** route('x') for a name no route has (Symfony's RouteNotFoundException). */\nexport class RouteNotDefinedError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'RouteNotDefinedError'\n constructor(readonly routeName: string) {\n super(`Route [${routeName}] not defined.`)\n }\n}\n\n/** route('posts.show') without a required parameter. */\nexport class UrlGenerationError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UrlGenerationError'\n constructor(routeName: string, uri: string, missing: string[]) {\n super(`Missing required parameter for [Route: ${routeName}] [URI: ${uri}] [Missing parameter: ${missing.join(', ')}].`)\n }\n}\n\n/** Thrown by the router when a binding finds no row, so a missing model is always a 404. */\nexport class RouteModelNotFoundError extends Error implements ModelNotFoundError {\n readonly kind = 'ModelNotFound' as const\n readonly status = 404\n readonly ids: unknown[]\n override readonly name = 'RouteModelNotFoundError'\n constructor(readonly model: string, value: unknown) {\n super(`No query results for model [${model}] ${String(value)}`)\n this.ids = [value]\n }\n}\n\n/** Internal routing failures (a string action with no controller, a view route with no container, etc). */\nexport class RoutingError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'RoutingError'\n}\n","import {\n ExceptionHandler,\n PipelineFactory,\n type Container,\n type HttpRequest,\n type Middleware,\n type MiddlewareClass,\n type MiddlewareReference,\n type OrielError,\n} from '@orieljs/contracts'\nimport { RoutingError } from './errors'\nimport { toResponse } from './toResponse'\n\n/** A middleware reference after alias and group expansion: 'throttle:60,1' → { cls: Throttle, parameters: ['60', '1'] }. */\nexport interface ResolvedMiddleware {\n readonly cls: MiddlewareClass\n readonly parameters: readonly string[]\n}\n\n/** A string middleware that is neither an alias nor a group. */\nexport class MiddlewareNotFoundError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'MiddlewareNotFoundError'\n constructor(readonly middleware: string) {\n super(\n `Middleware [${middleware}] is not defined. Register it with Route.aliasMiddleware() or ` +\n `withMiddleware((m) => m.alias({ ... })).`,\n )\n }\n}\n\nfunction expand(\n references: readonly MiddlewareReference[],\n aliases: Readonly<Record<string, MiddlewareClass>>,\n groups: Readonly<Record<string, readonly MiddlewareReference[]>>,\n visiting: Set<string>,\n out: ResolvedMiddleware[],\n): void {\n for (const reference of references) {\n if (typeof reference === 'function') {\n out.push({ cls: reference, parameters: [] })\n continue\n }\n const index = reference.indexOf(':')\n const name = index === -1 ? reference : reference.slice(0, index)\n const parameters = index === -1 ? [] : reference.slice(index + 1).split(',')\n if (index === -1 && Object.hasOwn(groups, name)) {\n if (visiting.has(name)) throw new RoutingError(`Middleware group [${name}] includes itself.`)\n visiting.add(name)\n expand(groups[name]!, aliases, groups, visiting, out)\n visiting.delete(name)\n continue\n }\n if (!Object.hasOwn(aliases, name)) throw new MiddlewareNotFoundError(reference)\n out.push({ cls: aliases[name]!, parameters })\n }\n}\n\n/**\n * Expands aliases and groups (recursively), drops anything `excluded` resolves to (withoutMiddleware), and\n * removes duplicates (same class and parameters), keeping the first occurrence like Laravel's uniqueMiddleware.\n */\nexport function resolveMiddleware(\n references: readonly MiddlewareReference[],\n excluded: readonly MiddlewareReference[],\n aliases: Readonly<Record<string, MiddlewareClass>>,\n groups: Readonly<Record<string, readonly MiddlewareReference[]>>,\n): ResolvedMiddleware[] {\n const all: ResolvedMiddleware[] = []\n expand(references, aliases, groups, new Set(), all)\n const skipped: ResolvedMiddleware[] = []\n expand(excluded, aliases, groups, new Set(), skipped)\n const skippedClasses = new Set(skipped.map((entry) => entry.cls))\n const seen = new Set<string>()\n const classIds = new Map<MiddlewareClass, number>()\n return all.filter((entry) => {\n if (skippedClasses.has(entry.cls)) return false\n if (!classIds.has(entry.cls)) classIds.set(entry.cls, classIds.size)\n const key = `${classIds.get(entry.cls)}:${entry.parameters.join(',')}`\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\n/**\n * Renders an error as a Response through the bound ExceptionHandler (reporting it first), like Laravel's\n * Routing\\Pipeline::handleException. Without a handler the error is rethrown.\n */\nexport async function renderError(container: Container, request: HttpRequest, error: unknown): Promise<Response> {\n if (!container.bound(ExceptionHandler)) throw error\n const handler = container.make(ExceptionHandler)\n await handler.report(error)\n return handler.render(request, error)\n}\n\nasync function guard(container: Container, request: HttpRequest, run: () => Promise<unknown>): Promise<Response> {\n try {\n const result = await run()\n return result instanceof Response ? result : await toResponse(request, result)\n } catch (error) {\n return renderError(container, request, error)\n }\n}\n\n/** An extra pipeline stage that runs before `middleware[at]` (route model binding uses it). */\nexport interface RouteStage {\n readonly at: number\n run(request: HttpRequest): Promise<void>\n}\n\ntype RoutePipe = (passable: HttpRequest, next: (passable: HttpRequest) => Promise<unknown>) => Promise<Response>\n\n/**\n * Sends the request through the middleware (built from `container`, the request scope) to `destination`.\n * Every stage converts its own errors into a response, so outer middleware always get a Response back.\n * Built instances are pushed onto `instances` (for terminate()). `stage`, when given, runs at its position.\n */\nexport async function runMiddleware(\n container: Container,\n request: HttpRequest,\n middleware: readonly ResolvedMiddleware[],\n instances: Middleware[],\n destination: (request: HttpRequest) => Promise<unknown>,\n stage?: RouteStage,\n): Promise<Response> {\n const pipes: RoutePipe[] = middleware.map(({ cls, parameters }) => {\n const instance = container.make(cls)\n instances.push(instance)\n return (passable, next) =>\n guard(container, passable, () => instance.handle(passable, next as (r: HttpRequest) => Promise<Response>, ...parameters))\n })\n if (stage !== undefined) {\n pipes.splice(stage.at, 0, (passable, next) =>\n guard(container, passable, async () => {\n await stage.run(passable)\n return next(passable)\n }),\n )\n }\n return container\n .make(PipelineFactory)\n .make<HttpRequest>()\n .send(request)\n .through(pipes)\n .then((passable) => guard(container, passable, () => destination(passable)))\n}\n","/** Laravel's Router::toResponse: turns whatever an action returned into a Response. */\nexport async function toResponse(request: unknown, value: unknown): Promise<Response> {\n if (value instanceof Response) return value\n if (value === null || value === undefined) return new Response(null, { status: 204 })\n if (typeof value === 'string') return html(value)\n if (typeof value !== 'object') return html(String(value))\n\n const candidate = value as Record<string, unknown>\n // Responsable (redirects, Inertia responses, …)\n if (typeof candidate.toResponse === 'function') {\n return toResponse(request, await (candidate.toResponse as (request: unknown) => unknown).call(value, request))\n }\n // Renderable (a View from ViewFactory.make())\n if (typeof candidate.render === 'function') return html(String(await (candidate.render as () => unknown).call(value)))\n // Htmlable\n if (typeof candidate.toHtml === 'function') return html(String((candidate.toHtml as () => unknown).call(value)))\n if (typeof candidate.toJSON !== 'function') {\n // Jsonable, then Arrayable\n if (typeof candidate.toJson === 'function') return json(String((candidate.toJson as () => unknown).call(value)))\n if (typeof candidate.toArray === 'function') return json(JSON.stringify((candidate.toArray as () => unknown).call(value)))\n }\n // Plain objects, arrays, models and collections (via toJSON)\n return json(JSON.stringify(value))\n}\n\nfunction html(body: string): Response {\n return new Response(body, { headers: { 'content-type': 'text/html; charset=utf-8' } })\n}\n\n/** Explicit header: Response.json() says 'application/json' on Node but adds ';charset=utf-8' on Bun. */\nfunction json(body: string): Response {\n return new Response(body, { headers: { 'content-type': 'application/json' } })\n}\n","import type { Class, MiddlewareReference, Route, RouteAction } from '@orieljs/contracts'\n\n/** A closure, a [Controller, 'method'] tuple, or a method name inside Route.controller(X).group(). */\nexport type RouteHandler = RouteAction | string\n\nexport interface RouteAttributes {\n /** The group's name prefix ('admin.'); name() appends to it. */\n namePrefix?: string\n /** Group middleware; the route's own middleware() is appended after it. */\n middleware?: MiddlewareReference[]\n /** The group controller that string actions call. */\n controller?: Class<unknown>\n fallback?: boolean\n}\n\nexport interface UriParameter {\n readonly name: string\n readonly optional: boolean\n /** The binding column from '{post:slug}'. */\n readonly field: string | undefined\n}\n\n/** Exported for the URL generator, which reuses these instead of redeclaring them. */\nexport const PARAMETER = /\\{(\\w+)(?::(\\w+))?(\\?)?\\}/g\nexport const WHOLE_OPTIONAL = /^\\{(\\w+)(?::\\w+)?\\?\\}$/\nconst escapeRegex = (value: string) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\nexport function parseParameters(uri: string): UriParameter[] {\n return [...uri.matchAll(PARAMETER)].map((match) => ({ name: match[1]!, optional: match[3] === '?', field: match[2] }))\n}\n\n/** Laravel stores URIs without surrounding slashes, and '/' for the root. */\nexport function normalizeUri(uri: string): string {\n const trimmed = uri.replace(/^\\/+|\\/+$/g, '')\n return trimmed === '' ? '/' : trimmed\n}\n\n/** The form compiled patterns match against: '/posts/1/' → '/posts/1', '/' → ''. */\nexport function normalizePath(pathname: string): string {\n const trimmed = pathname.replace(/^\\/+|\\/+$/g, '').replace(/\\/{2,}/g, '/')\n return trimmed === '' ? '' : `/${trimmed}`\n}\n\nfunction decode(value: string): string {\n try {\n return decodeURIComponent(value)\n } catch {\n return value\n }\n}\n\n/** The pattern body (no anchors) for a normalised uri; '' for the root. */\nfunction compileBody(uri: string, wheres: Readonly<Record<string, string>>): string {\n if (uri === '/') return ''\n const group = (name: string) => `(?<p_${name}>${wheres[name] ?? '[^/]+'})`\n let body = ''\n for (const segment of uri.split('/')) {\n const whole = WHOLE_OPTIONAL.exec(segment)\n if (whole) {\n body += `(?:/${group(whole[1]!)})?`\n continue\n }\n let piece = ''\n let last = 0\n for (const match of segment.matchAll(PARAMETER)) {\n piece += escapeRegex(segment.slice(last, match.index)) + group(match[1]!) + (match[3] === '?' ? '?' : '')\n last = match.index + match[0].length\n }\n body += `/${piece}${escapeRegex(segment.slice(last))}`\n }\n return body\n}\n\nconst FALLBACK_SEGMENT = '{fallbackPlaceholder}'\n\n/**\n * Laravel's fallback is '{fallbackPlaceholder}' with where('.*') under the group prefix, so it stays scoped to it:\n * 'api/{fallbackPlaceholder}' matches /api and /api/any/depth but not /about; at the root it matches every path.\n */\nfunction compileFallback(uri: string, wheres: Readonly<Record<string, string>>): RegExp {\n const tail = '(?:/(?<p_fallbackPlaceholder>.*))?'\n if (uri === FALLBACK_SEGMENT) return new RegExp(`^${tail}$`, 's')\n if (!uri.endsWith(`/${FALLBACK_SEGMENT}`)) return new RegExp(`^${compileBody(uri, { ...wheres, fallbackPlaceholder: '.*' })}$`, 's')\n return new RegExp(`^${compileBody(uri.slice(0, -FALLBACK_SEGMENT.length - 1), wheres)}${tail}$`, 's')\n}\n\n/** Sort order for matching: fallbacks last, then per-segment specificity; ties keep registration order. */\nexport function compareRoutes(a: RouteDefinition, b: RouteDefinition): number {\n if (a.isFallback !== b.isFallback) return a.isFallback ? 1 : -1\n const left = a.rank()\n const right = b.rank()\n for (let i = 0; i < Math.max(left.length, right.length); i++) {\n const x = left[i] ?? -1\n const y = right[i] ?? -1\n if (x !== y) return x - y\n }\n return 0\n}\n\nexport class RouteDefinition implements Route {\n readonly methods: readonly string[]\n readonly uri: string\n readonly action: RouteHandler\n readonly controller: Class<unknown> | undefined\n readonly isFallback: boolean\n readonly parameters: readonly UriParameter[]\n #name: string | undefined\n readonly #middleware: MiddlewareReference[]\n readonly #excluded: MiddlewareReference[] = []\n readonly #wheres: Record<string, string> = {}\n #compiled: { regex: RegExp; version: number } | undefined\n\n constructor(methods: readonly string[], uri: string, action: RouteHandler, attributes: RouteAttributes = {}) {\n this.methods = [...new Set(methods.map((method) => method.toUpperCase()))]\n this.uri = normalizeUri(uri)\n this.action = action\n this.controller = attributes.controller\n this.isFallback = attributes.fallback ?? false\n this.parameters = parseParameters(this.uri)\n this.#name = attributes.namePrefix === undefined || attributes.namePrefix === '' ? undefined : attributes.namePrefix\n this.#middleware = [...(attributes.middleware ?? [])]\n }\n\n getName(): string | undefined {\n return this.#name\n }\n\n /** Appends, like Laravel's $action['as'] .= $name. */\n name(name: string): this {\n this.#name = (this.#name ?? '') + name\n return this\n }\n\n middleware(...middleware: MiddlewareReference[]): this {\n this.#middleware.push(...middleware.flat())\n return this\n }\n\n withoutMiddleware(...middleware: MiddlewareReference[]): this {\n this.#excluded.push(...middleware.flat())\n return this\n }\n\n where(parameter: string | Record<string, string>, pattern?: string): this {\n if (typeof parameter === 'string') this.#wheres[parameter] = pattern ?? '[^/]+'\n else Object.assign(this.#wheres, parameter)\n this.#compiled = undefined\n return this\n }\n\n gatherMiddleware(): MiddlewareReference[] {\n return [...this.#middleware]\n }\n\n excludedMiddleware(): MiddlewareReference[] {\n return [...this.#excluded]\n }\n\n wheres(): Record<string, string> {\n return { ...this.#wheres }\n }\n\n getActionName(): string {\n if (typeof this.action === 'string') return `${this.controller?.name ?? 'Controller'}@${this.action}`\n if (Array.isArray(this.action)) return `${(this.action[0] as Class<unknown>).name}@${String(this.action[1])}`\n return 'Closure'\n }\n\n /** Decoded parameter values when `path` (normalizePath output) matches, else undefined. */\n match(\n path: string,\n patterns: Readonly<Record<string, string>> = {},\n version = 0,\n ): Record<string, string | undefined> | undefined {\n const found = this.#regex(patterns, version).exec(path)\n if (found === null) return undefined\n const values: Record<string, string | undefined> = {}\n for (const { name } of this.parameters) {\n const raw = found.groups?.[`p_${name}`]\n values[name] = raw === undefined ? undefined : decode(raw)\n }\n return values\n }\n\n /** Per-segment specificity: static 0, parameter 1, optional parameter 2. Lower sorts first. */\n rank(): number[] {\n if (this.uri === '/') return []\n return this.uri.split('/').map((segment) => (WHOLE_OPTIONAL.test(segment) ? 2 : segment.includes('{') ? 1 : 0))\n }\n\n #regex(patterns: Readonly<Record<string, string>>, version: number): RegExp {\n if (this.#compiled !== undefined && this.#compiled.version === version) return this.#compiled.regex\n const wheres = { ...patterns, ...this.#wheres }\n const regex = this.isFallback ? compileFallback(this.uri, wheres) : new RegExp(`^${compileBody(this.uri, wheres)}$`)\n this.#compiled = { regex, version }\n return regex\n }\n}\n","import type { Class, ControllerAction, MiddlewareReference, ResourceOptions, RouteClosure, RouteRegistrar } from '@orieljs/contracts'\nimport type { RouteDefinition, RouteHandler } from './RouteDefinition'\n\n/** Attributes shared by the routes of a group (Laravel's group attribute array). */\nexport interface GroupAttributes {\n prefix?: string\n /** Name prefix ('admin.'). */\n as?: string\n middleware?: MiddlewareReference[]\n controller?: Class<unknown>\n}\n\n/** What a GroupRegistrar needs from the router. */\nexport interface GroupHost {\n group(attributes: GroupAttributes, routes: () => void | Promise<void>): Promise<void>\n addRoute(methods: readonly string[], uri: string, action: RouteHandler): RouteDefinition\n resource(name: string, controller: Class<unknown>, options?: ResourceOptions): void\n apiResource(name: string, controller: Class<unknown>, options?: ResourceOptions): void\n}\n\n/** Every HTTP verb a route can respond to. BaseRouter reuses this instead of redeclaring it. */\nexport const ALL_VERBS = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']\n\n/** Merges a nested group's attributes into its parent's, like Laravel's RouteGroup::merge. */\nexport function mergeGroup(parent: GroupAttributes, child: GroupAttributes): GroupAttributes {\n const prefix = [parent.prefix, child.prefix]\n .map((part) => (part ?? '').replace(/^\\/+|\\/+$/g, ''))\n .filter((part) => part !== '')\n .join('/')\n const merged: GroupAttributes = {\n middleware: [...(parent.middleware ?? []), ...(child.middleware ?? [])],\n }\n if (prefix !== '') merged.prefix = prefix\n const as = (parent.as ?? '') + (child.as ?? '')\n if (as !== '') merged.as = as\n const controller = child.controller ?? parent.controller\n if (controller !== undefined) merged.controller = controller\n return merged\n}\n\n/**\n * Route.prefix('admin').name('admin.').middleware('auth').group(() => …), and the one-route form\n * Route.middleware('auth').get('/x', action) (Laravel's RouteRegistrar).\n */\nexport class GroupRegistrar implements RouteRegistrar {\n readonly #attributes: GroupAttributes = {}\n\n constructor(private readonly router: GroupHost) {}\n\n prefix(prefix: string): this {\n this.#attributes.prefix = prefix\n return this\n }\n\n name(prefix: string): this {\n this.#attributes.as = prefix\n return this\n }\n\n middleware(...middleware: MiddlewareReference[]): this {\n this.#attributes.middleware = [...(this.#attributes.middleware ?? []), ...middleware.flat()]\n return this\n }\n\n controller(controller: Class<unknown>): this {\n this.#attributes.controller = controller\n return this\n }\n\n group(routes: () => void | Promise<void>): Promise<void> {\n return this.router.group({ ...this.#attributes }, routes)\n }\n\n get<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['GET', 'HEAD'], uri, action)\n }\n\n post<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['POST'], uri, action)\n }\n\n put<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['PUT'], uri, action)\n }\n\n patch<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['PATCH'], uri, action)\n }\n\n delete<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['DELETE'], uri, action)\n }\n\n options<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['OPTIONS'], uri, action)\n }\n\n any<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(ALL_VERBS, uri, action)\n }\n\n match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(methods, uri, action)\n }\n\n resource(name: string, controller: Class<unknown>, options?: ResourceOptions): void {\n void this.router.group({ ...this.#attributes }, () => this.router.resource(name, controller, options))\n }\n\n apiResource(name: string, controller: Class<unknown>, options?: ResourceOptions): void {\n void this.router.group({ ...this.#attributes }, () => this.router.apiResource(name, controller, options))\n }\n\n #one(methods: readonly string[], uri: string, action: RouteHandler): RouteDefinition {\n let route: RouteDefinition | undefined\n void this.router.group({ ...this.#attributes }, () => {\n route = this.router.addRoute(methods, uri, action)\n })\n return route!\n }\n}\n","import type { ResourceOptions } from '@orieljs/contracts'\nimport { Str } from '@orieljs/support'\n\nexport type ResourceMethod = 'index' | 'create' | 'store' | 'show' | 'edit' | 'update' | 'destroy'\n\nexport interface ResourceRoute {\n readonly method: ResourceMethod\n readonly verbs: readonly string[]\n readonly uri: string\n readonly name: string\n}\n\n/** Laravel's order (ResourceRegistrar::$resourceDefaults). */\nconst DEFAULTS: readonly ResourceMethod[] = ['index', 'create', 'store', 'show', 'edit', 'update', 'destroy']\nconst API_DEFAULTS: readonly ResourceMethod[] = ['index', 'store', 'show', 'update', 'destroy']\n\n/** 'blog-posts' → 'blog_post' (Laravel's getResourceWildcard), unless options.parameters renames it. */\nfunction wildcard(segment: string, options: ResourceOptions): string {\n const renamed = options.parameters?.[segment]\n return (renamed ?? Str.singular(segment)).replace(/-/g, '_')\n}\n\n/**\n * The routes Route.resource()/apiResource() register. 'photos.comments' nests:\n * photos/{photo}/comments/{comment}, named photos.comments.*.\n */\nexport function resourceRoutes(name: string, options: ResourceOptions = {}, api = false): ResourceRoute[] {\n const segments = name.split('.')\n const last = segments.at(-1)!\n const base = [...segments.slice(0, -1).map((segment) => `${segment}/{${wildcard(segment, options)}}`), last].join('/')\n const member = `${base}/{${wildcard(last, options)}}`\n\n let methods = api ? API_DEFAULTS : DEFAULTS\n if (options.only !== undefined) methods = methods.filter((method) => options.only!.includes(method))\n if (options.except !== undefined) methods = methods.filter((method) => !options.except!.includes(method))\n\n const table: Record<ResourceMethod, { verbs: string[]; uri: string }> = {\n index: { verbs: ['GET', 'HEAD'], uri: base },\n create: { verbs: ['GET', 'HEAD'], uri: `${base}/create` },\n store: { verbs: ['POST'], uri: base },\n show: { verbs: ['GET', 'HEAD'], uri: member },\n edit: { verbs: ['GET', 'HEAD'], uri: `${member}/edit` },\n update: { verbs: ['PUT', 'PATCH'], uri: member },\n destroy: { verbs: ['DELETE'], uri: member },\n }\n return methods.map((method) => ({\n method,\n verbs: table[method].verbs,\n uri: table[method].uri,\n name: options.names?.[method] ?? `${name}.${method}`,\n }))\n}\n","import { ConfigRepository, HttpRequest, Session, type Container, type UrlGenerator } from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport type { BaseRouter } from './BaseRouter'\nimport { RouteNotDefinedError, UrlGenerationError } from './errors'\nimport { PARAMETER, WHOLE_OPTIONAL } from './RouteDefinition'\n\nconst VALID_URL = /^(#|\\/\\/|https?:\\/\\/|(mailto|tel|sms):)/i\n\n// Duplicated in Http's input.ts on purpose: Http, Routing and Pipeline may not import each other.\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const prototype = Object.getPrototypeOf(value) as unknown\n return prototype === Object.prototype || prototype === null\n}\n\n/** PHP's http_build_query: nested objects and arrays become a[b]=1&a[0]=2; null/undefined are skipped. */\nexport function buildQuery(values: Record<string, unknown>): string {\n const pairs: string[] = []\n const add = (key: string, value: unknown): void => {\n if (value === null || value === undefined) return\n if (typeof value === 'object' && (Array.isArray(value) || isPlainObject(value))) {\n for (const [child, nested] of Object.entries(value)) add(`${key}[${child}]`, nested)\n return\n }\n const text = value === true ? '1' : value === false ? '0' : String(value)\n pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(text)}`)\n }\n for (const [key, value] of Object.entries(values)) add(key, value)\n return pairs.join('&')\n}\n\n/** A model's URL value: the {post:slug} field when given, else getRouteKey(), else the value itself. */\nfunction routeKey(value: unknown, field: string | undefined): unknown {\n if (typeof value !== 'object' || value === null) return value\n const model = value as { getRouteKey?: () => unknown; getAttribute?: (key: string) => unknown } & Record<string, unknown>\n if (field !== undefined) return typeof model.getAttribute === 'function' ? model.getAttribute(field) : model[field]\n return typeof model.getRouteKey === 'function' ? model.getRouteKey() : value\n}\n\n/** Laravel's UrlGenerator. The root is the current request's origin, else config('app.url'). */\nexport class BaseUrlGenerator implements UrlGenerator {\n constructor(\n private readonly router: BaseRouter,\n private readonly container?: Container,\n ) {}\n\n /** 'http://localhost' (no trailing slash). */\n root(): string {\n const request = this.#request()\n if (request !== undefined) return new URL(request.url()).origin\n const configured = this.#config<string | undefined>('app.url', undefined)\n return (configured ?? 'http://localhost').replace(/\\/+$/, '')\n }\n\n to(path: string, query: Record<string, unknown> = {}, absolute = true): string {\n const queryString = buildQuery(query)\n const base = VALID_URL.test(path) ? path : this.#join(path, absolute)\n if (queryString === '') return base\n return `${base}${base.includes('?') ? '&' : '?'}${queryString}`\n }\n\n /**\n * route('posts.show', post) / route('posts.show', [post, comment]) / route('posts.show', { post: 1, page: 2 }).\n * Named values fill their parameters, positional values fill the rest in URI order; extra named values become\n * the query string, extra positional ones are dropped.\n */\n route(name: string, parameters?: unknown, absolute = true): string {\n const route = this.router.getByName(name)\n if (route === undefined) throw new RouteNotDefinedError(name)\n const named: Record<string, unknown> = isPlainObject(parameters) ? { ...parameters } : {}\n const positional: unknown[] = Array.isArray(parameters)\n ? [...parameters]\n : parameters === undefined || parameters === null || isPlainObject(parameters)\n ? []\n : [parameters]\n\n const values = new Map<string, string | undefined>()\n const missing: string[] = []\n for (const parameter of route.parameters) {\n let value: unknown\n if (Object.hasOwn(named, parameter.name)) {\n value = named[parameter.name]\n delete named[parameter.name]\n } else if (positional.length > 0) {\n value = positional.shift()\n }\n const key = routeKey(value, parameter.field)\n const text = key === undefined || key === null ? undefined : String(key)\n if (text === undefined && !parameter.optional) missing.push(parameter.name)\n values.set(parameter.name, text)\n }\n if (missing.length > 0) throw new UrlGenerationError(name, route.uri, missing)\n\n const path =\n route.uri === '/'\n ? ''\n : route.uri\n .split('/')\n .filter((segment) => {\n const whole = WHOLE_OPTIONAL.exec(segment)\n return whole === null || values.get(whole[1]!) !== undefined\n })\n .map((segment) =>\n segment.replace(PARAMETER, (_match, parameter: string) => {\n const value = values.get(parameter)\n return value === undefined ? '' : encodeURIComponent(value)\n }),\n )\n .join('/')\n const query = Object.fromEntries(Object.entries(named).map(([key, value]) => [key, routeKey(value, undefined)]))\n return this.to(path, query, absolute)\n }\n\n asset(path: string): string {\n if (VALID_URL.test(path)) return path\n const base = this.#config<string | undefined>('app.asset_url', undefined)?.replace(/\\/+$/, '') ?? this.root()\n const trimmed = path.replace(/^\\/+/, '')\n return trimmed === '' ? base : `${base}/${trimmed}`\n }\n\n /** The current URL without the query string. */\n current(): string {\n return this.#request()?.url() ?? this.root()\n }\n\n /** The current URL with the query string. */\n full(): string {\n return this.#request()?.fullUrl() ?? this.root()\n }\n\n /** The Referer header, then the session's previous URL, then `fallback`, then the root (Laravel's order). */\n previous(fallback?: string): string {\n const scope = this.#scope()\n const request = this.#request()\n const referer = request?.header('referer')\n if (referer !== undefined && referer !== '') return this.to(referer)\n if (request !== undefined && scope?.bound(Session)) {\n const previous = scope.make(Session).previousUrl()\n if (previous !== undefined && previous !== '') return this.to(previous)\n }\n return this.to(fallback ?? '/')\n }\n\n hasRoute(name: string): boolean {\n return this.router.getByName(name) !== undefined\n }\n\n #join(path: string, absolute: boolean): string {\n const trimmed = path.replace(/^\\/+|\\/+$/g, '')\n if (!absolute) return `/${trimmed}`\n return trimmed === '' ? this.root() : `${this.root()}/${trimmed}`\n }\n\n #scope(): Container | undefined {\n return currentContainer() ?? this.container\n }\n\n /** The HttpRequest, only when running inside a request scope. */\n #request(): HttpRequest | undefined {\n const scope = this.#scope()\n return scope?.bound(HttpRequest) ? scope.make(HttpRequest) : undefined\n }\n\n #config<T>(key: string, fallback: T): T {\n const scope = this.#scope()\n return scope?.bound(ConfigRepository) ? scope.make(ConfigRepository).get<T>(key, fallback) : fallback\n }\n}\n","import { Router, type Abstract } from '@orieljs/contracts'\nimport { facade } from '@orieljs/support'\nimport type { BaseRouter } from './BaseRouter'\n\n/**\n * The Route facade: Route.get('/', …), Route.prefix('admin').group(…), Route.resource(…). Typed as the BaseRouter\n * so the extras (permanentRedirect, patterns, has, currentRouteName, …) are available too.\n */\nexport const Route = facade<BaseRouter>(Router as Abstract<BaseRouter>)\n","import { pathToFileURL } from 'node:url'\nimport type { Application, Router } from '@orieljs/contracts'\n\n/** A route file may export a function instead of (or as well as) calling the Route facade at the top level. */\nexport type RouteFileCallback = (router: Router) => void | Promise<void>\n\nlet generation = 0\n\n/**\n * Imports a route file inside app.run(), so the Route facade in it resolves this application. Each load adds a\n * fresh `?oriel-routes=<n>` query: ESM caches modules, and a fresh app per test must register its routes again.\n * A default export that is a function is called with the router.\n */\nexport async function loadRoutesFrom(app: Application, router: Router, file: string): Promise<void> {\n const url = `${pathToFileURL(file).href}?oriel-routes=${++generation}`\n const module = (await app.run(() => import(/* @vite-ignore */ url))) as { default?: unknown }\n if (typeof module.default === 'function') await app.run(() => (module.default as RouteFileCallback)(router))\n}\n\n/** The health route's page (Laravel's `/up`): 200 as long as the application boots and handles requests. */\nexport function healthResponse(): Response {\n const html =\n '<!DOCTYPE html>\\n<html lang=\"en\">\\n<head>\\n<meta charset=\"utf-8\">\\n<title>Application up</title>\\n</head>\\n' +\n '<body><h1>Application up</h1></body>\\n</html>'\n return new Response(html, { status: 200, headers: { 'content-type': 'text/html; charset=utf-8' } })\n}\n","import { Router, RoutingPaths, UrlGenerator } from '@orieljs/contracts'\nimport { ServiceProvider } from '@orieljs/support'\nimport { BaseRouter } from './BaseRouter'\nimport { BaseUrlGenerator } from './BaseUrlGenerator'\nimport { RoutingError } from './errors'\nimport { healthResponse, loadRoutesFrom } from './routeFiles'\n\n/**\n * Binds the Router and the UrlGenerator, and once the app has booted loads the files given to withRouting(): the health URI,\n * then routes/web.ts in the `web` middleware group, then routes/api.ts under the api prefix in the `api` group\n * (Laravel's ApplicationBuilder::withRouting).\n */\nexport class RoutingServiceProvider extends ServiceProvider {\n override register(): void {\n this.app.singleton(Router, () => new BaseRouter(this.app))\n this.app.singleton(UrlGenerator, () => {\n const router = this.app.make(Router)\n if (!(router instanceof BaseRouter)) {\n throw new RoutingError('The UrlGenerator needs the BaseRouter: the bound Router was replaced by another implementation.')\n }\n return new BaseUrlGenerator(router, this.app)\n })\n }\n\n /**\n * The files load in a booted() callback, after every provider's boot() (Laravel's withRouting does the same), so\n * what the app's own providers set up at boot (Route.pattern/bind/model, gates, shared view data) is in place\n * when the route files run.\n */\n override boot(): void {\n this.app.booted(async () => {\n if (!this.app.bound(RoutingPaths)) return\n const { web, api, health, apiPrefix } = this.app.make(RoutingPaths)\n const router = this.app.make(Router)\n if (health !== undefined) router.get(health, () => healthResponse())\n if (web !== undefined) await router.middleware('web').group(() => loadRoutesFrom(this.app, router, web))\n if (api !== undefined) await router.prefix(apiPrefix).middleware('api').group(() => loadRoutesFrom(this.app, router, api))\n })\n }\n}\n"],"mappings":";AAAA;AAAA,EACE,gBAAAA;AAAA,EACA;AAAA,EACA;AAAA,OAWK;AACP,SAAS,oBAAAC,yBAAwB;;;ACfjC,SAAS,oBAAmF;AAC5F,SAAS,wBAAwB;;;ACDjC,SAAS,0BAAgE;AACzE,SAAS,8BAA8B;AACvC,SAAS,WAAW;;;ACCb,IAAM,oBAAN,cAAgC,MAA4B;AAAA,EACxD,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAAA,EACzB,YAAY,MAAc;AACxB,UAAM,aAAa,IAAI,sBAAsB;AAAA,EAC/C;AACF;AAGO,IAAM,4BAAN,cAAwC,MAA4B;AAAA,EAChE,OAAO;AAAA,EACP,SAAS;AAAA,EACT;AAAA,EACS,OAAO;AAAA,EACzB,YAAY,QAAgB,MAAc,SAAmB;AAC3D,UAAM,OAAO,MAAM,sCAAsC,IAAI,wBAAwB,QAAQ,KAAK,IAAI,CAAC,GAAG;AAC1G,SAAK,UAAU,EAAE,OAA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AAM,MAAM,eAAe,KAAK,KAAK,QAAQ,GAAG,CAAC;AACvG,UAAI,QAAQ,OAAW,OAAM,OAAO,OAAO,SAAS,EAAE,WAAW,KAAK,EAAE,MAAM,MAAM,eAAe,KAAK,KAAK,QAAQ,GAAG,CAAC;AAAA,IAC3H,CAAC;AAAA,EACH;AACF;","names":["CurrentRoute","currentContainer","Str","currentContainer","CurrentRoute","currentContainer","currentContainer","html","Router","UrlGenerator","Router","UrlGenerator"]}
|
|
1
|
+
{"version":3,"sources":["../BaseRouter.ts","../dispatch.ts","../bindings.ts","../errors.ts","../middleware.ts","../toResponse.ts","../RouteDefinition.ts","../GroupRegistrar.ts","../resource.ts","../BaseUrlGenerator.ts","../facade.ts","../routeFiles.ts","../RoutingServiceProvider.ts"],"sourcesContent":["import {\n CurrentRoute,\n InertiaFactory,\n UrlGenerator,\n ViewFactory,\n type Class,\n type Container,\n type ControllerAction,\n type HttpRequest,\n type MiddlewareClass,\n type MiddlewareReference,\n type ResourceOptions,\n type RouteAction,\n type RouteClosure,\n type Router,\n} from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport { dispatchRoute } from './dispatch'\nimport { RoutingError } from './errors'\nimport { ALL_VERBS, GroupRegistrar, mergeGroup, type GroupAttributes } from './GroupRegistrar'\nimport { resourceRoutes } from './resource'\nimport { compareRoutes, RouteDefinition, type RouteHandler } from './RouteDefinition'\n\nexport type RouteBinder = (value: string) => unknown | Promise<unknown>\n\n/** Laravel's Illuminate\\Routing\\Router: registration, groups, patterns, bindings, middleware aliases/groups and dispatch. */\nexport class BaseRouter implements Router {\n readonly #routes: RouteDefinition[] = []\n #sorted: RouteDefinition[] | undefined\n readonly #groupStack: GroupAttributes[] = []\n readonly #patterns: Record<string, string> = {}\n #patternVersion = 0\n readonly #aliases: Record<string, MiddlewareClass> = {}\n readonly #groups: Record<string, MiddlewareReference[]> = { web: [], api: [] }\n readonly #binders = new Map<string, RouteBinder>()\n readonly #models = new Map<string, Class<unknown>>()\n\n /** `container` is the application; request-time lookups use the current (request) container first. */\n constructor(protected readonly container?: Container) {}\n\n get<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['GET', 'HEAD'], uri, action)\n }\n\n post<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['POST'], uri, action)\n }\n\n put<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['PUT'], uri, action)\n }\n\n patch<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['PATCH'], uri, action)\n }\n\n delete<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['DELETE'], uri, action)\n }\n\n options<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(['OPTIONS'], uri, action)\n }\n\n any<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(ALL_VERBS, uri, action)\n }\n\n match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.addRoute(methods, uri, action)\n }\n\n /** Registers a route with the current group's prefix, name prefix, middleware and controller. GET implies HEAD. */\n addRoute(methods: readonly string[], uri: string, action: RouteHandler, options: { fallback?: boolean } = {}): RouteDefinition {\n const group = this.#groupStack.at(-1) ?? {}\n const verbs = methods.map((method) => method.toUpperCase())\n if (verbs.includes('GET') && !verbs.includes('HEAD')) verbs.push('HEAD')\n if (typeof action === 'string' && group.controller === undefined) {\n throw new RoutingError(\n `Route action [${action}] needs a controller. Use Route.controller(X).group(...) or pass [Controller, '${action}'].`,\n )\n }\n const prefix = (group.prefix ?? '').replace(/^\\/+|\\/+$/g, '')\n const path = uri.replace(/^\\/+|\\/+$/g, '')\n const route = new RouteDefinition(verbs, [prefix, path].filter((part) => part !== '').join('/'), action, {\n ...(group.as !== undefined && { namePrefix: group.as }),\n ...(group.middleware !== undefined && { middleware: group.middleware }),\n ...(group.controller !== undefined && { controller: group.controller }),\n ...(options.fallback === true && { fallback: true }),\n })\n this.#routes.push(route)\n this.#sorted = undefined\n return route\n }\n\n /** Route.redirect('/here', '/there'): any verb, 302 by default; '{param}' in the target is filled from the URI. */\n redirect(from: string, to: string, status = 302): RouteDefinition {\n const holder: { route?: RouteDefinition } = {}\n const action = (...values: unknown[]) => {\n const parameters = new Map(holder.route!.parameters.map((parameter, index) => [parameter.name, values[index]]))\n const target = to.replace(/\\{(\\w+)\\??\\}/g, (_match, name: string) => {\n const value = parameters.get(name)\n return value === undefined || value === null ? '' : encodeURIComponent(String(value))\n })\n const container = currentContainer() ?? this.container\n const location = container?.bound(UrlGenerator) ? container.make(UrlGenerator).to(target) : target\n return new Response(null, { status, headers: { Location: location } })\n }\n holder.route = this.any(from, action)\n return holder.route\n }\n\n permanentRedirect(from: string, to: string): RouteDefinition {\n return this.redirect(from, to, 301)\n }\n\n /** Route.view('/about', 'pages.about', data): GET/HEAD; route parameters are merged into the view data. */\n view(uri: string, view: string, data: Record<string, unknown> = {}): RouteDefinition {\n const holder: { route?: RouteDefinition } = {}\n const action = (...values: unknown[]) => {\n const parameters = Object.fromEntries(holder.route!.parameters.map((parameter, index) => [parameter.name, values[index]]))\n const container = currentContainer() ?? this.container\n if (container === undefined) throw new RoutingError(`Cannot render view [${view}]: no container is available.`)\n return container.make(ViewFactory).make(view, { ...data, ...parameters })\n }\n holder.route = this.addRoute(['GET', 'HEAD'], uri, action)\n return holder.route\n }\n\n /**\n * Route.inertia('/about', 'About', props): GET/HEAD; renders the page through the InertiaFactory (resolved when\n * the route runs, so Routing needs no Inertia import). Route parameters are merged into the props.\n */\n inertia(uri: string, component: string, props: Record<string, unknown> = {}): RouteDefinition {\n const holder: { route?: RouteDefinition } = {}\n const action = (...values: unknown[]) => {\n const parameters = Object.fromEntries(holder.route!.parameters.map((parameter, index) => [parameter.name, values[index]]))\n const container = currentContainer() ?? this.container\n if (container === undefined || !container.bound(InertiaFactory)) {\n throw new RoutingError(`Cannot render Inertia page [${component}]: no InertiaFactory is bound.`)\n }\n return container.make(InertiaFactory).render(component, { ...props, ...parameters })\n }\n holder.route = this.addRoute(['GET', 'HEAD'], uri, action)\n return holder.route\n }\n\n resource(name: string, controller: Class<unknown>, options: ResourceOptions = {}): void {\n this.#registerResource(name, controller, options, false)\n }\n\n apiResource(name: string, controller: Class<unknown>, options: ResourceOptions = {}): void {\n this.#registerResource(name, controller, options, true)\n }\n\n /** Matches any GET path no other route matches. Always tried last. */\n fallback(action: RouteAction): RouteDefinition {\n return this.addRoute(['GET', 'HEAD'], '{fallbackPlaceholder}', action, { fallback: true })\n }\n\n prefix(prefix: string): GroupRegistrar {\n return new GroupRegistrar(this).prefix(prefix)\n }\n\n name(prefix: string): GroupRegistrar {\n return new GroupRegistrar(this).name(prefix)\n }\n\n middleware(...middleware: MiddlewareReference[]): GroupRegistrar {\n return new GroupRegistrar(this).middleware(...middleware)\n }\n\n controller(controller: Class<unknown>): GroupRegistrar {\n return new GroupRegistrar(this).controller(controller)\n }\n\n /**\n * Laravel's Route::group(attributes, callback). A synchronous callback's attributes are popped before this\n * returns, so an unawaited group never leaks into later routes; an async callback keeps them until it settles.\n */\n group(attributes: GroupAttributes, routes: () => void | Promise<void>): Promise<void> {\n const entry = mergeGroup(this.#groupStack.at(-1) ?? {}, attributes)\n this.#groupStack.push(entry)\n const pop = () => {\n const index = this.#groupStack.lastIndexOf(entry)\n if (index !== -1) this.#groupStack.splice(index, 1)\n }\n let result: void | Promise<void>\n try {\n result = routes()\n } catch (error) {\n pop()\n throw error\n }\n if (result instanceof Promise) return result.finally(pop)\n pop()\n return Promise.resolve()\n }\n\n model(parameter: string, model: Class<unknown>): void {\n this.#models.set(parameter, model)\n }\n\n bind(parameter: string, resolver: RouteBinder): void {\n this.#binders.set(parameter, resolver)\n }\n\n pattern(parameter: string, pattern: string): void {\n this.#patterns[parameter] = pattern\n this.#patternVersion++\n }\n\n patterns(patterns: Record<string, string>): void {\n for (const [parameter, pattern] of Object.entries(patterns)) this.pattern(parameter, pattern)\n }\n\n getPatterns(): Readonly<Record<string, string>> {\n return { ...this.#patterns }\n }\n\n /** Bumped by pattern(); routes recompile their matcher when it changes. */\n getPatternVersion(): number {\n return this.#patternVersion\n }\n\n getBinder(parameter: string): RouteBinder | undefined {\n return this.#binders.get(parameter)\n }\n\n getModel(parameter: string): Class<unknown> | undefined {\n return this.#models.get(parameter)\n }\n\n aliasMiddleware(name: string, middleware: MiddlewareClass): this {\n this.#aliases[name] = middleware\n return this\n }\n\n /** The middleware aliases (Laravel's Router::getMiddleware()). */\n getMiddleware(): Record<string, MiddlewareClass> {\n return { ...this.#aliases }\n }\n\n middlewareGroup(name: string, middleware: MiddlewareReference[]): this {\n this.#groups[name] = [...middleware]\n return this\n }\n\n pushMiddlewareToGroup(group: string, middleware: MiddlewareReference): this {\n const list = (this.#groups[group] ??= [])\n if (!list.includes(middleware)) list.push(middleware)\n return this\n }\n\n prependMiddlewareToGroup(group: string, middleware: MiddlewareReference): this {\n const list = (this.#groups[group] ??= [])\n if (!list.includes(middleware)) list.unshift(middleware)\n return this\n }\n\n hasMiddlewareGroup(name: string): boolean {\n return Object.hasOwn(this.#groups, name)\n }\n\n getMiddlewareGroups(): Record<string, MiddlewareReference[]> {\n return Object.fromEntries(Object.entries(this.#groups).map(([name, list]) => [name, [...list]]))\n }\n\n /** Every route, in registration order. */\n getRoutes(): readonly RouteDefinition[] {\n return [...this.#routes]\n }\n\n /** Routes in matching order: static segments first, fallbacks last (cached until a route is added). */\n getRoutesByMatchOrder(): readonly RouteDefinition[] {\n return (this.#sorted ??= [...this.#routes].sort(compareRoutes))\n }\n\n /** The last route registered with this name wins, as in Laravel. */\n getByName(name: string): RouteDefinition | undefined {\n return this.#routes.findLast((route) => route.getName() === name)\n }\n\n has(...names: string[]): boolean {\n return names.every((name) => this.getByName(name) !== undefined)\n }\n\n /** The route matched for the current request (read from the request scope). */\n current(): RouteDefinition | undefined {\n const container = currentContainer()\n if (container === undefined || !container.bound(CurrentRoute)) return undefined\n return container.make(CurrentRoute).route as RouteDefinition\n }\n\n currentRouteName(): string | undefined {\n return this.current()?.getName()\n }\n\n /** Match, bind and run the route middleware and action (Router.dispatch; called by the Http kernel). */\n dispatch(request: HttpRequest): Promise<Response> {\n return dispatchRoute(this, request, this.container)\n }\n\n #registerResource(name: string, controller: Class<unknown>, options: ResourceOptions, api: boolean): void {\n for (const entry of resourceRoutes(name, options, api)) {\n this.addRoute(entry.verbs, entry.uri, [controller, entry.method] as RouteAction).name(entry.name)\n }\n }\n}\n","import { CurrentRoute, type Class, type Container, type HttpRequest, type OrielError } from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport type { BaseRouter } from './BaseRouter'\nimport { orderForBindings, substituteBindings } from './bindings'\nimport { MethodNotAllowedHttpError, NotFoundHttpError, RoutingError } from './errors'\nimport { resolveMiddleware, runMiddleware } from './middleware'\nimport { normalizePath, type RouteDefinition } from './RouteDefinition'\n\n/** [Controller, 'missing'] (Laravel's BadMethodCallException). */\nexport class ControllerMethodNotFoundError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'ControllerMethodNotFoundError'\n constructor(controller: string, method: string) {\n super(`Method ${controller}::${method} does not exist.`)\n }\n}\n\n// Duplicated in Pipeline's BasePipeline.ts on purpose: Http, Routing and Pipeline may not import each other.\nconst isClass = (value: unknown): value is Class<object> =>\n typeof value === 'function' && /^class[\\s{]/.test(Function.prototype.toString.call(value))\n\ntype Match = { route: RouteDefinition; values: Record<string, string | undefined> } | { response: Response }\n\nfunction findRoute(router: BaseRouter, request: HttpRequest): Match {\n const method = request.method().toUpperCase()\n const path = normalizePath(new URL(request.raw.url).pathname)\n const patterns = router.getPatterns()\n const version = router.getPatternVersion()\n const allowed = new Set<string>()\n for (const route of router.getRoutesByMatchOrder()) {\n const values = route.match(path, patterns, version)\n if (values === undefined) continue\n if (route.methods.includes(method)) return { route, values }\n // A fallback never turns an unknown POST into a 405.\n if (!route.isFallback) for (const verb of route.methods) allowed.add(verb)\n }\n if (allowed.size > 0) {\n // Laravel's automatic OPTIONS response.\n if (method === 'OPTIONS') return { response: new Response(null, { status: 200, headers: { Allow: [...allowed].join(', ') } }) }\n throw new MethodNotAllowedHttpError(method, request.path(), [...allowed])\n }\n throw new NotFoundHttpError(request.path())\n}\n\n/** Calls the route action with the parameters in URI order. Controllers are built by the request scope. */\nasync function runAction(scope: Container, route: RouteDefinition, parameters: Record<string, unknown>): Promise<unknown> {\n const args = route.parameters.map((parameter) => parameters[parameter.name])\n const action = route.action\n if (typeof action === 'function' && !isClass(action)) return (action as (...values: unknown[]) => unknown)(...args)\n const [cls, method] =\n typeof action === 'string'\n ? [route.controller as Class<object>, action]\n : isClass(action)\n ? [action, '__invoke']\n : [action[0] as Class<object>, String(action[1])]\n const controller = scope.make(cls) as Record<string, unknown>\n const handler = controller[method]\n if (typeof handler !== 'function') throw new ControllerMethodNotFoundError(cls.name, method)\n return (handler as (...values: unknown[]) => unknown).apply(controller, args)\n}\n\n/**\n * Router::dispatch: match, record the current route in the request scope, then run the route middleware and the\n * action. Matching errors (404/405) are thrown for the kernel's stage to render.\n */\nexport async function dispatchRoute(router: BaseRouter, request: HttpRequest, container?: Container): Promise<Response> {\n const scope = currentContainer() ?? container\n if (scope === undefined) throw new RoutingError('Cannot dispatch a request: no container is available.')\n const match = findRoute(router, request)\n if ('response' in match) return match.response\n const { route, values } = match\n\n const state: CurrentRoute = { route, parameters: { ...values }, middleware: [] }\n scope.instance(CurrentRoute, state)\n\n const middleware = resolveMiddleware(\n route.gatherMiddleware(),\n route.excludedMiddleware(),\n router.getMiddleware(),\n router.getMiddlewareGroups(),\n )\n const ordered = orderForBindings(router, middleware)\n return runMiddleware(scope, request, ordered.middleware, state.middleware, () => runAction(scope, route, state.parameters), {\n at: ordered.at,\n run: async () => void Object.assign(state.parameters, await substituteBindings(router, route, values, scope)),\n })\n}\n","import { RouteModelResolver, type Container, type MiddlewareClass } from '@orieljs/contracts'\nimport { BindingResolutionError } from '@orieljs/container'\nimport { Str } from '@orieljs/support'\nimport type { BaseRouter } from './BaseRouter'\nimport { RouteModelNotFoundError } from './errors'\nimport { resolveMiddleware, type ResolvedMiddleware } from './middleware'\nimport type { RouteDefinition } from './RouteDefinition'\n\n/**\n * Laravel's $middlewarePriority around SubstituteBindings: the `web`/`api` group middleware and the `auth`/`guest`\n * aliases run before binding, every other route middleware after it (so `can:` sees the models, and a guest is\n * redirected before any lookup). Returns the middleware in that order (stable within each part) and the index\n * where the binding stage runs.\n */\nexport function orderForBindings(\n router: BaseRouter,\n middleware: readonly ResolvedMiddleware[],\n): { middleware: ResolvedMiddleware[]; at: number } {\n const aliases = router.getMiddleware()\n const groups = router.getMiddlewareGroups()\n const early = new Set<MiddlewareClass>()\n for (const name of ['auth', 'guest']) if (Object.hasOwn(aliases, name)) early.add(aliases[name]!)\n for (const group of ['web', 'api']) {\n try {\n for (const entry of resolveMiddleware([group], [], aliases, groups)) early.add(entry.cls)\n } catch {\n // A group naming an unknown alias fails the routes that use it, when they resolve their middleware.\n }\n }\n const before = middleware.filter((entry) => early.has(entry.cls))\n const after = middleware.filter((entry) => !early.has(entry.cls))\n return { middleware: [...before, ...after], at: before.length }\n}\n\n/**\n * Laravel's SubstituteBindings, run as a route stage (see orderForBindings), in URI order:\n * 1. Route.bind(name, fn): the callback's result, whatever it is\n * 2. Route.model(name, Model): RouteModelResolver.resolveExplicit(); nothing found → 404\n * 3. implicit: RouteModelResolver.resolve(name, value, field); undefined keeps the string, null → 404\n * Missing optional parameters stay undefined. Without a resolver, implicit binding is skipped.\n */\nexport async function substituteBindings(\n router: BaseRouter,\n route: RouteDefinition,\n values: Readonly<Record<string, string | undefined>>,\n container: Container,\n): Promise<Record<string, unknown>> {\n const resolver = container.bound(RouteModelResolver) ? container.make(RouteModelResolver) : undefined\n const bound: Record<string, unknown> = {}\n for (const { name, field } of route.parameters) {\n const value = values[name]\n if (value === undefined) {\n bound[name] = undefined\n continue\n }\n const binder = router.getBinder(name)\n if (binder !== undefined) {\n bound[name] = await binder(value)\n continue\n }\n const model = router.getModel(name)\n if (model !== undefined) {\n if (resolver === undefined) {\n throw new BindingResolutionError(\n `Route.model('${name}', ${model.name}) needs a RouteModelResolver. Is the Database service provider registered?`,\n )\n }\n const found = await resolver.resolveExplicit(model, value, field)\n if (found === null || found === undefined) throw new RouteModelNotFoundError(model.name, value)\n bound[name] = found\n continue\n }\n if (resolver !== undefined) {\n const found = await resolver.resolve(name, value, field)\n if (found === null) throw new RouteModelNotFoundError(Str.studly(name), value)\n bound[name] = found === undefined ? value : found\n continue\n }\n bound[name] = value\n }\n return bound\n}\n","import type { ModelNotFoundError, OrielError } from '@orieljs/contracts'\n\n/** No route matches the path (Symfony's NotFoundHttpException). */\nexport class NotFoundHttpError extends Error implements OrielError {\n readonly kind = 'Http' as const\n readonly status = 404\n override readonly name = 'NotFoundHttpError'\n constructor(path: string) {\n super(`The route ${path} could not be found.`)\n }\n}\n\n/** The path exists, but not for this method. */\nexport class MethodNotAllowedHttpError extends Error implements OrielError {\n readonly kind = 'Http' as const\n readonly status = 405\n readonly headers: Record<string, string>\n override readonly name = 'MethodNotAllowedHttpError'\n constructor(method: string, path: string, allowed: string[]) {\n super(`The ${method} method is not supported for route ${path}. Supported methods: ${allowed.join(', ')}.`)\n this.headers = { Allow: allowed.join(', ') }\n }\n}\n\n/** route('x') for a name no route has (Symfony's RouteNotFoundException). */\nexport class RouteNotDefinedError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'RouteNotDefinedError'\n constructor(readonly routeName: string) {\n super(`Route [${routeName}] not defined.`)\n }\n}\n\n/** route('posts.show') without a required parameter. */\nexport class UrlGenerationError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UrlGenerationError'\n constructor(routeName: string, uri: string, missing: string[]) {\n super(`Missing required parameter for [Route: ${routeName}] [URI: ${uri}] [Missing parameter: ${missing.join(', ')}].`)\n }\n}\n\n/** Thrown by the router when a binding finds no row, so a missing model is always a 404. */\nexport class RouteModelNotFoundError extends Error implements ModelNotFoundError {\n readonly kind = 'ModelNotFound' as const\n readonly status = 404\n readonly ids: unknown[]\n override readonly name = 'RouteModelNotFoundError'\n constructor(readonly model: string, value: unknown) {\n super(`No query results for model [${model}] ${String(value)}`)\n this.ids = [value]\n }\n}\n\n/** Internal routing failures (a string action with no controller, a view route with no container, etc). */\nexport class RoutingError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'RoutingError'\n}\n","import {\n ExceptionHandler,\n PipelineFactory,\n type Container,\n type HttpRequest,\n type Middleware,\n type MiddlewareClass,\n type MiddlewareReference,\n type OrielError,\n} from '@orieljs/contracts'\nimport { RoutingError } from './errors'\nimport { toResponse } from './toResponse'\n\n/** A middleware reference after alias and group expansion: 'throttle:60,1' → { cls: Throttle, parameters: ['60', '1'] }. */\nexport interface ResolvedMiddleware {\n readonly cls: MiddlewareClass\n readonly parameters: readonly string[]\n}\n\n/** A string middleware that is neither an alias nor a group. */\nexport class MiddlewareNotFoundError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'MiddlewareNotFoundError'\n constructor(readonly middleware: string) {\n super(\n `Middleware [${middleware}] is not defined. Register it with Route.aliasMiddleware() or ` +\n `withMiddleware((m) => m.alias({ ... })).`,\n )\n }\n}\n\nfunction expand(\n references: readonly MiddlewareReference[],\n aliases: Readonly<Record<string, MiddlewareClass>>,\n groups: Readonly<Record<string, readonly MiddlewareReference[]>>,\n visiting: Set<string>,\n out: ResolvedMiddleware[],\n): void {\n for (const reference of references) {\n if (typeof reference === 'function') {\n out.push({ cls: reference, parameters: [] })\n continue\n }\n const index = reference.indexOf(':')\n const name = index === -1 ? reference : reference.slice(0, index)\n const parameters = index === -1 ? [] : reference.slice(index + 1).split(',')\n if (index === -1 && Object.hasOwn(groups, name)) {\n if (visiting.has(name)) throw new RoutingError(`Middleware group [${name}] includes itself.`)\n visiting.add(name)\n expand(groups[name]!, aliases, groups, visiting, out)\n visiting.delete(name)\n continue\n }\n if (!Object.hasOwn(aliases, name)) throw new MiddlewareNotFoundError(reference)\n out.push({ cls: aliases[name]!, parameters })\n }\n}\n\n/**\n * Expands aliases and groups (recursively), drops anything `excluded` resolves to (withoutMiddleware), and\n * removes duplicates (same class and parameters), keeping the first occurrence like Laravel's uniqueMiddleware.\n */\nexport function resolveMiddleware(\n references: readonly MiddlewareReference[],\n excluded: readonly MiddlewareReference[],\n aliases: Readonly<Record<string, MiddlewareClass>>,\n groups: Readonly<Record<string, readonly MiddlewareReference[]>>,\n): ResolvedMiddleware[] {\n const all: ResolvedMiddleware[] = []\n expand(references, aliases, groups, new Set(), all)\n const skipped: ResolvedMiddleware[] = []\n expand(excluded, aliases, groups, new Set(), skipped)\n const skippedClasses = new Set(skipped.map((entry) => entry.cls))\n const seen = new Set<string>()\n const classIds = new Map<MiddlewareClass, number>()\n return all.filter((entry) => {\n if (skippedClasses.has(entry.cls)) return false\n if (!classIds.has(entry.cls)) classIds.set(entry.cls, classIds.size)\n const key = `${classIds.get(entry.cls)}:${entry.parameters.join(',')}`\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\n/**\n * Renders an error as a Response through the bound ExceptionHandler (reporting it first), like Laravel's\n * Routing\\Pipeline::handleException. Without a handler the error is rethrown.\n */\nexport async function renderError(container: Container, request: HttpRequest, error: unknown): Promise<Response> {\n if (!container.bound(ExceptionHandler)) throw error\n const handler = container.make(ExceptionHandler)\n await handler.report(error)\n return handler.render(request, error)\n}\n\nasync function guard(container: Container, request: HttpRequest, run: () => Promise<unknown>): Promise<Response> {\n try {\n const result = await run()\n return result instanceof Response ? result : await toResponse(request, result)\n } catch (error) {\n return renderError(container, request, error)\n }\n}\n\n/** An extra pipeline stage that runs before `middleware[at]` (route model binding uses it). */\nexport interface RouteStage {\n readonly at: number\n run(request: HttpRequest): Promise<void>\n}\n\ntype RoutePipe = (passable: HttpRequest, next: (passable: HttpRequest) => Promise<unknown>) => Promise<Response>\n\n/**\n * Sends the request through the middleware (built from `container`, the request scope) to `destination`.\n * Every stage converts its own errors into a response, so outer middleware always get a Response back.\n * Built instances are pushed onto `instances` (for terminate()). `stage`, when given, runs at its position.\n */\nexport async function runMiddleware(\n container: Container,\n request: HttpRequest,\n middleware: readonly ResolvedMiddleware[],\n instances: Middleware[],\n destination: (request: HttpRequest) => Promise<unknown>,\n stage?: RouteStage,\n): Promise<Response> {\n const pipes: RoutePipe[] = middleware.map(({ cls, parameters }) => {\n const instance = container.make(cls)\n instances.push(instance)\n return (passable, next) =>\n guard(container, passable, () => instance.handle(passable, next as (r: HttpRequest) => Promise<Response>, ...parameters))\n })\n if (stage !== undefined) {\n pipes.splice(stage.at, 0, (passable, next) =>\n guard(container, passable, async () => {\n await stage.run(passable)\n return next(passable)\n }),\n )\n }\n return container\n .make(PipelineFactory)\n .make<HttpRequest>()\n .send(request)\n .through(pipes)\n .then((passable) => guard(container, passable, () => destination(passable)))\n}\n","/** Laravel's Router::toResponse: turns whatever an action returned into a Response. */\nexport async function toResponse(request: unknown, value: unknown): Promise<Response> {\n if (value instanceof Response) return value\n if (value === null || value === undefined) return new Response(null, { status: 204 })\n if (typeof value === 'string') return html(value)\n if (typeof value !== 'object') return html(String(value))\n\n const candidate = value as Record<string, unknown>\n // Responsable (redirects, Inertia responses, …)\n if (typeof candidate.toResponse === 'function') {\n return toResponse(request, await (candidate.toResponse as (request: unknown) => unknown).call(value, request))\n }\n // Renderable (a View from ViewFactory.make())\n if (typeof candidate.render === 'function') return html(String(await (candidate.render as () => unknown).call(value)))\n // Htmlable\n if (typeof candidate.toHtml === 'function') return html(String((candidate.toHtml as () => unknown).call(value)))\n if (typeof candidate.toJSON !== 'function') {\n // Jsonable, then Arrayable\n if (typeof candidate.toJson === 'function') return json(String((candidate.toJson as () => unknown).call(value)))\n if (typeof candidate.toArray === 'function') return json(JSON.stringify((candidate.toArray as () => unknown).call(value)))\n }\n // Plain objects, arrays, models and collections (via toJSON)\n return json(JSON.stringify(value))\n}\n\nfunction html(body: string): Response {\n return new Response(body, { headers: { 'content-type': 'text/html; charset=utf-8' } })\n}\n\n/** Explicit header: Response.json() says 'application/json' on Node but adds ';charset=utf-8' on Bun. */\nfunction json(body: string): Response {\n return new Response(body, { headers: { 'content-type': 'application/json' } })\n}\n","import type { Class, MiddlewareReference, Route, RouteAction } from '@orieljs/contracts'\n\n/** A closure, a [Controller, 'method'] tuple, or a method name inside Route.controller(X).group(). */\nexport type RouteHandler = RouteAction | string\n\nexport interface RouteAttributes {\n /** The group's name prefix ('admin.'); name() appends to it. */\n namePrefix?: string\n /** Group middleware; the route's own middleware() is appended after it. */\n middleware?: MiddlewareReference[]\n /** The group controller that string actions call. */\n controller?: Class<unknown>\n fallback?: boolean\n}\n\nexport interface UriParameter {\n readonly name: string\n readonly optional: boolean\n /** The binding column from '{post:slug}'. */\n readonly field: string | undefined\n}\n\n/** Exported for the URL generator, which reuses these instead of redeclaring them. */\nexport const PARAMETER = /\\{(\\w+)(?::(\\w+))?(\\?)?\\}/g\nexport const WHOLE_OPTIONAL = /^\\{(\\w+)(?::\\w+)?\\?\\}$/\nconst escapeRegex = (value: string) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\nexport function parseParameters(uri: string): UriParameter[] {\n return [...uri.matchAll(PARAMETER)].map((match) => ({ name: match[1]!, optional: match[3] === '?', field: match[2] }))\n}\n\n/** Laravel stores URIs without surrounding slashes, and '/' for the root. */\nexport function normalizeUri(uri: string): string {\n const trimmed = uri.replace(/^\\/+|\\/+$/g, '')\n return trimmed === '' ? '/' : trimmed\n}\n\n/** The form compiled patterns match against: '/posts/1/' → '/posts/1', '/' → ''. */\nexport function normalizePath(pathname: string): string {\n const trimmed = pathname.replace(/^\\/+|\\/+$/g, '').replace(/\\/{2,}/g, '/')\n return trimmed === '' ? '' : `/${trimmed}`\n}\n\nfunction decode(value: string): string {\n try {\n return decodeURIComponent(value)\n } catch {\n return value\n }\n}\n\n/** The pattern body (no anchors) for a normalised uri; '' for the root. */\nfunction compileBody(uri: string, wheres: Readonly<Record<string, string>>): string {\n if (uri === '/') return ''\n const group = (name: string) => `(?<p_${name}>${wheres[name] ?? '[^/]+'})`\n let body = ''\n for (const segment of uri.split('/')) {\n const whole = WHOLE_OPTIONAL.exec(segment)\n if (whole) {\n body += `(?:/${group(whole[1]!)})?`\n continue\n }\n let piece = ''\n let last = 0\n for (const match of segment.matchAll(PARAMETER)) {\n piece += escapeRegex(segment.slice(last, match.index)) + group(match[1]!) + (match[3] === '?' ? '?' : '')\n last = match.index + match[0].length\n }\n body += `/${piece}${escapeRegex(segment.slice(last))}`\n }\n return body\n}\n\nconst FALLBACK_SEGMENT = '{fallbackPlaceholder}'\n\n/**\n * Laravel's fallback is '{fallbackPlaceholder}' with where('.*') under the group prefix, so it stays scoped to it:\n * 'api/{fallbackPlaceholder}' matches /api and /api/any/depth but not /about; at the root it matches every path.\n */\nfunction compileFallback(uri: string, wheres: Readonly<Record<string, string>>): RegExp {\n const tail = '(?:/(?<p_fallbackPlaceholder>.*))?'\n if (uri === FALLBACK_SEGMENT) return new RegExp(`^${tail}$`, 's')\n if (!uri.endsWith(`/${FALLBACK_SEGMENT}`)) return new RegExp(`^${compileBody(uri, { ...wheres, fallbackPlaceholder: '.*' })}$`, 's')\n return new RegExp(`^${compileBody(uri.slice(0, -FALLBACK_SEGMENT.length - 1), wheres)}${tail}$`, 's')\n}\n\n/** Sort order for matching: fallbacks last, then per-segment specificity; ties keep registration order. */\nexport function compareRoutes(a: RouteDefinition, b: RouteDefinition): number {\n if (a.isFallback !== b.isFallback) return a.isFallback ? 1 : -1\n const left = a.rank()\n const right = b.rank()\n for (let i = 0; i < Math.max(left.length, right.length); i++) {\n const x = left[i] ?? -1\n const y = right[i] ?? -1\n if (x !== y) return x - y\n }\n return 0\n}\n\nexport class RouteDefinition implements Route {\n readonly methods: readonly string[]\n readonly uri: string\n readonly action: RouteHandler\n readonly controller: Class<unknown> | undefined\n readonly isFallback: boolean\n readonly parameters: readonly UriParameter[]\n #name: string | undefined\n readonly #middleware: MiddlewareReference[]\n readonly #excluded: MiddlewareReference[] = []\n readonly #wheres: Record<string, string> = {}\n #compiled: { regex: RegExp; version: number } | undefined\n\n constructor(methods: readonly string[], uri: string, action: RouteHandler, attributes: RouteAttributes = {}) {\n this.methods = [...new Set(methods.map((method) => method.toUpperCase()))]\n this.uri = normalizeUri(uri)\n this.action = action\n this.controller = attributes.controller\n this.isFallback = attributes.fallback ?? false\n this.parameters = parseParameters(this.uri)\n this.#name = attributes.namePrefix === undefined || attributes.namePrefix === '' ? undefined : attributes.namePrefix\n this.#middleware = [...(attributes.middleware ?? [])]\n }\n\n getName(): string | undefined {\n return this.#name\n }\n\n /** Appends, like Laravel's $action['as'] .= $name. */\n name(name: string): this {\n this.#name = (this.#name ?? '') + name\n return this\n }\n\n middleware(...middleware: MiddlewareReference[]): this {\n this.#middleware.push(...middleware.flat())\n return this\n }\n\n withoutMiddleware(...middleware: MiddlewareReference[]): this {\n this.#excluded.push(...middleware.flat())\n return this\n }\n\n where(parameter: string | Record<string, string>, pattern?: string): this {\n if (typeof parameter === 'string') this.#wheres[parameter] = pattern ?? '[^/]+'\n else Object.assign(this.#wheres, parameter)\n this.#compiled = undefined\n return this\n }\n\n gatherMiddleware(): MiddlewareReference[] {\n return [...this.#middleware]\n }\n\n excludedMiddleware(): MiddlewareReference[] {\n return [...this.#excluded]\n }\n\n wheres(): Record<string, string> {\n return { ...this.#wheres }\n }\n\n getActionName(): string {\n if (typeof this.action === 'string') return `${this.controller?.name ?? 'Controller'}@${this.action}`\n if (Array.isArray(this.action)) return `${(this.action[0] as Class<unknown>).name}@${String(this.action[1])}`\n return 'Closure'\n }\n\n /** Decoded parameter values when `path` (normalizePath output) matches, else undefined. */\n match(\n path: string,\n patterns: Readonly<Record<string, string>> = {},\n version = 0,\n ): Record<string, string | undefined> | undefined {\n const found = this.#regex(patterns, version).exec(path)\n if (found === null) return undefined\n const values: Record<string, string | undefined> = {}\n for (const { name } of this.parameters) {\n const raw = found.groups?.[`p_${name}`]\n values[name] = raw === undefined ? undefined : decode(raw)\n }\n return values\n }\n\n /** Per-segment specificity: static 0, parameter 1, optional parameter 2. Lower sorts first. */\n rank(): number[] {\n if (this.uri === '/') return []\n return this.uri.split('/').map((segment) => (WHOLE_OPTIONAL.test(segment) ? 2 : segment.includes('{') ? 1 : 0))\n }\n\n #regex(patterns: Readonly<Record<string, string>>, version: number): RegExp {\n if (this.#compiled !== undefined && this.#compiled.version === version) return this.#compiled.regex\n const wheres = { ...patterns, ...this.#wheres }\n const regex = this.isFallback ? compileFallback(this.uri, wheres) : new RegExp(`^${compileBody(this.uri, wheres)}$`)\n this.#compiled = { regex, version }\n return regex\n }\n}\n","import type { Class, ControllerAction, MiddlewareReference, ResourceOptions, RouteClosure, RouteRegistrar } from '@orieljs/contracts'\nimport type { RouteDefinition, RouteHandler } from './RouteDefinition'\n\n/** Attributes shared by the routes of a group (Laravel's group attribute array). */\nexport interface GroupAttributes {\n prefix?: string\n /** Name prefix ('admin.'). */\n as?: string\n middleware?: MiddlewareReference[]\n controller?: Class<unknown>\n}\n\n/** What a GroupRegistrar needs from the router. */\nexport interface GroupHost {\n group(attributes: GroupAttributes, routes: () => void | Promise<void>): Promise<void>\n addRoute(methods: readonly string[], uri: string, action: RouteHandler): RouteDefinition\n resource(name: string, controller: Class<unknown>, options?: ResourceOptions): void\n apiResource(name: string, controller: Class<unknown>, options?: ResourceOptions): void\n}\n\n/** Every HTTP verb a route can respond to. BaseRouter reuses this instead of redeclaring it. */\nexport const ALL_VERBS = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']\n\n/** Merges a nested group's attributes into its parent's, like Laravel's RouteGroup::merge. */\nexport function mergeGroup(parent: GroupAttributes, child: GroupAttributes): GroupAttributes {\n const prefix = [parent.prefix, child.prefix]\n .map((part) => (part ?? '').replace(/^\\/+|\\/+$/g, ''))\n .filter((part) => part !== '')\n .join('/')\n const merged: GroupAttributes = {\n middleware: [...(parent.middleware ?? []), ...(child.middleware ?? [])],\n }\n if (prefix !== '') merged.prefix = prefix\n const as = (parent.as ?? '') + (child.as ?? '')\n if (as !== '') merged.as = as\n const controller = child.controller ?? parent.controller\n if (controller !== undefined) merged.controller = controller\n return merged\n}\n\n/**\n * Route.prefix('admin').name('admin.').middleware('auth').group(() => …), and the one-route form\n * Route.middleware('auth').get('/x', action) (Laravel's RouteRegistrar).\n */\nexport class GroupRegistrar implements RouteRegistrar {\n readonly #attributes: GroupAttributes = {}\n\n constructor(private readonly router: GroupHost) {}\n\n prefix(prefix: string): this {\n this.#attributes.prefix = prefix\n return this\n }\n\n name(prefix: string): this {\n this.#attributes.as = prefix\n return this\n }\n\n middleware(...middleware: MiddlewareReference[]): this {\n this.#attributes.middleware = [...(this.#attributes.middleware ?? []), ...middleware.flat()]\n return this\n }\n\n controller(controller: Class<unknown>): this {\n this.#attributes.controller = controller\n return this\n }\n\n group(routes: () => void | Promise<void>): Promise<void> {\n return this.router.group({ ...this.#attributes }, routes)\n }\n\n get<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['GET', 'HEAD'], uri, action)\n }\n\n post<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['POST'], uri, action)\n }\n\n put<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['PUT'], uri, action)\n }\n\n patch<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['PATCH'], uri, action)\n }\n\n delete<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['DELETE'], uri, action)\n }\n\n options<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(['OPTIONS'], uri, action)\n }\n\n any<C>(uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(ALL_VERBS, uri, action)\n }\n\n match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | string): RouteDefinition {\n return this.#one(methods, uri, action)\n }\n\n resource(name: string, controller: Class<unknown>, options?: ResourceOptions): void {\n void this.router.group({ ...this.#attributes }, () => this.router.resource(name, controller, options))\n }\n\n apiResource(name: string, controller: Class<unknown>, options?: ResourceOptions): void {\n void this.router.group({ ...this.#attributes }, () => this.router.apiResource(name, controller, options))\n }\n\n #one(methods: readonly string[], uri: string, action: RouteHandler): RouteDefinition {\n let route: RouteDefinition | undefined\n void this.router.group({ ...this.#attributes }, () => {\n route = this.router.addRoute(methods, uri, action)\n })\n return route!\n }\n}\n","import type { ResourceOptions } from '@orieljs/contracts'\nimport { Str } from '@orieljs/support'\n\nexport type ResourceMethod = 'index' | 'create' | 'store' | 'show' | 'edit' | 'update' | 'destroy'\n\nexport interface ResourceRoute {\n readonly method: ResourceMethod\n readonly verbs: readonly string[]\n readonly uri: string\n readonly name: string\n}\n\n/** Laravel's order (ResourceRegistrar::$resourceDefaults). */\nconst DEFAULTS: readonly ResourceMethod[] = ['index', 'create', 'store', 'show', 'edit', 'update', 'destroy']\nconst API_DEFAULTS: readonly ResourceMethod[] = ['index', 'store', 'show', 'update', 'destroy']\n\n/** 'blog-posts' → 'blog_post' (Laravel's getResourceWildcard), unless options.parameters renames it. */\nfunction wildcard(segment: string, options: ResourceOptions): string {\n const renamed = options.parameters?.[segment]\n return (renamed ?? Str.singular(segment)).replace(/-/g, '_')\n}\n\n/**\n * The routes Route.resource()/apiResource() register. 'photos.comments' nests:\n * photos/{photo}/comments/{comment}, named photos.comments.*.\n */\nexport function resourceRoutes(name: string, options: ResourceOptions = {}, api = false): ResourceRoute[] {\n const segments = name.split('.')\n const last = segments.at(-1)!\n const base = [...segments.slice(0, -1).map((segment) => `${segment}/{${wildcard(segment, options)}}`), last].join('/')\n const member = `${base}/{${wildcard(last, options)}}`\n\n let methods = api ? API_DEFAULTS : DEFAULTS\n if (options.only !== undefined) methods = methods.filter((method) => options.only!.includes(method))\n if (options.except !== undefined) methods = methods.filter((method) => !options.except!.includes(method))\n\n const table: Record<ResourceMethod, { verbs: string[]; uri: string }> = {\n index: { verbs: ['GET', 'HEAD'], uri: base },\n create: { verbs: ['GET', 'HEAD'], uri: `${base}/create` },\n store: { verbs: ['POST'], uri: base },\n show: { verbs: ['GET', 'HEAD'], uri: member },\n edit: { verbs: ['GET', 'HEAD'], uri: `${member}/edit` },\n update: { verbs: ['PUT', 'PATCH'], uri: member },\n destroy: { verbs: ['DELETE'], uri: member },\n }\n return methods.map((method) => ({\n method,\n verbs: table[method].verbs,\n uri: table[method].uri,\n name: options.names?.[method] ?? `${name}.${method}`,\n }))\n}\n","import { ConfigRepository, HttpRequest, Session, type Container, type UrlGenerator } from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport type { BaseRouter } from './BaseRouter'\nimport { RouteNotDefinedError, UrlGenerationError } from './errors'\nimport { PARAMETER, WHOLE_OPTIONAL } from './RouteDefinition'\n\nconst VALID_URL = /^(#|\\/\\/|https?:\\/\\/|(mailto|tel|sms):)/i\n\n// Duplicated in Http's input.ts on purpose: Http, Routing and Pipeline may not import each other.\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const prototype = Object.getPrototypeOf(value) as unknown\n return prototype === Object.prototype || prototype === null\n}\n\n/** PHP's http_build_query: nested objects and arrays become a[b]=1&a[0]=2; null/undefined are skipped. */\nexport function buildQuery(values: Record<string, unknown>): string {\n const pairs: string[] = []\n const add = (key: string, value: unknown): void => {\n if (value === null || value === undefined) return\n if (typeof value === 'object' && (Array.isArray(value) || isPlainObject(value))) {\n for (const [child, nested] of Object.entries(value)) add(`${key}[${child}]`, nested)\n return\n }\n const text = value === true ? '1' : value === false ? '0' : String(value)\n pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(text)}`)\n }\n for (const [key, value] of Object.entries(values)) add(key, value)\n return pairs.join('&')\n}\n\n/** A model's URL value: the {post:slug} field when given, else getRouteKey(), else the value itself. */\nfunction routeKey(value: unknown, field: string | undefined): unknown {\n if (typeof value !== 'object' || value === null) return value\n const model = value as { getRouteKey?: () => unknown; getAttribute?: (key: string) => unknown } & Record<string, unknown>\n if (field !== undefined) return typeof model.getAttribute === 'function' ? model.getAttribute(field) : model[field]\n return typeof model.getRouteKey === 'function' ? model.getRouteKey() : value\n}\n\n/** Laravel's UrlGenerator. The root is the current request's origin, else config('app.url'). */\nexport class BaseUrlGenerator implements UrlGenerator {\n constructor(\n private readonly router: BaseRouter,\n private readonly container?: Container,\n ) {}\n\n /** 'http://localhost' (no trailing slash). */\n root(): string {\n const request = this.#request()\n if (request !== undefined) return new URL(request.url()).origin\n const configured = this.#config<string | undefined>('app.url', undefined)\n return (configured ?? 'http://localhost').replace(/\\/+$/, '')\n }\n\n to(path: string, query: Record<string, unknown> = {}, absolute = true): string {\n const queryString = buildQuery(query)\n const base = VALID_URL.test(path) ? path : this.#join(path, absolute)\n if (queryString === '') return base\n return `${base}${base.includes('?') ? '&' : '?'}${queryString}`\n }\n\n /**\n * route('posts.show', post) / route('posts.show', [post, comment]) / route('posts.show', { post: 1, page: 2 }).\n * Named values fill their parameters, positional values fill the rest in URI order; extra named values become\n * the query string, extra positional ones are dropped.\n */\n route(name: string, parameters?: unknown, absolute = true): string {\n const route = this.router.getByName(name)\n if (route === undefined) throw new RouteNotDefinedError(name)\n const named: Record<string, unknown> = isPlainObject(parameters) ? { ...parameters } : {}\n const positional: unknown[] = Array.isArray(parameters)\n ? [...parameters]\n : parameters === undefined || parameters === null || isPlainObject(parameters)\n ? []\n : [parameters]\n\n const values = new Map<string, string | undefined>()\n const missing: string[] = []\n for (const parameter of route.parameters) {\n let value: unknown\n if (Object.hasOwn(named, parameter.name)) {\n value = named[parameter.name]\n delete named[parameter.name]\n } else if (positional.length > 0) {\n value = positional.shift()\n }\n const key = routeKey(value, parameter.field)\n const text = key === undefined || key === null ? undefined : String(key)\n if (text === undefined && !parameter.optional) missing.push(parameter.name)\n values.set(parameter.name, text)\n }\n if (missing.length > 0) throw new UrlGenerationError(name, route.uri, missing)\n\n const path =\n route.uri === '/'\n ? ''\n : route.uri\n .split('/')\n .filter((segment) => {\n const whole = WHOLE_OPTIONAL.exec(segment)\n return whole === null || values.get(whole[1]!) !== undefined\n })\n .map((segment) =>\n segment.replace(PARAMETER, (_match, parameter: string) => {\n const value = values.get(parameter)\n return value === undefined ? '' : encodeURIComponent(value)\n }),\n )\n .join('/')\n const query = Object.fromEntries(Object.entries(named).map(([key, value]) => [key, routeKey(value, undefined)]))\n return this.to(path, query, absolute)\n }\n\n asset(path: string): string {\n if (VALID_URL.test(path)) return path\n const base = this.#config<string | undefined>('app.asset_url', undefined)?.replace(/\\/+$/, '') ?? this.root()\n const trimmed = path.replace(/^\\/+/, '')\n return trimmed === '' ? base : `${base}/${trimmed}`\n }\n\n /** The current URL without the query string. */\n current(): string {\n return this.#request()?.url() ?? this.root()\n }\n\n /** The current URL with the query string. */\n full(): string {\n return this.#request()?.fullUrl() ?? this.root()\n }\n\n /** The Referer header, then the session's previous URL, then `fallback`, then the root (Laravel's order). */\n previous(fallback?: string): string {\n const scope = this.#scope()\n const request = this.#request()\n const referer = request?.header('referer')\n if (referer !== undefined && referer !== '') return this.to(referer)\n if (request !== undefined && scope?.bound(Session)) {\n const previous = scope.make(Session).previousUrl()\n if (previous !== undefined && previous !== '') return this.to(previous)\n }\n return this.to(fallback ?? '/')\n }\n\n hasRoute(name: string): boolean {\n return this.router.getByName(name) !== undefined\n }\n\n #join(path: string, absolute: boolean): string {\n const trimmed = path.replace(/^\\/+|\\/+$/g, '')\n if (!absolute) return `/${trimmed}`\n return trimmed === '' ? this.root() : `${this.root()}/${trimmed}`\n }\n\n #scope(): Container | undefined {\n return currentContainer() ?? this.container\n }\n\n /** The HttpRequest, only when running inside a request scope. */\n #request(): HttpRequest | undefined {\n const scope = this.#scope()\n return scope?.bound(HttpRequest) ? scope.make(HttpRequest) : undefined\n }\n\n #config<T>(key: string, fallback: T): T {\n const scope = this.#scope()\n return scope?.bound(ConfigRepository) ? scope.make(ConfigRepository).get<T>(key, fallback) : fallback\n }\n}\n","import { Router, type Abstract } from '@orieljs/contracts'\nimport { facade } from '@orieljs/support'\nimport type { BaseRouter } from './BaseRouter'\n\n/**\n * The Route facade: Route.get('/', …), Route.prefix('admin').group(…), Route.resource(…). Typed as the BaseRouter\n * so the extras (permanentRedirect, patterns, has, currentRouteName, …) are available too.\n */\nexport const Route = facade<BaseRouter>(Router as Abstract<BaseRouter>)\n","import { pathToFileURL } from 'node:url'\nimport type { Application, Router } from '@orieljs/contracts'\n\n/** A route file may export a function instead of (or as well as) calling the Route facade at the top level. */\nexport type RouteFileCallback = (router: Router) => void | Promise<void>\n\nlet generation = 0\n\n/**\n * Imports a route file inside app.run(), so the Route facade in it resolves this application. Each load adds a\n * fresh `?oriel-routes=<n>` query: ESM caches modules, and a fresh app per test must register its routes again.\n * A default export that is a function is called with the router.\n */\nexport async function loadRoutesFrom(app: Application, router: Router, file: string): Promise<void> {\n const url = `${pathToFileURL(file).href}?oriel-routes=${++generation}`\n const module = (await app.run(() => import(/* @vite-ignore */ url))) as { default?: unknown }\n if (typeof module.default === 'function') await app.run(() => (module.default as RouteFileCallback)(router))\n}\n\n/** The health route's page (Laravel's `/up`): 200 as long as the application boots and handles requests. */\nexport function healthResponse(): Response {\n const html =\n '<!DOCTYPE html>\\n<html lang=\"en\">\\n<head>\\n<meta charset=\"utf-8\">\\n<title>Application up</title>\\n</head>\\n' +\n '<body><h1>Application up</h1></body>\\n</html>'\n return new Response(html, { status: 200, headers: { 'content-type': 'text/html; charset=utf-8' } })\n}\n","import { Router, RoutingPaths, UrlGenerator } from '@orieljs/contracts'\nimport { ServiceProvider } from '@orieljs/support'\nimport { BaseRouter } from './BaseRouter'\nimport { BaseUrlGenerator } from './BaseUrlGenerator'\nimport { RoutingError } from './errors'\nimport { healthResponse, loadRoutesFrom } from './routeFiles'\n\n/**\n * Binds the Router and the UrlGenerator, and once the app has booted loads the files given to withRouting(): the health URI,\n * then routes/web.ts in the `web` middleware group, then routes/api.ts under the api prefix in the `api` group\n * (Laravel's ApplicationBuilder::withRouting).\n */\nexport class RoutingServiceProvider extends ServiceProvider {\n override register(): void {\n this.app.singleton(Router, () => new BaseRouter(this.app))\n this.app.singleton(UrlGenerator, () => {\n const router = this.app.make(Router)\n if (!(router instanceof BaseRouter)) {\n throw new RoutingError('The UrlGenerator needs the BaseRouter: the bound Router was replaced by another implementation.')\n }\n return new BaseUrlGenerator(router, this.app)\n })\n }\n\n /**\n * The files load in a booted() callback, after every provider's boot() (Laravel's withRouting does the same), so\n * what the app's own providers set up at boot (Route.pattern/bind/model, gates, shared view data) is in place\n * when the route files run.\n */\n override boot(): void {\n this.app.booted(async () => {\n if (!this.app.bound(RoutingPaths)) return\n const { web, api, health, apiPrefix } = this.app.make(RoutingPaths)\n const router = this.app.make(Router)\n if (health !== undefined) router.get(health, () => healthResponse())\n if (web !== undefined) await router.middleware('web').group(() => loadRoutesFrom(this.app, router, web))\n if (api !== undefined) await router.prefix(apiPrefix).middleware('api').group(() => loadRoutesFrom(this.app, router, api))\n })\n }\n}\n"],"mappings":";AAAA;AAAA,EACE,gBAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAWK;AACP,SAAS,oBAAAC,yBAAwB;;;AChBjC,SAAS,oBAAmF;AAC5F,SAAS,wBAAwB;;;ACDjC,SAAS,0BAAgE;AACzE,SAAS,8BAA8B;AACvC,SAAS,WAAW;;;ACCb,IAAM,oBAAN,cAAgC,MAA4B;AAAA,EACxD,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAAA,EACzB,YAAY,MAAc;AACxB,UAAM,aAAa,IAAI,sBAAsB;AAAA,EAC/C;AACF;AAGO,IAAM,4BAAN,cAAwC,MAA4B;AAAA,EAChE,OAA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pG;;;ACzBA,SAAS,UAAAC,SAAQ,cAAc,gBAAAC,qBAAoB;AACnD,SAAS,uBAAuB;AAWzB,IAAM,yBAAN,cAAqC,gBAAgB;AAAA,EACjD,WAAiB;AACxB,SAAK,IAAI,UAAUC,SAAQ,MAAM,IAAI,WAAW,KAAK,GAAG,CAAC;AACzD,SAAK,IAAI,UAAUC,eAAc,MAAM;AACrC,YAAM,SAAS,KAAK,IAAI,KAAKD,OAAM;AACnC,UAAI,EAAE,kBAAkB,aAAa;AACnC,cAAM,IAAI,aAAa,iGAAiG;AAAA,MAC1H;AACA,aAAO,IAAI,iBAAiB,QAAQ,KAAK,GAAG;AAAA,IAC9C,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOS,OAAa;AACpB,SAAK,IAAI,OAAO,YAAY;AAC1B,UAAI,CAAC,KAAK,IAAI,MAAM,YAAY,EAAG;AACnC,YAAM,EAAE,KAAK,KAAK,QAAQ,UAAU,IAAI,KAAK,IAAI,KAAK,YAAY;AAClE,YAAM,SAAS,KAAK,IAAI,KAAKA,OAAM;AACnC,UAAI,WAAW,OAAW,QAAO,IAAI,QAAQ,MAAM,eAAe,CAAC;AACnE,UAAI,QAAQ,OAAW,OAAM,OAAO,WAAW,KAAK,EAAE,MAAM,MAAM,eAAe,KAAK,KAAK,QAAQ,GAAG,CAAC;AACvG,UAAI,QAAQ,OAAW,OAAM,OAAO,OAAO,SAAS,EAAE,WAAW,KAAK,EAAE,MAAM,MAAM,eAAe,KAAK,KAAK,QAAQ,GAAG,CAAC;AAAA,IAC3H,CAAC;AAAA,EACH;AACF;","names":["CurrentRoute","currentContainer","Str","currentContainer","CurrentRoute","currentContainer","currentContainer","html","Router","UrlGenerator","Router","UrlGenerator"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orieljs/routing",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "The Oriel Routing component.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"NOTICE"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@orieljs/contracts": "0.1.0-alpha.
|
|
33
|
-
"@orieljs/container": "0.1.0-alpha.
|
|
34
|
-
"@orieljs/support": "0.1.0-alpha.
|
|
32
|
+
"@orieljs/contracts": "0.1.0-alpha.2",
|
|
33
|
+
"@orieljs/container": "0.1.0-alpha.2",
|
|
34
|
+
"@orieljs/support": "0.1.0-alpha.2"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsup && node ../../../scripts/copy-license.mjs"
|