@orieljs/routing 0.1.0-alpha.15 → 0.1.0-alpha.16
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 +6 -3
- package/dist/index.js +87 -30
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -263,7 +263,8 @@ declare function runMiddleware(container: Container, request: HttpRequest, middl
|
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
265
|
* Laravel's $middlewarePriority around SubstituteBindings: the `web`/`api` group middleware and the `auth`/`guest`
|
|
266
|
-
* aliases run before binding,
|
|
266
|
+
* aliases run before binding, then `throttle` (so a throttled request does no lookup, and a missing model's 404
|
|
267
|
+
* counts toward the limit), every other route middleware after it (so `can:` sees the models, and a guest is
|
|
267
268
|
* redirected before any lookup). Returns the middleware in that order (stable within each part) and the index
|
|
268
269
|
* where the binding stage runs.
|
|
269
270
|
*/
|
|
@@ -428,10 +429,12 @@ declare class RoutingServiceProvider extends ServiceProvider {
|
|
|
428
429
|
/**
|
|
429
430
|
* Laravel's ThrottleRequests (`throttle:<maxAttempts>,<decayMinutes>[,<prefix>]`): counts the client's requests
|
|
430
431
|
* (the signed-in user, else the IP) in a window and answers 429 once there are too many. Responses carry
|
|
431
|
-
* X-RateLimit-Limit and X-RateLimit-Remaining; the 429 adds Retry-After and X-RateLimit-Reset.
|
|
432
|
+
* X-RateLimit-Limit and X-RateLimit-Remaining; the 429 adds Retry-After and X-RateLimit-Reset. `throttle:<name>`
|
|
433
|
+
* uses the limits `RateLimiter.for(name, …)` returns for the request instead.
|
|
432
434
|
*/
|
|
433
435
|
declare class ThrottleRequests implements Middleware {
|
|
434
|
-
|
|
436
|
+
#private;
|
|
437
|
+
handle(request: HttpRequest, next: Next, ...parameters: string[]): Promise<Response>;
|
|
435
438
|
/** The signed-in user's identifier, else the client IP, hashed (Laravel's resolveRequestSignature()). */
|
|
436
439
|
protected resolveRequestSignature(request: HttpRequest): Promise<string>;
|
|
437
440
|
}
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
CurrentRoute as CurrentRoute2,
|
|
4
4
|
InertiaFactory,
|
|
5
5
|
UrlGenerator,
|
|
6
|
-
ViewFactory
|
|
6
|
+
ViewFactory as ViewFactory2
|
|
7
7
|
} from "@orieljs/contracts";
|
|
8
|
-
import { currentContainer as
|
|
8
|
+
import { currentContainer as currentContainer3 } from "@orieljs/container";
|
|
9
9
|
|
|
10
10
|
// bindings.ts
|
|
11
11
|
import { RouteModelResolver } from "@orieljs/contracts";
|
|
@@ -92,11 +92,15 @@ import {
|
|
|
92
92
|
} from "@orieljs/contracts";
|
|
93
93
|
|
|
94
94
|
// toResponse.ts
|
|
95
|
+
import { ViewFactory } from "@orieljs/contracts";
|
|
96
|
+
import { currentContainer } from "@orieljs/container";
|
|
97
|
+
var ELEMENT = /* @__PURE__ */ Symbol.for("oriel:view.element");
|
|
95
98
|
async function toResponse(request, value) {
|
|
96
99
|
if (value instanceof Response) return value;
|
|
97
100
|
if (value === null || value === void 0) return new Response(null, { status: 204 });
|
|
98
101
|
if (typeof value === "string") return html(value);
|
|
99
102
|
if (typeof value !== "object") return html(String(value));
|
|
103
|
+
if (value[ELEMENT] === true) return html(await renderElement(value));
|
|
100
104
|
const candidate = value;
|
|
101
105
|
if (typeof candidate.toResponse === "function") {
|
|
102
106
|
return toResponse(request, await candidate.toResponse.call(value, request));
|
|
@@ -109,6 +113,13 @@ async function toResponse(request, value) {
|
|
|
109
113
|
}
|
|
110
114
|
return json(JSON.stringify(value));
|
|
111
115
|
}
|
|
116
|
+
async function renderElement(element) {
|
|
117
|
+
const container = currentContainer();
|
|
118
|
+
if (container === void 0 || !container.bound(ViewFactory)) {
|
|
119
|
+
throw new RoutingError("Returning a TSX element needs the View service provider.");
|
|
120
|
+
}
|
|
121
|
+
return container.make(ViewFactory).renderToString(element);
|
|
122
|
+
}
|
|
112
123
|
function html(body) {
|
|
113
124
|
return new Response(body, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
114
125
|
}
|
|
@@ -172,10 +183,14 @@ async function renderError(container, request, error) {
|
|
|
172
183
|
await handler.report(error);
|
|
173
184
|
return handler.render(request, error);
|
|
174
185
|
}
|
|
175
|
-
async function guard(container, request, run) {
|
|
186
|
+
async function guard(container, request, run, stage = "middleware") {
|
|
176
187
|
try {
|
|
177
188
|
const result = await run();
|
|
178
|
-
|
|
189
|
+
if (result instanceof Response) return result;
|
|
190
|
+
if (stage === "middleware" && (result === void 0 || result === null)) {
|
|
191
|
+
throw new RoutingError("Middleware must return a Response.");
|
|
192
|
+
}
|
|
193
|
+
return await toResponse(request, result);
|
|
179
194
|
} catch (error) {
|
|
180
195
|
return renderError(container, request, error);
|
|
181
196
|
}
|
|
@@ -196,7 +211,7 @@ async function runMiddleware(container, request, middleware, instances, destinat
|
|
|
196
211
|
})
|
|
197
212
|
);
|
|
198
213
|
}
|
|
199
|
-
return container.make(PipelineFactory).make().send(request).through(pipes).then((passable) => guard(container, passable, () => destination(passable)));
|
|
214
|
+
return container.make(PipelineFactory).make().send(request).through(pipes).then((passable) => guard(container, passable, () => destination(passable), "action"));
|
|
200
215
|
}
|
|
201
216
|
|
|
202
217
|
// bindings.ts
|
|
@@ -204,6 +219,7 @@ function orderForBindings(router, middleware) {
|
|
|
204
219
|
const aliases = router.getMiddleware();
|
|
205
220
|
const groups = router.getMiddlewareGroups();
|
|
206
221
|
const early = /* @__PURE__ */ new Set();
|
|
222
|
+
const throttle = Object.hasOwn(aliases, "throttle") ? aliases["throttle"] : void 0;
|
|
207
223
|
for (const name of ["auth", "guest"]) if (Object.hasOwn(aliases, name)) early.add(aliases[name]);
|
|
208
224
|
for (const group of ["web", "api"]) {
|
|
209
225
|
try {
|
|
@@ -211,9 +227,11 @@ function orderForBindings(router, middleware) {
|
|
|
211
227
|
} catch {
|
|
212
228
|
}
|
|
213
229
|
}
|
|
214
|
-
const
|
|
215
|
-
const
|
|
216
|
-
|
|
230
|
+
const isThrottle = (entry) => throttle !== void 0 && entry.cls === throttle;
|
|
231
|
+
const before = middleware.filter((entry) => early.has(entry.cls) && !isThrottle(entry));
|
|
232
|
+
const throttled = middleware.filter(isThrottle);
|
|
233
|
+
const after = middleware.filter((entry) => !early.has(entry.cls) && !isThrottle(entry));
|
|
234
|
+
return { middleware: [...before, ...throttled, ...after], at: before.length + throttled.length };
|
|
217
235
|
}
|
|
218
236
|
async function substituteBindings(router, route, values, container) {
|
|
219
237
|
const resolver = container.bound(RouteModelResolver) ? container.make(RouteModelResolver) : void 0;
|
|
@@ -254,7 +272,7 @@ async function substituteBindings(router, route, values, container) {
|
|
|
254
272
|
|
|
255
273
|
// dispatch.ts
|
|
256
274
|
import { CurrentRoute } from "@orieljs/contracts";
|
|
257
|
-
import { currentContainer } from "@orieljs/container";
|
|
275
|
+
import { currentContainer as currentContainer2 } from "@orieljs/container";
|
|
258
276
|
|
|
259
277
|
// RouteDefinition.ts
|
|
260
278
|
var PARAMETER = /\{(\w+)(?::(\w+))?(\?)?\}/g;
|
|
@@ -469,7 +487,7 @@ async function runAction(scope, route, parameters) {
|
|
|
469
487
|
return handler.apply(controller, args);
|
|
470
488
|
}
|
|
471
489
|
async function dispatchRoute(router, request, container) {
|
|
472
|
-
const scope =
|
|
490
|
+
const scope = currentContainer2() ?? container;
|
|
473
491
|
if (scope === void 0) throw new RoutingError("Cannot dispatch a request: no container is available.");
|
|
474
492
|
const match = findRoute(router, request);
|
|
475
493
|
if ("response" in match) return match.response;
|
|
@@ -671,7 +689,7 @@ var BaseRouter = class {
|
|
|
671
689
|
const value = parameters.get(name);
|
|
672
690
|
return value === void 0 || value === null ? "" : encodeURIComponent(String(value));
|
|
673
691
|
});
|
|
674
|
-
const container =
|
|
692
|
+
const container = currentContainer3() ?? this.container;
|
|
675
693
|
const location = container?.bound(UrlGenerator) ? container.make(UrlGenerator).to(target) : target;
|
|
676
694
|
return new Response(null, { status, headers: { Location: location } });
|
|
677
695
|
};
|
|
@@ -686,9 +704,9 @@ var BaseRouter = class {
|
|
|
686
704
|
const holder = {};
|
|
687
705
|
const action = (...values) => {
|
|
688
706
|
const parameters = Object.fromEntries(holder.route.parameters.map((parameter, index) => [parameter.name, values[index]]));
|
|
689
|
-
const container =
|
|
707
|
+
const container = currentContainer3() ?? this.container;
|
|
690
708
|
if (container === void 0) throw new RoutingError(`Cannot render view [${view}]: no container is available.`);
|
|
691
|
-
return container.make(
|
|
709
|
+
return container.make(ViewFactory2).make(view, { ...data, ...parameters });
|
|
692
710
|
};
|
|
693
711
|
holder.route = this.addRoute(["GET", "HEAD"], uri, action);
|
|
694
712
|
return holder.route;
|
|
@@ -701,7 +719,7 @@ var BaseRouter = class {
|
|
|
701
719
|
const holder = {};
|
|
702
720
|
const action = (...values) => {
|
|
703
721
|
const parameters = Object.fromEntries(holder.route.parameters.map((parameter, index) => [parameter.name, values[index]]));
|
|
704
|
-
const container =
|
|
722
|
+
const container = currentContainer3() ?? this.container;
|
|
705
723
|
if (container === void 0 || !container.bound(InertiaFactory)) {
|
|
706
724
|
throw new RoutingError(`Cannot render Inertia page [${component}]: no InertiaFactory is bound.`);
|
|
707
725
|
}
|
|
@@ -833,7 +851,7 @@ var BaseRouter = class {
|
|
|
833
851
|
}
|
|
834
852
|
/** The route matched for the current request (read from the request scope). */
|
|
835
853
|
current() {
|
|
836
|
-
const container =
|
|
854
|
+
const container = currentContainer3();
|
|
837
855
|
if (container === void 0 || !container.bound(CurrentRoute2)) return void 0;
|
|
838
856
|
return container.make(CurrentRoute2).route;
|
|
839
857
|
}
|
|
@@ -854,7 +872,7 @@ var BaseRouter = class {
|
|
|
854
872
|
// BaseUrlGenerator.ts
|
|
855
873
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
856
874
|
import { ConfigRepository, Encrypter, HttpRequest, Session } from "@orieljs/contracts";
|
|
857
|
-
import { currentContainer as
|
|
875
|
+
import { currentContainer as currentContainer4 } from "@orieljs/container";
|
|
858
876
|
var VALID_URL = /^(#|\/\/|https?:\/\/|(mailto|tel|sms):)/i;
|
|
859
877
|
var isPlainObject = (value) => {
|
|
860
878
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
@@ -875,6 +893,14 @@ function buildQuery(values) {
|
|
|
875
893
|
for (const [key, value] of Object.entries(values)) add(key, value);
|
|
876
894
|
return pairs.join("&");
|
|
877
895
|
}
|
|
896
|
+
function acceptsSlash(pattern) {
|
|
897
|
+
if (pattern === void 0) return false;
|
|
898
|
+
try {
|
|
899
|
+
return new RegExp(`^(?:${pattern})$`).test("a/b");
|
|
900
|
+
} catch {
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
878
904
|
function routeKey(value, field) {
|
|
879
905
|
if (typeof value !== "object" || value === null) return value;
|
|
880
906
|
const model = value;
|
|
@@ -923,6 +949,7 @@ var BaseUrlGenerator = class {
|
|
|
923
949
|
const named = isPlainObject(parameters) ? { ...parameters } : {};
|
|
924
950
|
const positional = Array.isArray(parameters) ? [...parameters] : parameters === void 0 || parameters === null || isPlainObject(parameters) ? [] : [parameters];
|
|
925
951
|
const values = /* @__PURE__ */ new Map();
|
|
952
|
+
const wheres = route.wheres();
|
|
926
953
|
const missing = [];
|
|
927
954
|
for (const parameter of route.parameters) {
|
|
928
955
|
let value;
|
|
@@ -944,7 +971,8 @@ var BaseUrlGenerator = class {
|
|
|
944
971
|
}).map(
|
|
945
972
|
(segment) => segment.replace(PARAMETER, (_match, parameter) => {
|
|
946
973
|
const value = values.get(parameter);
|
|
947
|
-
|
|
974
|
+
if (value === void 0) return "";
|
|
975
|
+
return acceptsSlash(wheres[parameter]) ? value.split("/").map(encodeURIComponent).join("/") : encodeURIComponent(value);
|
|
948
976
|
})
|
|
949
977
|
).join("/");
|
|
950
978
|
const query = Object.fromEntries(Object.entries(named).map(([key, value]) => [key, routeKey(value, void 0)]));
|
|
@@ -952,7 +980,8 @@ var BaseUrlGenerator = class {
|
|
|
952
980
|
}
|
|
953
981
|
asset(path) {
|
|
954
982
|
if (VALID_URL.test(path)) return path;
|
|
955
|
-
const
|
|
983
|
+
const assetUrl = this.#config("app.asset_url", void 0)?.replace(/\/+$/, "");
|
|
984
|
+
const base = assetUrl === void 0 || assetUrl === "" ? this.root() : assetUrl;
|
|
956
985
|
const trimmed = path.replace(/^\/+/, "");
|
|
957
986
|
return trimmed === "" ? base : `${base}/${trimmed}`;
|
|
958
987
|
}
|
|
@@ -1048,7 +1077,7 @@ var BaseUrlGenerator = class {
|
|
|
1048
1077
|
return trimmed === "" ? this.root() : `${this.root()}/${trimmed}`;
|
|
1049
1078
|
}
|
|
1050
1079
|
#scope() {
|
|
1051
|
-
return
|
|
1080
|
+
return currentContainer4() ?? this.container;
|
|
1052
1081
|
}
|
|
1053
1082
|
/** The HttpRequest, only when running inside a request scope. */
|
|
1054
1083
|
#request() {
|
|
@@ -1143,25 +1172,53 @@ function withHeaders(response, headers) {
|
|
|
1143
1172
|
}
|
|
1144
1173
|
}
|
|
1145
1174
|
var ThrottleRequests = class {
|
|
1146
|
-
async handle(request, next,
|
|
1175
|
+
async handle(request, next, ...parameters) {
|
|
1176
|
+
if (parameters.length === 1 && !/^\d+$/.test(parameters[0].trim())) return this.#named(request, next, parameters[0]);
|
|
1177
|
+
const [maxAttempts = "60", decayMinutes = "1", prefix = ""] = parameters;
|
|
1178
|
+
return this.#numbered(request, next, maxAttempts, decayMinutes, prefix);
|
|
1179
|
+
}
|
|
1180
|
+
/** Laravel's handleRequestUsingNamedLimiter(): each limit checked and hit in order, under sha1(name + its key). */
|
|
1181
|
+
async #named(request, next, name) {
|
|
1182
|
+
const limiter = inject(RateLimiter);
|
|
1183
|
+
const callback = limiter.limiter(name);
|
|
1184
|
+
if (callback === void 0) throw new RoutingError(`Rate limiter [${name}] is not defined.`);
|
|
1185
|
+
const result = await callback(request);
|
|
1186
|
+
const limits = (Array.isArray(result) ? result : [result]).filter((limit) => limit.unlimited !== true);
|
|
1187
|
+
if (limits.length === 0) return next(request);
|
|
1188
|
+
const keyed = limits.map((limit) => ({ key: sha1(name + limit.key), max: limit.maxAttempts, decay: limit.decaySeconds }));
|
|
1189
|
+
for (const limit of keyed) {
|
|
1190
|
+
if (await limiter.tooManyAttempts(limit.key, limit.max)) throw await this.#tooMany(limit.key, limit.max);
|
|
1191
|
+
await limiter.hit(limit.key, limit.decay);
|
|
1192
|
+
}
|
|
1193
|
+
let response = await next(request);
|
|
1194
|
+
for (const limit of keyed) {
|
|
1195
|
+
response = withHeaders(response, {
|
|
1196
|
+
"X-RateLimit-Limit": String(limit.max),
|
|
1197
|
+
"X-RateLimit-Remaining": String(await limiter.remaining(limit.key, limit.max))
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
return response;
|
|
1201
|
+
}
|
|
1202
|
+
async #tooMany(key, max) {
|
|
1203
|
+
const retryAfter = await inject(RateLimiter).availableIn(key);
|
|
1204
|
+
return new ThrottleRequestsError({
|
|
1205
|
+
"X-RateLimit-Limit": String(max),
|
|
1206
|
+
"X-RateLimit-Remaining": "0",
|
|
1207
|
+
"Retry-After": String(retryAfter),
|
|
1208
|
+
"X-RateLimit-Reset": String(Math.floor(Date.now() / 1e3) + retryAfter)
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
async #numbered(request, next, maxAttempts, decayMinutes, prefix) {
|
|
1147
1212
|
const max = Number(maxAttempts);
|
|
1148
1213
|
const decay = Number(decayMinutes);
|
|
1149
1214
|
if (maxAttempts.trim() === "" || !Number.isInteger(max) || max < 0 || decayMinutes.trim() === "" || !Number.isFinite(decay) || decay <= 0) {
|
|
1150
1215
|
throw new RoutingError(
|
|
1151
|
-
`Invalid throttle parameters "${maxAttempts},${decayMinutes}": use throttle:<maxAttempts>,<decayMinutes>[,<prefix>]
|
|
1216
|
+
`Invalid throttle parameters "${maxAttempts},${decayMinutes}": use throttle:<maxAttempts>,<decayMinutes>[,<prefix>] or throttle:<name>.`
|
|
1152
1217
|
);
|
|
1153
1218
|
}
|
|
1154
1219
|
const limiter = inject(RateLimiter);
|
|
1155
1220
|
const key = prefix + await this.resolveRequestSignature(request);
|
|
1156
|
-
if (await limiter.tooManyAttempts(key, max))
|
|
1157
|
-
const retryAfter = await limiter.availableIn(key);
|
|
1158
|
-
throw new ThrottleRequestsError({
|
|
1159
|
-
"X-RateLimit-Limit": String(max),
|
|
1160
|
-
"X-RateLimit-Remaining": "0",
|
|
1161
|
-
"Retry-After": String(retryAfter),
|
|
1162
|
-
"X-RateLimit-Reset": String(Math.floor(Date.now() / 1e3) + retryAfter)
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1221
|
+
if (await limiter.tooManyAttempts(key, max)) throw await this.#tooMany(key, max);
|
|
1165
1222
|
await limiter.hit(key, Math.round(decay * 60));
|
|
1166
1223
|
const response = await next(request);
|
|
1167
1224
|
return withHeaders(response, {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../BaseRouter.ts","../bindings.ts","../errors.ts","../middleware.ts","../toResponse.ts","../dispatch.ts","../RouteDefinition.ts","../GroupRegistrar.ts","../resource.ts","../BaseUrlGenerator.ts","../facade.ts","../health.ts","../routeFiles.ts","../RoutingServiceProvider.ts","../ThrottleRequests.ts","../SetCacheHeaders.ts","../ValidateSignature.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 InvokableClass,\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 { substituteBindings } from './bindings'\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 | InvokableClass | string): RouteDefinition {\n return this.addRoute(['GET', 'HEAD'], uri, action)\n }\n\n post<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['POST'], uri, action)\n }\n\n put<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['PUT'], uri, action)\n }\n\n patch<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['PATCH'], uri, action)\n }\n\n delete<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['DELETE'], uri, action)\n }\n\n options<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['OPTIONS'], uri, action)\n }\n\n any<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(ALL_VERBS, uri, action)\n }\n\n match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | 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: Array<MiddlewareReference | readonly 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 /**\n * Binds a matched route's raw parameter values as a request to it would: Route.bind() callbacks, Route.model(),\n * then implicit binding through the RouteModelResolver of `container`. A missing model throws\n * RouteModelNotFoundError (404). Live uses it to check a page route's `can:` middleware again on each update.\n */\n substituteBindings(route: RouteDefinition, values: Readonly<Record<string, string | undefined>>, container: Container): Promise<Record<string, unknown>> {\n return substituteBindings(this, route, values, container)\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 { 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\n/** A signed URL whose signature is missing, wrong or expired (Laravel's InvalidSignatureException). */\nexport class InvalidUrlSignatureError extends Error implements OrielError {\n readonly kind = 'Http' as const\n readonly status = 403\n override readonly name = 'InvalidUrlSignatureError'\n constructor() {\n super('Invalid signature.')\n }\n}\n\n/** Too many requests in the window (Laravel's ThrottleRequestsException): 429 with Retry-After and X-RateLimit-*. */\nexport class ThrottleRequestsError extends Error implements OrielError {\n readonly kind = 'Http' as const\n readonly status = 429\n override readonly name = 'ThrottleRequestsError'\n constructor(readonly headers: Record<string, string> = {}) {\n super('Too Many Attempts.')\n }\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 { 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 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('auth', 'verified') or middleware(['auth', 'verified']). */\n middleware(...middleware: Array<MiddlewareReference | readonly 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 /** Laravel's whereAlpha(): ASCII letters only. One parameter name or several. */\n whereAlpha(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[a-zA-Z]+')\n }\n\n /** Laravel's whereAlphaNumeric(): ASCII letters and digits. */\n whereAlphaNumeric(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[a-zA-Z0-9]+')\n }\n\n /** Laravel's whereNumber(): digits only. */\n whereNumber(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[0-9]+')\n }\n\n /** Laravel's whereUlid(): 26 Crockford base-32 characters, the first at most 7. */\n whereUlid(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[0-7][0-9a-hjkmnp-tv-zA-HJKMNP-TV-Z]{25}')\n }\n\n /** Laravel's whereUuid(): five groups of hex digits (8-4-4-4-12), any version. */\n whereUuid(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[\\\\da-fA-F]{8}-[\\\\da-fA-F]{4}-[\\\\da-fA-F]{4}-[\\\\da-fA-F]{4}-[\\\\da-fA-F]{12}')\n }\n\n /** Laravel's whereIn(): one of the values. Unlike Laravel, each value is matched literally (`c++` is not a pattern). */\n whereIn(parameters: string | readonly string[], values: ReadonlyArray<string | number>): this {\n const first = typeof parameters === 'string' ? parameters : parameters[0]\n if (values.length === 0 && first !== undefined) throw new Error(`Routing requirement for \"${first}\" cannot be empty.`)\n return this.#assign(parameters, values.map((value) => escapeRegex(String(value))).join('|'))\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 #assign(parameters: string | readonly string[], pattern: string): this {\n const names: readonly string[] = typeof parameters === 'string' ? [parameters] : parameters\n return this.where(Object.fromEntries(names.map((name) => [name, pattern])))\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, InvokableClass, 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: Array<MiddlewareReference | readonly 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 | InvokableClass | string): RouteDefinition {\n return this.#one(['GET', 'HEAD'], uri, action)\n }\n\n post<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['POST'], uri, action)\n }\n\n put<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['PUT'], uri, action)\n }\n\n patch<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['PATCH'], uri, action)\n }\n\n delete<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['DELETE'], uri, action)\n }\n\n options<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['OPTIONS'], uri, action)\n }\n\n any<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(ALL_VERBS, uri, action)\n }\n\n match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | 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 { createHmac, timingSafeEqual } from 'node:crypto'\nimport { ConfigRepository, Encrypter, HttpRequest, Session, type Container, type UrlGenerator } from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport type { BaseRouter } from './BaseRouter'\nimport { RouteNotDefinedError, RoutingError, 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/** HMAC-SHA256 of a URL, hex (Laravel's hash_hmac('sha256', $url, $key)). */\nfunction sign(url: string, key: Uint8Array): string {\n return createHmac('sha256', key).update(url).digest('hex')\n}\n\n/** Constant-time string comparison. */\nfunction safeEquals(expected: string, given: string): boolean {\n const a = Buffer.from(expected)\n const b = Buffer.from(given)\n return a.length === b.length && timingSafeEqual(a, b)\n}\n\n/** Unix seconds: a Date, or a number of seconds from now (Laravel's availableAt()). */\nfunction availableAt(expiration: Date | number): number {\n return expiration instanceof Date ? Math.floor(expiration.getTime() / 1000) : Math.floor(Date.now() / 1000) + expiration\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 /**\n * Laravel's URL::signedRoute(): the route URL with its parameters sorted by name, then a `signature` query (the\n * HMAC-SHA256 of that URL, keyed by APP_KEY). `expiration` (a Date, or seconds from now) adds `expires`.\n * `absolute: false` signs the path only (checked by `signed:relative`).\n */\n signedRoute(name: string, parameters?: unknown, expiration?: Date | number, absolute = true): string {\n const named = this.#namedParameters(name, parameters)\n for (const reserved of ['signature', 'expires']) {\n if (Object.hasOwn(named, reserved)) {\n throw new RoutingError(`\"${reserved}\" is a reserved parameter when generating signed routes. Please rename your route parameter.`)\n }\n }\n if (expiration !== undefined) named.expires = availableAt(expiration)\n const sorted = Object.fromEntries(Object.keys(named).sort().map((key) => [key, named[key]]))\n const signature = sign(this.route(name, sorted, absolute), this.#signingKeys()[0]!)\n return this.route(name, { ...sorted, signature }, absolute)\n }\n\n /** Laravel's URL::temporarySignedRoute(): a signed URL that expires at `expiration` (a Date, or seconds from now). */\n temporarySignedRoute(name: string, expiration: Date | number, parameters?: unknown, absolute = true): string {\n return this.signedRoute(name, parameters, expiration, absolute)\n }\n\n /** The request URL carries a correct signature (current or previous APP_KEY) that hasn't expired. */\n hasValidSignature(request: HttpRequest, absolute = true): boolean {\n return this.hasCorrectSignature(request, absolute) && this.signatureHasNotExpired(request)\n }\n\n /** The signature matches the URL without its `signature` query, in a constant-time comparison. */\n hasCorrectSignature(request: HttpRequest, absolute = true): boolean {\n const full = new URL(request.fullUrl())\n const path = request.path()\n const url = absolute ? request.url() : path === '/' ? '/' : `/${path}`\n const query = full.search\n .slice(1)\n .split('&')\n .filter((pair) => pair !== '' && pair.split('=')[0] !== 'signature')\n .join('&')\n const original = query === '' ? url : `${url}?${query}`\n const given = full.searchParams.get('signature') ?? ''\n return this.#signingKeys().some((key) => safeEquals(sign(original, key), given))\n }\n\n /** No `expires` query, or one that is still in the future. */\n signatureHasNotExpired(request: HttpRequest): boolean {\n const expires = new URL(request.fullUrl()).searchParams.get('expires')\n if (expires === null || expires === '') return true\n const at = Number(expires)\n return Number.isFinite(at) && Math.floor(Date.now() / 1000) <= at\n }\n\n /** Named parameters: an object as is, positional values (a list or one value) by the route's parameter names. */\n #namedParameters(name: string, parameters: unknown): Record<string, unknown> {\n if (isPlainObject(parameters)) return { ...parameters }\n const route = this.router.getByName(name)\n if (route === undefined) throw new RouteNotDefinedError(name)\n const values = parameters === undefined || parameters === null ? [] : Array.isArray(parameters) ? parameters : [parameters]\n const named: Record<string, unknown> = {}\n route.parameters.forEach((parameter, index) => {\n if (index < values.length) named[parameter.name] = values[index]\n })\n return named\n }\n\n /** The Encrypter's key, then its previous keys (config app.previous_keys), so rotated keys still verify. */\n #signingKeys(): Uint8Array[] {\n const scope = this.#scope()\n if (scope === undefined || !scope.bound(Encrypter)) {\n throw new RoutingError('Signed URLs need the Encrypter: set APP_KEY (oriel key:generate).')\n }\n const encrypter = scope.make(Encrypter) as Encrypter & { getAllKeys?(): Uint8Array[] }\n return typeof encrypter.getAllKeys === 'function' ? encrypter.getAllKeys() : [encrypter.getKey()]\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 { ConfigRepository, EventDispatcher, ExceptionHandler, type Container } from '@orieljs/contracts'\n\n/**\n * Dispatched by the health route (`/up`) on every request (Laravel's DiagnosingHealth event). A listener checks\n * something the application needs, such as the database or the cache, and throws when it fails: `/up` then answers\n * 500 with \"Application experiencing problems\", and the exception is reported.\n *\n * Event.listen(DiagnosingHealth, async () => { await DB.select('select 1') })\n */\nexport class DiagnosingHealth {}\n\nexport interface HealthPage {\n /** False when a check failed: the page says so and the status is 500 (default true). */\n healthy?: boolean\n /** How long the request took, shown when given. */\n milliseconds?: number\n /** The page title (default \"Oriel\"). */\n appName?: string\n}\n\nconst escapeHtml = (value: string): string => value.replace(/[&<>\"']/g, (char) => `&#${char.charCodeAt(0)};`)\n\n// The Oriel style: dark canvas, one Graphite block, the system fonts, flat. Green and red are the status dot only.\nconst STYLE =\n ':root{color-scheme:dark}*{box-sizing:border-box;margin:0}html{background:#05050b}' +\n 'body{min-height:100vh;display:grid;place-items:center;padding:20px;background:#1a1a1a;color:#fff;' +\n 'font:400 16px/1.7 system-ui,-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif}' +\n 'main{display:flex;align-items:center;gap:20px;width:100%;max-width:640px;padding:20px 32px;border-radius:18px;background:#212121}' +\n '.dot{flex:none;width:12px;height:12px;border-radius:50%;background:#74ec5a}.dot.down{background:#ff3543}' +\n 'h1{font-size:21px;line-height:1.4;font-weight:600}p{color:#a3a3a3}.time{color:#ba94ff}'\n\n/**\n * The health route's page (Laravel's health-up view): \"Application up\", or \"Application experiencing problems\" with\n * status 500. Self-contained HTML with inline CSS: it loads nothing, so it answers even when the assets don't.\n */\nexport function healthResponse(page: HealthPage = {}): Response {\n const healthy = page.healthy ?? true\n const time = page.milliseconds === undefined ? '' : ` Response rendered in <span class=\"time\">${Math.round(page.milliseconds)} ms</span>.`\n const html =\n '<!DOCTYPE html>\\n<html lang=\"en\">\\n<head>\\n<meta charset=\"utf-8\">\\n' +\n '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\\n' +\n `<title>${escapeHtml(page.appName ?? 'Oriel')}</title>\\n<style>${STYLE}</style>\\n</head>\\n<body>\\n<main>\\n` +\n `<span class=\"${healthy ? 'dot' : 'dot down'}\" aria-hidden=\"true\"></span>\\n` +\n `<div>\\n<h1>Application ${healthy ? 'up' : 'experiencing problems'}</h1>\\n<p>HTTP request received.${time}</p>\\n</div>\\n` +\n '</main>\\n</body>\\n</html>\\n'\n return new Response(html, { status: healthy ? 200 : 500, headers: { 'content-type': 'text/html; charset=utf-8' } })\n}\n\n/**\n * The `/up` action: dispatches DiagnosingHealth, then renders the page. A listener's exception is rethrown in debug\n * mode (the error page shows it); otherwise it is reported, and the page answers 500 without its message.\n */\nexport async function diagnoseHealth(app: Container): Promise<Response> {\n const started = performance.now()\n const config = app.bound(ConfigRepository) ? app.make(ConfigRepository) : undefined\n let healthy = true\n try {\n if (app.bound(EventDispatcher)) await app.make(EventDispatcher).dispatch(new DiagnosingHealth())\n } catch (error) {\n if (config?.get<unknown>('app.debug', false) === true) throw error\n if (app.bound(ExceptionHandler)) await app.make(ExceptionHandler).report(error)\n healthy = false\n }\n const appName = String(config?.get('app.name', 'Oriel') ?? 'Oriel')\n return healthResponse({ healthy, appName, milliseconds: performance.now() - started })\n}\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","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 { diagnoseHealth } from './health'\nimport { loadRoutesFrom } from './routeFiles'\nimport { ThrottleRequests } from './ThrottleRequests'\nimport { SetCacheHeaders } from './SetCacheHeaders'\nimport { ValidateSignature } from './ValidateSignature'\n\n/**\n * Binds the Router and the UrlGenerator, registers the `signed` and `throttle` middleware, and once the app has booted\n * loads the files given to withRouting(): the health URI (which dispatches DiagnosingHealth), then the web files in the\n * `web` middleware group, then the api files under the api prefix in the `api` group (Laravel's\n * 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\n .make(Router)\n .aliasMiddleware('signed', ValidateSignature)\n .aliasMiddleware('throttle', ThrottleRequests)\n .aliasMiddleware('cache.headers', SetCacheHeaders)\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, () => diagnoseHealth(this.app))\n if (web !== undefined) await router.middleware('web').group(() => this.#load(router, web))\n if (api !== undefined) await router.prefix(apiPrefix).middleware('api').group(() => this.#load(router, api))\n })\n }\n\n /** One file or several, in order: each is imported afresh for this application (a nested import is not). */\n async #load(router: Router, files: string | string[]): Promise<void> {\n for (const file of [files].flat()) await loadRoutesFrom(this.app, router, file)\n }\n}\n","import { createHash } from 'node:crypto'\nimport { RateLimiter, type HttpRequest, type Middleware, type Next } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { RoutingError, ThrottleRequestsError } from './errors'\n\nconst sha1 = (value: string): string => createHash('sha1').update(value).digest('hex')\n\n/** Sets headers, copying the response first when its headers are immutable (Response.redirect()). */\nfunction withHeaders(response: Response, headers: Record<string, string>): Response {\n try {\n for (const [name, value] of Object.entries(headers)) response.headers.set(name, value)\n return response\n } catch {\n const copy = new Headers(response.headers)\n for (const [name, value] of Object.entries(headers)) copy.set(name, value)\n return new Response(response.body, { status: response.status, statusText: response.statusText, headers: copy })\n }\n}\n\n/**\n * Laravel's ThrottleRequests (`throttle:<maxAttempts>,<decayMinutes>[,<prefix>]`): counts the client's requests\n * (the signed-in user, else the IP) in a window and answers 429 once there are too many. Responses carry\n * X-RateLimit-Limit and X-RateLimit-Remaining; the 429 adds Retry-After and X-RateLimit-Reset.\n */\nexport class ThrottleRequests implements Middleware {\n async handle(request: HttpRequest, next: Next, maxAttempts = '60', decayMinutes = '1', prefix = ''): Promise<Response> {\n const max = Number(maxAttempts)\n const decay = Number(decayMinutes)\n if (maxAttempts.trim() === '' || !Number.isInteger(max) || max < 0 || decayMinutes.trim() === '' || !Number.isFinite(decay) || decay <= 0) {\n throw new RoutingError(\n `Invalid throttle parameters \"${maxAttempts},${decayMinutes}\": use throttle:<maxAttempts>,<decayMinutes>[,<prefix>] (named rate limiters are not supported).`,\n )\n }\n const limiter = inject(RateLimiter)\n const key = prefix + (await this.resolveRequestSignature(request))\n if (await limiter.tooManyAttempts(key, max)) {\n const retryAfter = await limiter.availableIn(key)\n throw new ThrottleRequestsError({\n 'X-RateLimit-Limit': String(max),\n 'X-RateLimit-Remaining': '0',\n 'Retry-After': String(retryAfter),\n 'X-RateLimit-Reset': String(Math.floor(Date.now() / 1000) + retryAfter),\n })\n }\n await limiter.hit(key, Math.round(decay * 60))\n const response = await next(request)\n return withHeaders(response, {\n 'X-RateLimit-Limit': String(max),\n 'X-RateLimit-Remaining': String(await limiter.remaining(key, max)),\n })\n }\n\n /** The signed-in user's identifier, else the client IP, hashed (Laravel's resolveRequestSignature()). */\n protected async resolveRequestSignature(request: HttpRequest): Promise<string> {\n const user = await request.user<{ getAuthIdentifier?(): unknown }>()\n if (user !== undefined && user !== null && typeof user.getAuthIdentifier === 'function') {\n return sha1(String(user.getAuthIdentifier()))\n }\n return sha1(`|${request.ip() ?? ''}`)\n }\n}\n","import { createHash } from 'node:crypto'\nimport type { HttpRequest, Middleware, Next } from '@orieljs/contracts'\n\n/** The Cache-Control directives `cache.headers` takes, written with `_` as Laravel's are. */\nconst DIRECTIVES = new Set([\n 'public',\n 'private',\n 'no_cache',\n 'no_store',\n 'no_transform',\n 'must_revalidate',\n 'proxy_revalidate',\n 'immutable',\n 'max_age',\n 's_maxage',\n 'stale_while_revalidate',\n 'stale_if_error',\n])\n\n/**\n * Laravel's SetCacheHeaders (`cache.headers:public;max_age=3600;s_maxage=86400;etag`): a GET or HEAD response gets\n * the Cache-Control directives, and with `etag` an ETag from the body's MD5, answering 304 to a matching\n * If-None-Match. A response that sets a cookie, or already says `no-store`, is left alone, so a CDN never stores a\n * page made for one visitor.\n */\nexport class SetCacheHeaders implements Middleware {\n async handle(request: HttpRequest, next: Next, ...parameters: string[]): Promise<Response> {\n const response = await next(request)\n const method = request.method()\n if (method !== 'GET' && method !== 'HEAD') return response\n if (response.headers.has('set-cookie') || /\\bno-store\\b/i.test(response.headers.get('cache-control') ?? '')) return response\n\n const options = parameters\n .join(',')\n .split(';')\n .map((option) => option.trim())\n .filter((option) => option !== '')\n const headers = new Headers(response.headers)\n const directives: string[] = []\n let etag = false\n for (const option of options) {\n const [name = '', value] = option.split('=', 2)\n if (name === 'etag') {\n etag = true\n continue\n }\n if (!DIRECTIVES.has(name)) throw new Error(`cache.headers: unknown option \"${name}\".`)\n const directive = name.replace(/_/g, '-')\n directives.push(value === undefined ? directive : `${directive}=${value}`)\n }\n if (directives.length > 0) headers.set('cache-control', directives.join(', '))\n if (!etag) return new Response(response.body, { status: response.status, statusText: response.statusText, headers })\n\n const body = new Uint8Array(await response.arrayBuffer())\n const tag = `\"${createHash('md5').update(body).digest('hex')}\"`\n headers.set('etag', tag)\n if (matches(request.header('if-none-match'), tag)) {\n const notModified = new Headers({ etag: tag })\n const cacheControl = headers.get('cache-control')\n if (cacheControl !== null) notModified.set('cache-control', cacheControl)\n return new Response(null, { status: 304, headers: notModified })\n }\n return new Response(body, { status: response.status, statusText: response.statusText, headers })\n }\n}\n\n/** If-None-Match holds the tag, weak (`W/\"…\"`) or not, or `*`. */\nfunction matches(header: string | undefined, tag: string): boolean {\n if (header === undefined) return false\n return header.split(',').some((candidate) => {\n const value = candidate.trim()\n return value === '*' || value === tag || value === `W/${tag}`\n })\n}\n","import { UrlGenerator, type HttpRequest, type Middleware, type Next } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { InvalidUrlSignatureError } from './errors'\n\n/**\n * Laravel's ValidateSignature (`signed`, `signed:relative`): the request URL must carry a valid, unexpired\n * signature from URL.signedRoute()/temporarySignedRoute(), else 403. `relative` checks a path-only signature.\n */\nexport class ValidateSignature implements Middleware {\n async handle(request: HttpRequest, next: Next, ...parameters: string[]): Promise<Response> {\n const absolute = parameters[0] !== 'relative'\n if (inject(UrlGenerator).hasValidSignature(request, absolute)) return next(request)\n throw new InvalidUrlSignatureError()\n }\n}\n"],"mappings":";AAAA;AAAA,EACE,gBAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAYK;AACP,SAAS,oBAAAC,yBAAwB;;;ACjBjC,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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oute","currentContainer","currentContainer","ConfigRepository","ExceptionHandler","html","Router","UrlGenerator","createHash","UrlGenerator","inject","inject","UrlGenerator","Router","UrlGenerator"]}
|
|
1
|
+
{"version":3,"sources":["../BaseRouter.ts","../bindings.ts","../errors.ts","../middleware.ts","../toResponse.ts","../dispatch.ts","../RouteDefinition.ts","../GroupRegistrar.ts","../resource.ts","../BaseUrlGenerator.ts","../facade.ts","../health.ts","../routeFiles.ts","../RoutingServiceProvider.ts","../ThrottleRequests.ts","../SetCacheHeaders.ts","../ValidateSignature.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 InvokableClass,\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 { substituteBindings } from './bindings'\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 | InvokableClass | string): RouteDefinition {\n return this.addRoute(['GET', 'HEAD'], uri, action)\n }\n\n post<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['POST'], uri, action)\n }\n\n put<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['PUT'], uri, action)\n }\n\n patch<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['PATCH'], uri, action)\n }\n\n delete<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['DELETE'], uri, action)\n }\n\n options<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(['OPTIONS'], uri, action)\n }\n\n any<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.addRoute(ALL_VERBS, uri, action)\n }\n\n match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | 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: Array<MiddlewareReference | readonly 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 /**\n * Binds a matched route's raw parameter values as a request to it would: Route.bind() callbacks, Route.model(),\n * then implicit binding through the RouteModelResolver of `container`. A missing model throws\n * RouteModelNotFoundError (404). Live uses it to check a page route's `can:` middleware again on each update.\n */\n substituteBindings(route: RouteDefinition, values: Readonly<Record<string, string | undefined>>, container: Container): Promise<Record<string, unknown>> {\n return substituteBindings(this, route, values, container)\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 { 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, then `throttle` (so a throttled request does no lookup, and a missing model's 404\n * counts toward the limit), 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 const throttle = Object.hasOwn(aliases, 'throttle') ? aliases['throttle'] : undefined\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 isThrottle = (entry: ResolvedMiddleware) => throttle !== undefined && entry.cls === throttle\n const before = middleware.filter((entry) => early.has(entry.cls) && !isThrottle(entry))\n const throttled = middleware.filter(isThrottle)\n const after = middleware.filter((entry) => !early.has(entry.cls) && !isThrottle(entry))\n return { middleware: [...before, ...throttled, ...after], at: before.length + throttled.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\n/** A signed URL whose signature is missing, wrong or expired (Laravel's InvalidSignatureException). */\nexport class InvalidUrlSignatureError extends Error implements OrielError {\n readonly kind = 'Http' as const\n readonly status = 403\n override readonly name = 'InvalidUrlSignatureError'\n constructor() {\n super('Invalid signature.')\n }\n}\n\n/** Too many requests in the window (Laravel's ThrottleRequestsException): 429 with Retry-After and X-RateLimit-*. */\nexport class ThrottleRequestsError extends Error implements OrielError {\n readonly kind = 'Http' as const\n readonly status = 429\n override readonly name = 'ThrottleRequestsError'\n constructor(readonly headers: Record<string, string> = {}) {\n super('Too Many Attempts.')\n }\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\n/**\n * Converts a stage's result, and renders a thrown error at this stage. A middleware stage must return something\n * (Laravel's \"Middleware must return a Response.\"); only the action's nothing becomes a 204.\n */\nasync function guard(\n container: Container,\n request: HttpRequest,\n run: () => Promise<unknown>,\n stage: 'middleware' | 'action' = 'middleware',\n): Promise<Response> {\n try {\n const result = await run()\n if (result instanceof Response) return result\n if (stage === 'middleware' && (result === undefined || result === null)) {\n throw new RoutingError('Middleware must return a Response.')\n }\n return 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), 'action'))\n}\n","import { ViewFactory } from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport { RoutingError } from './errors'\n\n/** The marker View's elements carry (Symbol.for, so Routing needn't import View). */\nconst ELEMENT = Symbol.for('oriel:view.element')\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 // A TSX element: rendered as a view is (an <html> root gets its doctype)\n if ((value as Record<symbol, unknown>)[ELEMENT] === true) return html(await renderElement(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\nasync function renderElement(element: unknown): Promise<string> {\n const container = currentContainer()\n if (container === undefined || !container.bound(ViewFactory)) {\n throw new RoutingError('Returning a TSX element needs the View service provider.')\n }\n return container.make(ViewFactory).renderToString(element)\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 { 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 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('auth', 'verified') or middleware(['auth', 'verified']). */\n middleware(...middleware: Array<MiddlewareReference | readonly 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 /** Laravel's whereAlpha(): ASCII letters only. One parameter name or several. */\n whereAlpha(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[a-zA-Z]+')\n }\n\n /** Laravel's whereAlphaNumeric(): ASCII letters and digits. */\n whereAlphaNumeric(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[a-zA-Z0-9]+')\n }\n\n /** Laravel's whereNumber(): digits only. */\n whereNumber(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[0-9]+')\n }\n\n /** Laravel's whereUlid(): 26 Crockford base-32 characters, the first at most 7. */\n whereUlid(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[0-7][0-9a-hjkmnp-tv-zA-HJKMNP-TV-Z]{25}')\n }\n\n /** Laravel's whereUuid(): five groups of hex digits (8-4-4-4-12), any version. */\n whereUuid(parameters: string | readonly string[]): this {\n return this.#assign(parameters, '[\\\\da-fA-F]{8}-[\\\\da-fA-F]{4}-[\\\\da-fA-F]{4}-[\\\\da-fA-F]{4}-[\\\\da-fA-F]{12}')\n }\n\n /** Laravel's whereIn(): one of the values. Unlike Laravel, each value is matched literally (`c++` is not a pattern). */\n whereIn(parameters: string | readonly string[], values: ReadonlyArray<string | number>): this {\n const first = typeof parameters === 'string' ? parameters : parameters[0]\n if (values.length === 0 && first !== undefined) throw new Error(`Routing requirement for \"${first}\" cannot be empty.`)\n return this.#assign(parameters, values.map((value) => escapeRegex(String(value))).join('|'))\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 #assign(parameters: string | readonly string[], pattern: string): this {\n const names: readonly string[] = typeof parameters === 'string' ? [parameters] : parameters\n return this.where(Object.fromEntries(names.map((name) => [name, pattern])))\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, InvokableClass, 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: Array<MiddlewareReference | readonly 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 | InvokableClass | string): RouteDefinition {\n return this.#one(['GET', 'HEAD'], uri, action)\n }\n\n post<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['POST'], uri, action)\n }\n\n put<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['PUT'], uri, action)\n }\n\n patch<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['PATCH'], uri, action)\n }\n\n delete<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['DELETE'], uri, action)\n }\n\n options<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(['OPTIONS'], uri, action)\n }\n\n any<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): RouteDefinition {\n return this.#one(ALL_VERBS, uri, action)\n }\n\n match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | 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 { createHmac, timingSafeEqual } from 'node:crypto'\nimport { ConfigRepository, Encrypter, HttpRequest, Session, type Container, type UrlGenerator } from '@orieljs/contracts'\nimport { currentContainer } from '@orieljs/container'\nimport type { BaseRouter } from './BaseRouter'\nimport { RouteNotDefinedError, RoutingError, 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/** Whether a where() pattern matches a value with a slash in it. */\nfunction acceptsSlash(pattern: string | undefined): boolean {\n if (pattern === undefined) return false\n try {\n return new RegExp(`^(?:${pattern})$`).test('a/b')\n } catch {\n return false\n }\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/** HMAC-SHA256 of a URL, hex (Laravel's hash_hmac('sha256', $url, $key)). */\nfunction sign(url: string, key: Uint8Array): string {\n return createHmac('sha256', key).update(url).digest('hex')\n}\n\n/** Constant-time string comparison. */\nfunction safeEquals(expected: string, given: string): boolean {\n const a = Buffer.from(expected)\n const b = Buffer.from(given)\n return a.length === b.length && timingSafeEqual(a, b)\n}\n\n/** Unix seconds: a Date, or a number of seconds from now (Laravel's availableAt()). */\nfunction availableAt(expiration: Date | number): number {\n return expiration instanceof Date ? Math.floor(expiration.getTime() / 1000) : Math.floor(Date.now() / 1000) + expiration\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 wheres = route.wheres()\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 if (value === undefined) return ''\n // A parameter whose where() pattern takes slashes ({path} with '.*') keeps them, as Laravel's URLs do.\n return acceptsSlash(wheres[parameter]) ? value.split('/').map(encodeURIComponent).join('/') : 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 // An empty ASSET_URL= in .env is no asset URL, as Laravel's `?:`.\n const assetUrl = this.#config<string | undefined>('app.asset_url', undefined)?.replace(/\\/+$/, '')\n const base = assetUrl === undefined || assetUrl === '' ? this.root() : assetUrl\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 /**\n * Laravel's URL::signedRoute(): the route URL with its parameters sorted by name, then a `signature` query (the\n * HMAC-SHA256 of that URL, keyed by APP_KEY). `expiration` (a Date, or seconds from now) adds `expires`.\n * `absolute: false` signs the path only (checked by `signed:relative`).\n */\n signedRoute(name: string, parameters?: unknown, expiration?: Date | number, absolute = true): string {\n const named = this.#namedParameters(name, parameters)\n for (const reserved of ['signature', 'expires']) {\n if (Object.hasOwn(named, reserved)) {\n throw new RoutingError(`\"${reserved}\" is a reserved parameter when generating signed routes. Please rename your route parameter.`)\n }\n }\n if (expiration !== undefined) named.expires = availableAt(expiration)\n const sorted = Object.fromEntries(Object.keys(named).sort().map((key) => [key, named[key]]))\n const signature = sign(this.route(name, sorted, absolute), this.#signingKeys()[0]!)\n return this.route(name, { ...sorted, signature }, absolute)\n }\n\n /** Laravel's URL::temporarySignedRoute(): a signed URL that expires at `expiration` (a Date, or seconds from now). */\n temporarySignedRoute(name: string, expiration: Date | number, parameters?: unknown, absolute = true): string {\n return this.signedRoute(name, parameters, expiration, absolute)\n }\n\n /** The request URL carries a correct signature (current or previous APP_KEY) that hasn't expired. */\n hasValidSignature(request: HttpRequest, absolute = true): boolean {\n return this.hasCorrectSignature(request, absolute) && this.signatureHasNotExpired(request)\n }\n\n /** The signature matches the URL without its `signature` query, in a constant-time comparison. */\n hasCorrectSignature(request: HttpRequest, absolute = true): boolean {\n const full = new URL(request.fullUrl())\n const path = request.path()\n const url = absolute ? request.url() : path === '/' ? '/' : `/${path}`\n const query = full.search\n .slice(1)\n .split('&')\n .filter((pair) => pair !== '' && pair.split('=')[0] !== 'signature')\n .join('&')\n const original = query === '' ? url : `${url}?${query}`\n const given = full.searchParams.get('signature') ?? ''\n return this.#signingKeys().some((key) => safeEquals(sign(original, key), given))\n }\n\n /** No `expires` query, or one that is still in the future. */\n signatureHasNotExpired(request: HttpRequest): boolean {\n const expires = new URL(request.fullUrl()).searchParams.get('expires')\n if (expires === null || expires === '') return true\n const at = Number(expires)\n return Number.isFinite(at) && Math.floor(Date.now() / 1000) <= at\n }\n\n /** Named parameters: an object as is, positional values (a list or one value) by the route's parameter names. */\n #namedParameters(name: string, parameters: unknown): Record<string, unknown> {\n if (isPlainObject(parameters)) return { ...parameters }\n const route = this.router.getByName(name)\n if (route === undefined) throw new RouteNotDefinedError(name)\n const values = parameters === undefined || parameters === null ? [] : Array.isArray(parameters) ? parameters : [parameters]\n const named: Record<string, unknown> = {}\n route.parameters.forEach((parameter, index) => {\n if (index < values.length) named[parameter.name] = values[index]\n })\n return named\n }\n\n /** The Encrypter's key, then its previous keys (config app.previous_keys), so rotated keys still verify. */\n #signingKeys(): Uint8Array[] {\n const scope = this.#scope()\n if (scope === undefined || !scope.bound(Encrypter)) {\n throw new RoutingError('Signed URLs need the Encrypter: set APP_KEY (oriel key:generate).')\n }\n const encrypter = scope.make(Encrypter) as Encrypter & { getAllKeys?(): Uint8Array[] }\n return typeof encrypter.getAllKeys === 'function' ? encrypter.getAllKeys() : [encrypter.getKey()]\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 { ConfigRepository, EventDispatcher, ExceptionHandler, type Container } from '@orieljs/contracts'\n\n/**\n * Dispatched by the health route (`/up`) on every request (Laravel's DiagnosingHealth event). A listener checks\n * something the application needs, such as the database or the cache, and throws when it fails: `/up` then answers\n * 500 with \"Application experiencing problems\", and the exception is reported.\n *\n * Event.listen(DiagnosingHealth, async () => { await DB.select('select 1') })\n */\nexport class DiagnosingHealth {}\n\nexport interface HealthPage {\n /** False when a check failed: the page says so and the status is 500 (default true). */\n healthy?: boolean\n /** How long the request took, shown when given. */\n milliseconds?: number\n /** The page title (default \"Oriel\"). */\n appName?: string\n}\n\nconst escapeHtml = (value: string): string => value.replace(/[&<>\"']/g, (char) => `&#${char.charCodeAt(0)};`)\n\n// The Oriel style: dark canvas, one Graphite block, the system fonts, flat. Green and red are the status dot only.\nconst STYLE =\n ':root{color-scheme:dark}*{box-sizing:border-box;margin:0}html{background:#05050b}' +\n 'body{min-height:100vh;display:grid;place-items:center;padding:20px;background:#1a1a1a;color:#fff;' +\n 'font:400 16px/1.7 system-ui,-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif}' +\n 'main{display:flex;align-items:center;gap:20px;width:100%;max-width:640px;padding:20px 32px;border-radius:18px;background:#212121}' +\n '.dot{flex:none;width:12px;height:12px;border-radius:50%;background:#74ec5a}.dot.down{background:#ff3543}' +\n 'h1{font-size:21px;line-height:1.4;font-weight:600}p{color:#a3a3a3}.time{color:#ba94ff}'\n\n/**\n * The health route's page (Laravel's health-up view): \"Application up\", or \"Application experiencing problems\" with\n * status 500. Self-contained HTML with inline CSS: it loads nothing, so it answers even when the assets don't.\n */\nexport function healthResponse(page: HealthPage = {}): Response {\n const healthy = page.healthy ?? true\n const time = page.milliseconds === undefined ? '' : ` Response rendered in <span class=\"time\">${Math.round(page.milliseconds)} ms</span>.`\n const html =\n '<!DOCTYPE html>\\n<html lang=\"en\">\\n<head>\\n<meta charset=\"utf-8\">\\n' +\n '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\\n' +\n `<title>${escapeHtml(page.appName ?? 'Oriel')}</title>\\n<style>${STYLE}</style>\\n</head>\\n<body>\\n<main>\\n` +\n `<span class=\"${healthy ? 'dot' : 'dot down'}\" aria-hidden=\"true\"></span>\\n` +\n `<div>\\n<h1>Application ${healthy ? 'up' : 'experiencing problems'}</h1>\\n<p>HTTP request received.${time}</p>\\n</div>\\n` +\n '</main>\\n</body>\\n</html>\\n'\n return new Response(html, { status: healthy ? 200 : 500, headers: { 'content-type': 'text/html; charset=utf-8' } })\n}\n\n/**\n * The `/up` action: dispatches DiagnosingHealth, then renders the page. A listener's exception is rethrown in debug\n * mode (the error page shows it); otherwise it is reported, and the page answers 500 without its message.\n */\nexport async function diagnoseHealth(app: Container): Promise<Response> {\n const started = performance.now()\n const config = app.bound(ConfigRepository) ? app.make(ConfigRepository) : undefined\n let healthy = true\n try {\n if (app.bound(EventDispatcher)) await app.make(EventDispatcher).dispatch(new DiagnosingHealth())\n } catch (error) {\n if (config?.get<unknown>('app.debug', false) === true) throw error\n if (app.bound(ExceptionHandler)) await app.make(ExceptionHandler).report(error)\n healthy = false\n }\n const appName = String(config?.get('app.name', 'Oriel') ?? 'Oriel')\n return healthResponse({ healthy, appName, milliseconds: performance.now() - started })\n}\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","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 { diagnoseHealth } from './health'\nimport { loadRoutesFrom } from './routeFiles'\nimport { ThrottleRequests } from './ThrottleRequests'\nimport { SetCacheHeaders } from './SetCacheHeaders'\nimport { ValidateSignature } from './ValidateSignature'\n\n/**\n * Binds the Router and the UrlGenerator, registers the `signed` and `throttle` middleware, and once the app has booted\n * loads the files given to withRouting(): the health URI (which dispatches DiagnosingHealth), then the web files in the\n * `web` middleware group, then the api files under the api prefix in the `api` group (Laravel's\n * 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\n .make(Router)\n .aliasMiddleware('signed', ValidateSignature)\n .aliasMiddleware('throttle', ThrottleRequests)\n .aliasMiddleware('cache.headers', SetCacheHeaders)\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, () => diagnoseHealth(this.app))\n if (web !== undefined) await router.middleware('web').group(() => this.#load(router, web))\n if (api !== undefined) await router.prefix(apiPrefix).middleware('api').group(() => this.#load(router, api))\n })\n }\n\n /** One file or several, in order: each is imported afresh for this application (a nested import is not). */\n async #load(router: Router, files: string | string[]): Promise<void> {\n for (const file of [files].flat()) await loadRoutesFrom(this.app, router, file)\n }\n}\n","import { createHash } from 'node:crypto'\nimport { RateLimiter, type HttpRequest, type Middleware, type Next, type RateLimit } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { RoutingError, ThrottleRequestsError } from './errors'\n\nconst sha1 = (value: string): string => createHash('sha1').update(value).digest('hex')\n\n/** Sets headers, copying the response first when its headers are immutable (Response.redirect()). */\nfunction withHeaders(response: Response, headers: Record<string, string>): Response {\n try {\n for (const [name, value] of Object.entries(headers)) response.headers.set(name, value)\n return response\n } catch {\n const copy = new Headers(response.headers)\n for (const [name, value] of Object.entries(headers)) copy.set(name, value)\n return new Response(response.body, { status: response.status, statusText: response.statusText, headers: copy })\n }\n}\n\n/**\n * Laravel's ThrottleRequests (`throttle:<maxAttempts>,<decayMinutes>[,<prefix>]`): counts the client's requests\n * (the signed-in user, else the IP) in a window and answers 429 once there are too many. Responses carry\n * X-RateLimit-Limit and X-RateLimit-Remaining; the 429 adds Retry-After and X-RateLimit-Reset. `throttle:<name>`\n * uses the limits `RateLimiter.for(name, …)` returns for the request instead.\n */\nexport class ThrottleRequests implements Middleware {\n async handle(request: HttpRequest, next: Next, ...parameters: string[]): Promise<Response> {\n if (parameters.length === 1 && !/^\\d+$/.test(parameters[0]!.trim())) return this.#named(request, next, parameters[0]!)\n const [maxAttempts = '60', decayMinutes = '1', prefix = ''] = parameters\n return this.#numbered(request, next, maxAttempts, decayMinutes, prefix)\n }\n\n /** Laravel's handleRequestUsingNamedLimiter(): each limit checked and hit in order, under sha1(name + its key). */\n async #named(request: HttpRequest, next: Next, name: string): Promise<Response> {\n const limiter = inject(RateLimiter)\n const callback = limiter.limiter(name)\n if (callback === undefined) throw new RoutingError(`Rate limiter [${name}] is not defined.`)\n const result = await callback(request)\n const limits = (Array.isArray(result) ? result : [result]).filter((limit: RateLimit) => limit.unlimited !== true)\n if (limits.length === 0) return next(request)\n const keyed = limits.map((limit) => ({ key: sha1(name + limit.key), max: limit.maxAttempts, decay: limit.decaySeconds }))\n for (const limit of keyed) {\n if (await limiter.tooManyAttempts(limit.key, limit.max)) throw await this.#tooMany(limit.key, limit.max)\n await limiter.hit(limit.key, limit.decay)\n }\n let response = await next(request)\n for (const limit of keyed) {\n response = withHeaders(response, {\n 'X-RateLimit-Limit': String(limit.max),\n 'X-RateLimit-Remaining': String(await limiter.remaining(limit.key, limit.max)),\n })\n }\n return response\n }\n\n async #tooMany(key: string, max: number): Promise<ThrottleRequestsError> {\n const retryAfter = await inject(RateLimiter).availableIn(key)\n return new ThrottleRequestsError({\n 'X-RateLimit-Limit': String(max),\n 'X-RateLimit-Remaining': '0',\n 'Retry-After': String(retryAfter),\n 'X-RateLimit-Reset': String(Math.floor(Date.now() / 1000) + retryAfter),\n })\n }\n\n async #numbered(request: HttpRequest, next: Next, maxAttempts: string, decayMinutes: string, prefix: string): Promise<Response> {\n const max = Number(maxAttempts)\n const decay = Number(decayMinutes)\n if (maxAttempts.trim() === '' || !Number.isInteger(max) || max < 0 || decayMinutes.trim() === '' || !Number.isFinite(decay) || decay <= 0) {\n throw new RoutingError(\n `Invalid throttle parameters \"${maxAttempts},${decayMinutes}\": use throttle:<maxAttempts>,<decayMinutes>[,<prefix>] or throttle:<name>.`,\n )\n }\n const limiter = inject(RateLimiter)\n const key = prefix + (await this.resolveRequestSignature(request))\n if (await limiter.tooManyAttempts(key, max)) throw await this.#tooMany(key, max)\n await limiter.hit(key, Math.round(decay * 60))\n const response = await next(request)\n return withHeaders(response, {\n 'X-RateLimit-Limit': String(max),\n 'X-RateLimit-Remaining': String(await limiter.remaining(key, max)),\n })\n }\n\n /** The signed-in user's identifier, else the client IP, hashed (Laravel's resolveRequestSignature()). */\n protected async resolveRequestSignature(request: HttpRequest): Promise<string> {\n const user = await request.user<{ getAuthIdentifier?(): unknown }>()\n if (user !== undefined && user !== null && typeof user.getAuthIdentifier === 'function') {\n return sha1(String(user.getAuthIdentifier()))\n }\n return sha1(`|${request.ip() ?? ''}`)\n }\n}\n","import { createHash } from 'node:crypto'\nimport type { HttpRequest, Middleware, Next } from '@orieljs/contracts'\n\n/** The Cache-Control directives `cache.headers` takes, written with `_` as Laravel's are. */\nconst DIRECTIVES = new Set([\n 'public',\n 'private',\n 'no_cache',\n 'no_store',\n 'no_transform',\n 'must_revalidate',\n 'proxy_revalidate',\n 'immutable',\n 'max_age',\n 's_maxage',\n 'stale_while_revalidate',\n 'stale_if_error',\n])\n\n/**\n * Laravel's SetCacheHeaders (`cache.headers:public;max_age=3600;s_maxage=86400;etag`): a GET or HEAD response gets\n * the Cache-Control directives, and with `etag` an ETag from the body's MD5, answering 304 to a matching\n * If-None-Match. A response that sets a cookie, or already says `no-store`, is left alone, so a CDN never stores a\n * page made for one visitor.\n */\nexport class SetCacheHeaders implements Middleware {\n async handle(request: HttpRequest, next: Next, ...parameters: string[]): Promise<Response> {\n const response = await next(request)\n const method = request.method()\n if (method !== 'GET' && method !== 'HEAD') return response\n if (response.headers.has('set-cookie') || /\\bno-store\\b/i.test(response.headers.get('cache-control') ?? '')) return response\n\n const options = parameters\n .join(',')\n .split(';')\n .map((option) => option.trim())\n .filter((option) => option !== '')\n const headers = new Headers(response.headers)\n const directives: string[] = []\n let etag = false\n for (const option of options) {\n const [name = '', value] = option.split('=', 2)\n if (name === 'etag') {\n etag = true\n continue\n }\n if (!DIRECTIVES.has(name)) throw new Error(`cache.headers: unknown option \"${name}\".`)\n const directive = name.replace(/_/g, '-')\n directives.push(value === undefined ? directive : `${directive}=${value}`)\n }\n if (directives.length > 0) headers.set('cache-control', directives.join(', '))\n if (!etag) return new Response(response.body, { status: response.status, statusText: response.statusText, headers })\n\n const body = new Uint8Array(await response.arrayBuffer())\n const tag = `\"${createHash('md5').update(body).digest('hex')}\"`\n headers.set('etag', tag)\n if (matches(request.header('if-none-match'), tag)) {\n const notModified = new Headers({ etag: tag })\n const cacheControl = headers.get('cache-control')\n if (cacheControl !== null) notModified.set('cache-control', cacheControl)\n return new Response(null, { status: 304, headers: notModified })\n }\n return new Response(body, { status: response.status, statusText: response.statusText, headers })\n }\n}\n\n/** If-None-Match holds the tag, weak (`W/\"…\"`) or not, or `*`. */\nfunction matches(header: string | undefined, tag: string): boolean {\n if (header === undefined) return false\n return header.split(',').some((candidate) => {\n const value = candidate.trim()\n return value === '*' || value === tag || value === `W/${tag}`\n })\n}\n","import { UrlGenerator, type HttpRequest, type Middleware, type Next } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { InvalidUrlSignatureError } from './errors'\n\n/**\n * Laravel's ValidateSignature (`signed`, `signed:relative`): the request URL must carry a valid, unexpired\n * signature from URL.signedRoute()/temporarySignedRoute(), else 403. `relative` checks a path-only signature.\n */\nexport class ValidateSignature implements Middleware {\n async handle(request: HttpRequest, next: Next, ...parameters: string[]): Promise<Response> {\n const absolute = parameters[0] !== 'relative'\n if (inject(UrlGenerator).hasValidSignature(request, absolute)) return next(request)\n throw new InvalidU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AAW,KAAK,EAAE,MAAM,MAAM,KAAK,MAAM,QAAQ,GAAG,CAAC;AAAA,IAC7G,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAM,QAAgB,OAAyC;AACnE,eAAW,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAG,OAAM,eAAe,KAAK,KAAK,QAAQ,IAAI;AAAA,EAChF;AACF;","names":["CurrentRoute","ViewFactory","currentContainer","currentContainer","currentContainer","Str","currentContainer","ViewFactory","CurrentRoute","currentContainer","currentContainer","ConfigRepository","ExceptionHandler","html","Router","UrlGenerator","createHash","UrlGenerator","inject","inject","UrlGenerator","Router","UrlGenerator"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orieljs/routing",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
4
|
-
"description": "The Oriel
|
|
3
|
+
"version": "0.1.0-alpha.16",
|
|
4
|
+
"description": "The Oriel router, as Laravel's: map a URL and an HTTP method to a closure or a controller action, with model binding.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"homepage": "https://orieljs.vercel.app",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"TRADEMARKS.md"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@orieljs/contracts": "0.1.0-alpha.
|
|
35
|
-
"@orieljs/support": "0.1.0-alpha.
|
|
36
|
-
"@orieljs/container": "0.1.0-alpha.
|
|
34
|
+
"@orieljs/contracts": "0.1.0-alpha.16",
|
|
35
|
+
"@orieljs/support": "0.1.0-alpha.16",
|
|
36
|
+
"@orieljs/container": "0.1.0-alpha.16"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsup && node ../../../scripts/copy-license.mjs"
|