@rudderjs/router 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -196,6 +196,23 @@ Returning `null` from `findForRoute` triggers `RouteModelNotFoundError` (HTTP 40
196
196
 
197
197
  The `RouteResolver` contract is duck-typed — `name: string` + `findForRoute(value): unknown | Promise<unknown | null>` — so the router doesn't depend on `@rudderjs/orm`.
198
198
 
199
+ ### Catch-all fallback with `router.fallback()`
200
+
201
+ Register a handler that runs when no other route matches — Laravel's `Route::fallback()`. Use it for custom 404 JSON shapes, vanity URL redirects, or a "soft" landing on api routes:
202
+
203
+ ```ts
204
+ router.fallback((_req, res) => res.status(404).json({
205
+ message: 'Endpoint not found',
206
+ }))
207
+
208
+ // Per-request middleware works too
209
+ router.fallback(handler, [LogUnknownRoute()])
210
+ ```
211
+
212
+ Only one fallback per router — registering a second one replaces the first. The fallback runs after every other matcher, including `router.all('/api/*', ...)`, so use it as the last-resort 404 path.
213
+
214
+ ---
215
+
199
216
  ### Custom 404 with `.missing()`
200
217
 
201
218
  Override the default 404 response per route. Receives the request and the binding error; return a value the route handler may return — `Response`, plain object → JSON, string → body, or `undefined` (you wrote to `res` directly).
@@ -368,6 +385,7 @@ router.mount(serverAdapter)
368
385
  | `use(middleware)` | `this` | Register global middleware |
369
386
  | `bind(name, resolver, opts?)` | `this` | Bind a `:param` to a `RouteResolver` (e.g. an ORM Model) for auto-resolution |
370
387
  | `listBindings()` | `Record<string, RouteResolver>` | All registered route bindings |
388
+ | `fallback(handler, mw?)` | `RouteBuilder` | Catch-all handler when no other route matches |
371
389
  | `group(opts, fn)` | `this` | Apply prefix/domain/middleware to every route registered inside `fn` |
372
390
  | `resource(name, Ctrl, opts?)` | `ResourceRegistration` | Register the seven canonical RESTful routes |
373
391
  | `apiResource(name, Ctrl, opts?)` | `ResourceRegistration` | Resource minus `create`/`edit` |
@@ -0,0 +1,54 @@
1
+ import type { MiddlewareHandler, RouteDefinition } from '@rudderjs/contracts';
2
+ /**
3
+ * Duck-typed contract for any object that resolves a string route parameter
4
+ * into a value (typically a Model instance, but the router doesn't depend on
5
+ * `@rudderjs/orm` — anything with a static `findForRoute` method works).
6
+ *
7
+ * Returning `null` signals "not found" — the router maps that to a thrown
8
+ * `RouteModelNotFoundError`, which the framework's HTTP layer renders as a 404.
9
+ */
10
+ export interface RouteResolver {
11
+ /** Owning class name — used for error messages only. */
12
+ name: string;
13
+ /** Resolve the raw param value. Return `null` for not-found. */
14
+ findForRoute(value: string): Promise<unknown | null> | unknown | null;
15
+ }
16
+ export interface RouteBindingOptions {
17
+ /**
18
+ * When `true`, an absent or unresolvable param value silently sets
19
+ * `req.bound[name] = null` instead of throwing. Useful for shared routes
20
+ * that may or may not have a logged-in subject.
21
+ */
22
+ optional?: boolean;
23
+ }
24
+ /** @internal — stored entry in `Router.bindings`. */
25
+ export interface RouteBinding {
26
+ resolver: RouteResolver;
27
+ optional: boolean;
28
+ }
29
+ /**
30
+ * Thrown by route binding middleware when a required `{param}` cannot be
31
+ * resolved into a model instance. `@rudderjs/core` picks up the duck-typed
32
+ * `httpStatus` and renders this as an HTTP 404; apps can catch it explicitly
33
+ * to render a custom not-found page.
34
+ */
35
+ export declare class RouteModelNotFoundError extends Error {
36
+ readonly model: string;
37
+ readonly param: string;
38
+ readonly value: string;
39
+ /** Duck-typed signal to `@rudderjs/core`'s exception handler. */
40
+ readonly httpStatus = 404;
41
+ constructor(model: string, param: string, value: string);
42
+ }
43
+ /**
44
+ * Build per-route binding middleware from the route's `{param}` segments and
45
+ * the router's binding map. Returns `null` when the route's path contains no
46
+ * bound params — callers skip installation in that case so unbound routes
47
+ * keep their original middleware chain.
48
+ *
49
+ * Takes the full `RouteDefinition` (not just `path`) so the closure can
50
+ * capture `def.missing` — the per-route 404 customisation set via
51
+ * `RouteBuilder.missing()`.
52
+ */
53
+ export declare function buildBindingMiddleware(bindings: Map<string, RouteBinding>, def: RouteDefinition): MiddlewareHandler | null;
54
+ //# sourceMappingURL=binding-middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-middleware.d.ts","sourceRoot":"","sources":["../src/binding-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAK7E;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,OAAO,GAAG,IAAI,CAAA;CACtE;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,aAAa,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB,iEAAiE;IACjE,QAAQ,CAAC,UAAU,OAAM;gBAEb,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAOxD;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EACnC,GAAG,EAAE,eAAe,GACnB,iBAAiB,GAAG,IAAI,CAuD1B"}
@@ -0,0 +1,101 @@
1
+ import { stripRegexSegments } from './index.js';
2
+ /**
3
+ * Thrown by route binding middleware when a required `{param}` cannot be
4
+ * resolved into a model instance. `@rudderjs/core` picks up the duck-typed
5
+ * `httpStatus` and renders this as an HTTP 404; apps can catch it explicitly
6
+ * to render a custom not-found page.
7
+ */
8
+ export class RouteModelNotFoundError extends Error {
9
+ model;
10
+ param;
11
+ value;
12
+ /** Duck-typed signal to `@rudderjs/core`'s exception handler. */
13
+ httpStatus = 404;
14
+ constructor(model, param, value) {
15
+ super(`[RudderJS] No ${model} matched route parameter "${param}" with value "${value}".`);
16
+ this.name = 'RouteModelNotFoundError';
17
+ this.model = model;
18
+ this.param = param;
19
+ this.value = value;
20
+ }
21
+ }
22
+ /**
23
+ * Build per-route binding middleware from the route's `{param}` segments and
24
+ * the router's binding map. Returns `null` when the route's path contains no
25
+ * bound params — callers skip installation in that case so unbound routes
26
+ * keep their original middleware chain.
27
+ *
28
+ * Takes the full `RouteDefinition` (not just `path`) so the closure can
29
+ * capture `def.missing` — the per-route 404 customisation set via
30
+ * `RouteBuilder.missing()`.
31
+ */
32
+ export function buildBindingMiddleware(bindings, def) {
33
+ // Strip `{regex}` constraint segments from `where*()` before scanning for
34
+ // param names — otherwise a `:` inside a custom pattern could be misread
35
+ // as a route param. Uses balanced-brace stripping to support nested `{n}`
36
+ // quantifiers (e.g. UUID's `[0-9a-f]{8}-...`).
37
+ const stripped = stripRegexSegments(def.path);
38
+ const paramNames = [...stripped.matchAll(/:([a-zA-Z_][a-zA-Z0-9_]*)\??/g)].map(m => m[1]);
39
+ const matches = [];
40
+ for (const name of paramNames) {
41
+ const binding = bindings.get(name);
42
+ if (binding)
43
+ matches.push([name, binding]);
44
+ }
45
+ if (matches.length === 0)
46
+ return null;
47
+ return async (req, res, next) => {
48
+ // Lazy-init bound bag so handlers always see an object.
49
+ const bound = req.bound ?? {};
50
+ req.bound = bound;
51
+ for (const [name, binding] of matches) {
52
+ const raw = req.params[name];
53
+ let err = null;
54
+ if (raw === undefined || raw === '') {
55
+ if (binding.optional) {
56
+ bound[name] = null;
57
+ continue;
58
+ }
59
+ err = new RouteModelNotFoundError(binding.resolver.name, name, '');
60
+ }
61
+ else {
62
+ const resolved = await binding.resolver.findForRoute(raw);
63
+ if (resolved === null || resolved === undefined) {
64
+ if (binding.optional) {
65
+ bound[name] = null;
66
+ continue;
67
+ }
68
+ err = new RouteModelNotFoundError(binding.resolver.name, name, raw);
69
+ }
70
+ else {
71
+ bound[name] = resolved;
72
+ }
73
+ }
74
+ if (err) {
75
+ if (def.missing) {
76
+ // Route opted into a custom 404 — dispatch the result the same
77
+ // way registerRoute() handles a route handler's return value.
78
+ const result = await def.missing(req, err);
79
+ if (result instanceof Response) {
80
+ ;
81
+ res.raw.res = result;
82
+ return;
83
+ }
84
+ if (typeof result === 'string') {
85
+ res.send(result);
86
+ return;
87
+ }
88
+ if (result !== undefined && result !== null) {
89
+ res.json(result);
90
+ return;
91
+ }
92
+ // undefined → callback wrote to res directly; trust that.
93
+ return;
94
+ }
95
+ throw err;
96
+ }
97
+ }
98
+ await next();
99
+ };
100
+ }
101
+ //# sourceMappingURL=binding-middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-middleware.js","sourceRoot":"","sources":["../src/binding-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAkC/C;;;;;GAKG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,KAAK,CAAQ;IACb,KAAK,CAAQ;IACb,KAAK,CAAQ;IAEtB,iEAAiE;IACxD,UAAU,GAAG,GAAG,CAAA;IAEzB,YAAY,KAAa,EAAE,KAAa,EAAE,KAAa;QACrD,KAAK,CAAC,iBAAiB,KAAK,6BAA6B,KAAK,iBAAiB,KAAK,IAAI,CAAC,CAAA;QACzF,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU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AC;gBACD,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC;QACD,MAAM,IAAI,EAAE,CAAA;IACd,CAAC,CAAA;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,45 @@
1
1
  import 'reflect-metadata';
2
- import type { ServerAdapter, RouteDefinition, RouteHandler, MiddlewareHandler, HttpMethod, RouteGroup, AppRequest } from '@rudderjs/contracts';
2
+ import type { ServerAdapter, RouteDefinition, RouteHandler, MiddlewareHandler, HttpMethod, RouteGroup } from '@rudderjs/contracts';
3
+ import type { ZodType, z } from 'zod';
4
+ import type { TypedHandler } from './typed-routes.js';
5
+ export type { ExtractParams, TypedRequest, TypedHandler } from './typed-routes.js';
6
+ /**
7
+ * Per-route options accepted in the 3-arg form of `Router.get/post/etc`.
8
+ *
9
+ * The 3-arg form exists so the handler closure can be typed against the
10
+ * Zod-inferred query shape *at write time* — the bare 2-arg form types
11
+ * `req.query` as `Record<string, string>`, and chaining `.query(schema)`
12
+ * after that can't go back and re-type the closure.
13
+ */
14
+ export interface RouteOptions<S extends ZodType = ZodType> {
15
+ /** Zod schema to validate `req.query` against. Parsed result replaces `req.query`. */
16
+ query?: S;
17
+ /** Per-route middleware (prepended before the handler). */
18
+ middleware?: MiddlewareHandler[];
19
+ }
20
+ /**
21
+ * Tag every route registered while `fn` runs with `group` ('web' | 'api').
22
+ *
23
+ * **Synchronous bodies are the supported case.** Route loaders call
24
+ * `Route.get/post/...` at module-evaluation time — those calls complete
25
+ * before `fn` resolves, even when `fn` is `async`. The implementation
26
+ * supports an async `fn` (restoring the previous group in a `.finally()`),
27
+ * but two concurrent `runWithGroup` invocations on the same module instance
28
+ * will clobber each other: this is a single module-level variable, not an
29
+ * AsyncLocalStorage scope. Callers must run loaders **serially** — see
30
+ * `@rudderjs/core`'s `withRouting()` which sequentially `await`s each
31
+ * loader.
32
+ *
33
+ * Outside any `runWithGroup` scope, routes register without a group tag and
34
+ * receive only global `m.use(...)` middleware (no `m.web(...)` / `m.api(...)`
35
+ * stack).
36
+ */
3
37
  export declare function runWithGroup<R>(group: RouteGroup, fn: () => R | Promise<R>): R | Promise<R>;
38
+ /**
39
+ * Read the current group tag. Reads the module-level slot directly; returns
40
+ * `undefined` outside any `runWithGroup(...)` block. Called by route
41
+ * decorators to stamp each `RouteDefinition` with its group.
42
+ */
4
43
  export declare function currentGroup(): RouteGroup | undefined;
5
44
  /** Mark a class as a controller with an optional route prefix */
6
45
  export declare function Controller(prefix?: string): ClassDecorator;
@@ -12,6 +51,13 @@ export declare const Put: (path?: string) => MethodDecorator;
12
51
  export declare const Patch: (path?: string) => MethodDecorator;
13
52
  export declare const Delete: (path?: string) => MethodDecorator;
14
53
  export declare const Options: (path?: string) => MethodDecorator;
54
+ /**
55
+ * Remove every balanced `{...}` block from a path. Used to peel off
56
+ * `where*()` regex constraint segments before scanning the path for `:param`
57
+ * names.
58
+ */
59
+ /** @internal — exported so sibling modules (binding-middleware) can reuse. */
60
+ export declare function stripRegexSegments(path: string): string;
15
61
  /** Matches one or more digits — `[0-9]+`. */
16
62
  export declare const ROUTE_PATTERN_NUMBER = "[0-9]+";
17
63
  /** Matches one or more ASCII letters — `[A-Za-z]+`. */
@@ -30,9 +76,12 @@ export declare const ROUTE_PATTERN_ULID = "[0-7][0-9A-HJKMNP-TV-Z]{25}";
30
76
  * router.get('/users/:id', handler).name('users.show').whereNumber('id')
31
77
  * route('users.show', { id: 1 }) // → '/users/1'
32
78
  */
33
- export declare class RouteBuilder {
79
+ export declare class RouteBuilder<P extends string = string, // path literal — preserved for .query() / future .body() chains
80
+ Q = Record<string, string>> {
34
81
  private readonly definition;
35
82
  private readonly _router;
83
+ readonly _path: P;
84
+ readonly _query: Q;
36
85
  constructor(definition: RouteDefinition, _router: Router);
37
86
  /** Assign a name to this route for use with `route()` and `Url.signedRoute()`. */
38
87
  name(n: string): this;
@@ -89,6 +138,27 @@ export declare class RouteBuilder {
89
138
  * .missing((_req, err) => Response.json({ error: err.message }, { status: 404 }))
90
139
  */
91
140
  missing(fn: NonNullable<RouteDefinition['missing']>): this;
141
+ /**
142
+ * Install a Zod validator on `req.query` for this route. The parsed result
143
+ * replaces `req.query` at request time, so `z.coerce.number()` end-to-end
144
+ * works.
145
+ *
146
+ * **Note on typing:** the handler was already passed (and typed) when this
147
+ * route was registered. Chaining `.query(schema)` AFTER cannot re-type a
148
+ * closure that's already been bound. The returned `RouteBuilder<P, z.infer<S>>`
149
+ * carries the inferred query for downstream chain methods, but the
150
+ * already-registered handler still sees the original typing of its closure.
151
+ *
152
+ * For type-safe query at the handler closure, use the opts-object form:
153
+ *
154
+ * @example
155
+ * // Type-safe (handler closure sees `req.query.page: number`)
156
+ * Route.get('/users', { query: z.object({ page: z.coerce.number() }) }, (req) => req.query.page)
157
+ *
158
+ * // Runtime-only (validation runs, but `req.query.page` is still typed string)
159
+ * Route.get('/users', (req) => req.query.page).query(z.object({ page: z.coerce.number() }))
160
+ */
161
+ query<S extends ZodType>(schema: S): RouteBuilder<P, z.infer<S>>;
92
162
  }
93
163
  /**
94
164
  * Options accepted by `router.group(opts, fn)`. Each route registered inside
@@ -105,42 +175,9 @@ export interface RouteGroupOptions {
105
175
  /** Middleware prepended to every route's chain (before per-route middleware). */
106
176
  middleware?: MiddlewareHandler[];
107
177
  }
108
- /**
109
- * Duck-typed contract for any object that resolves a string route parameter
110
- * into a value (typically a Model instance, but the router doesn't depend on
111
- * `@rudderjs/orm` — anything with a static `findForRoute` method works).
112
- *
113
- * Returning `null` signals "not found" — the router maps that to a thrown
114
- * `RouteModelNotFoundError`, which the framework's HTTP layer renders as a 404.
115
- */
116
- export interface RouteResolver {
117
- /** Owning class name — used for error messages only. */
118
- name: string;
119
- /** Resolve the raw param value. Return `null` for not-found. */
120
- findForRoute(value: string): Promise<unknown | null> | unknown | null;
121
- }
122
- export interface RouteBindingOptions {
123
- /**
124
- * When `true`, an absent or unresolvable param value silently sets
125
- * `req.bound[name] = null` instead of throwing. Useful for shared routes
126
- * that may or may not have a logged-in subject.
127
- */
128
- optional?: boolean;
129
- }
130
- /**
131
- * Thrown by route binding middleware when a required `{param}` cannot be
132
- * resolved into a model instance. `@rudderjs/core` picks up the duck-typed
133
- * `httpStatus` and renders this as an HTTP 404; apps can catch it explicitly
134
- * to render a custom not-found page.
135
- */
136
- export declare class RouteModelNotFoundError extends Error {
137
- readonly model: string;
138
- readonly param: string;
139
- readonly value: string;
140
- /** Duck-typed signal to `@rudderjs/core`'s exception handler. */
141
- readonly httpStatus = 404;
142
- constructor(model: string, param: string, value: string);
143
- }
178
+ import { type RouteResolver, type RouteBindingOptions } from './binding-middleware.js';
179
+ export { RouteModelNotFoundError } from './binding-middleware.js';
180
+ export type { RouteResolver, RouteBindingOptions } from './binding-middleware.js';
144
181
  export declare class Router {
145
182
  private routes;
146
183
  private globalMiddleware;
@@ -242,12 +279,35 @@ export declare class Router {
242
279
  private _buildBindingMiddleware;
243
280
  /** Manually register a route. Returns `this` for bulk registration. */
244
281
  add(method: HttpMethod, path: string, handler: RouteHandler, middleware?: MiddlewareHandler[]): this;
245
- get(path: string, handler: RouteHandler, middleware?: MiddlewareHandler[]): RouteBuilder;
246
- post(path: string, handler: RouteHandler, middleware?: MiddlewareHandler[]): RouteBuilder;
247
- put(path: string, handler: RouteHandler, middleware?: MiddlewareHandler[]): RouteBuilder;
248
- patch(path: string, handler: RouteHandler, middleware?: MiddlewareHandler[]): RouteBuilder;
249
- delete(path: string, handler: RouteHandler, middleware?: MiddlewareHandler[]): RouteBuilder;
250
- all(path: string, handler: RouteHandler, middleware?: MiddlewareHandler[]): RouteBuilder;
282
+ get<P extends string>(path: P, handler: TypedHandler<P>, middleware?: MiddlewareHandler[]): RouteBuilder<P>;
283
+ get<P extends string, S extends ZodType>(path: P, opts: RouteOptions<S> & {
284
+ query: S;
285
+ }, handler: TypedHandler<P, z.infer<S>>): RouteBuilder<P, z.infer<S>>;
286
+ post<P extends string>(path: P, handler: TypedHandler<P>, middleware?: MiddlewareHandler[]): RouteBuilder<P>;
287
+ post<P extends string, S extends ZodType>(path: P, opts: RouteOptions<S> & {
288
+ query: S;
289
+ }, handler: TypedHandler<P, z.infer<S>>): RouteBuilder<P, z.infer<S>>;
290
+ put<P extends string>(path: P, handler: TypedHandler<P>, middleware?: MiddlewareHandler[]): RouteBuilder<P>;
291
+ put<P extends string, S extends ZodType>(path: P, opts: RouteOptions<S> & {
292
+ query: S;
293
+ }, handler: TypedHandler<P, z.infer<S>>): RouteBuilder<P, z.infer<S>>;
294
+ patch<P extends string>(path: P, handler: TypedHandler<P>, middleware?: MiddlewareHandler[]): RouteBuilder<P>;
295
+ patch<P extends string, S extends ZodType>(path: P, opts: RouteOptions<S> & {
296
+ query: S;
297
+ }, handler: TypedHandler<P, z.infer<S>>): RouteBuilder<P, z.infer<S>>;
298
+ delete<P extends string>(path: P, handler: TypedHandler<P>, middleware?: MiddlewareHandler[]): RouteBuilder<P>;
299
+ delete<P extends string, S extends ZodType>(path: P, opts: RouteOptions<S> & {
300
+ query: S;
301
+ }, handler: TypedHandler<P, z.infer<S>>): RouteBuilder<P, z.infer<S>>;
302
+ all<P extends string>(path: P, handler: TypedHandler<P>, middleware?: MiddlewareHandler[]): RouteBuilder<P>;
303
+ all<P extends string, S extends ZodType>(path: P, opts: RouteOptions<S> & {
304
+ query: S;
305
+ }, handler: TypedHandler<P, z.infer<S>>): RouteBuilder<P, z.infer<S>>;
306
+ /**
307
+ * Internal dispatcher for the two-overload shorthand methods. Decides
308
+ * between bare and opts form by whether the second arg is callable.
309
+ */
310
+ private _verb;
251
311
  /**
252
312
  * Register a catch-all fallback route. Runs when no other route matches.
253
313
  * Register it last — Hono evaluates routes in registration order.
@@ -308,63 +368,9 @@ export declare class Router {
308
368
  /** @internal — shared registration loop for resource/apiResource/singleton. */
309
369
  _registerResource(name: string, Ctrl: new () => object, table: readonly ResourceVerbSpec[], opts: ResourceOptions): ResourceRegistration;
310
370
  }
311
- /** The seven canonical RESTful verbs Laravel's `Route::resource` exposes. */
312
- export type ResourceVerb = 'index' | 'create' | 'store' | 'show' | 'edit' | 'update' | 'destroy';
313
- interface ResourceVerbSpec {
314
- verb: ResourceVerb;
315
- method: HttpMethod;
316
- path: (name: string, param: string) => string;
317
- nameSuffix: string;
318
- }
319
- /**
320
- * Options accepted by `router.resource`/`apiResource`/`singleton`.
321
- *
322
- * - `only`/`except` — restrict the verbs registered.
323
- * - `parameters` — override the `:param` segment name for a given resource
324
- * (e.g. `{ posts: 'article' }` → `/posts/:article`).
325
- * - `names` — override the generated route names per verb.
326
- * - `middleware` — applied to every route registered by the resource.
327
- */
328
- export interface ResourceOptions {
329
- only?: readonly ResourceVerb[];
330
- except?: readonly ResourceVerb[];
331
- parameters?: Record<string, string>;
332
- names?: Partial<Record<ResourceVerb, string>>;
333
- middleware?: MiddlewareHandler[];
334
- }
335
- /**
336
- * Returned by `router.resource()`/`apiResource()`. The `builders` array holds
337
- * one `RouteBuilder` per registered route in declaration order — apply
338
- * `where*()`, additional middleware, or rename individual routes by indexing
339
- * directly. The `update` PATCH alias is included as a separate builder
340
- * immediately after its PUT counterpart.
341
- */
342
- export declare class ResourceRegistration {
343
- readonly builders: RouteBuilder[];
344
- constructor(builders: RouteBuilder[]);
345
- }
346
- /**
347
- * Returned by `router.singleton()`. Adds two opt-in helpers on top of
348
- * `ResourceRegistration` for resources that also expose a creation flow
349
- * (`.creatable()`) or deletion flow (`.destroyable()`).
350
- */
351
- export declare class SingletonRegistration extends ResourceRegistration {
352
- private readonly _router;
353
- private readonly _name;
354
- private readonly _Ctrl;
355
- private readonly _opts;
356
- constructor(builders: RouteBuilder[], _router: Router, _name: string, _Ctrl: new () => object, _opts: ResourceOptions);
357
- /**
358
- * Add `GET /<name>/create` and `POST /<name>` — the create/store half of a
359
- * full resource. Skipped for any verb the controller doesn't implement.
360
- */
361
- creatable(): this;
362
- /**
363
- * Add `DELETE /<name>` — the destroy half of a full resource. Skipped if
364
- * the controller doesn't implement `destroy()`.
365
- */
366
- destroyable(): this;
367
- }
371
+ import { ResourceRegistration, SingletonRegistration, type ResourceOptions, type ResourceVerbSpec } from './resource.js';
372
+ export type { ResourceVerb, ResourceOptions } from './resource.js';
373
+ export { ResourceRegistration, SingletonRegistration } from './resource.js';
368
374
  export declare const router: Router;
369
375
  /** Alias for router — Laravel-style capitalised name */
370
376
  export declare const Route: Router;
@@ -380,49 +386,5 @@ export declare const Route: Router;
380
386
  * route('search', { q: 'hello', page: 2 }) // '/search?q=hello&page=2'
381
387
  */
382
388
  export declare function route(name: string, params?: Record<string, string | number>): string;
383
- export declare class Url {
384
- /**
385
- * Override the HMAC signing key used for signed URLs.
386
- * Falls back to `process.env.APP_KEY`.
387
- */
388
- static setKey(key: string): void;
389
- /** The full URL of the current request. */
390
- static current(req: AppRequest): string;
391
- /** The previous URL from the `Referer` header, or `fallback`. */
392
- static previous(req: AppRequest, fallback?: string): string;
393
- /**
394
- * Generate a signed URL for a named route.
395
- *
396
- * @example
397
- * Url.signedRoute('invoice.download', { id: 42 })
398
- * // → '/invoice/42?signature=abc123'
399
- */
400
- static signedRoute(name: string, params?: Record<string, string | number>, expiresAt?: Date): string;
401
- /**
402
- * Generate a signed URL that expires after `seconds` seconds.
403
- *
404
- * @example
405
- * Url.temporarySignedRoute('invoice.download', 3600, { id: 42 })
406
- * // → '/invoice/42?expires=1234567890&signature=abc123'
407
- */
408
- static temporarySignedRoute(name: string, seconds: number, params?: Record<string, string | number>): string;
409
- /**
410
- * Sign an arbitrary path string.
411
- * Appends `?signature=...` (and `?expires=...` if `expiresAt` given).
412
- */
413
- static sign(path: string, expiresAt?: Date): string;
414
- /**
415
- * Return `true` if the request has a valid (and non-expired) signature.
416
- */
417
- static isValidSignature(req: AppRequest): boolean;
418
- }
419
- /**
420
- * Middleware that verifies a signed URL signature.
421
- * Responds with 403 if the signature is missing, invalid, or expired.
422
- *
423
- * @example
424
- * router.get('/invoice/:id/download', handler, [ValidateSignature()])
425
- */
426
- export declare function ValidateSignature(): MiddlewareHandler;
427
- export {};
389
+ export { Url, ValidateSignature } from './url-signing.js';
428
390
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAUzB,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,UAAU,EACX,MAAM,qBAAqB,CAAA;AAkB5B,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAc3F;AAED,wBAAgB,YAAY,IAAI,UAAU,GAAG,SAAS,CAErD;AAoBD,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,MAAM,SAAK,GAAG,cAAc,CAItD;AAED,8DAA8D;AAC9D,wBAAgB,UAAU,CAAC,UAAU,EAAE,iBAAiB,EAAE,GAAG,cAAc,GAAG,eAAe,CAmB5F;AAiBD,eAAO,MAAM,GAAG,qBAbO,eAa4B,CAAA;AACnD,eAAO,MAAM,IAAI,qBAdM,eAc6B,CAAA;AACpD,eAAO,MAAM,GAAG,qBAfO,eAe4B,CAAA;AACnD,eAAO,MAAM,KAAK,qBAhBK,eAgB8B,CAAA;AACrD,eAAO,MAAM,MAAM,qBAjBI,eAiB+B,CAAA;AACtD,eAAO,MAAM,OAAO,qBAlBG,eAkBgC,CAAA;AAwDvD,6CAA6C;AAC7C,eAAO,MAAM,oBAAoB,WAAa,CAAA;AAC9C,uDAAuD;AACvD,eAAO,MAAM,mBAAmB,cAAiB,CAAA;AACjD,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,iBAAiB,CAAA;AACpD,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,gFAAoF,CAAA;AACnH,kDAAkD;AAClD,eAAO,MAAM,kBAAkB,gCAAoC,CAAA;AAIn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