balda 0.0.54 → 0.0.55

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/lib/index.d.cts CHANGED
@@ -54,6 +54,10 @@ interface ValidationOptions {
54
54
  * The schema to validate the query parameters against (Zod, TypeBox, or plain JSON schema)
55
55
  */
56
56
  query?: RequestSchema;
57
+ /**
58
+ * The schema to validate the request headers against (Zod, TypeBox, or plain JSON schema)
59
+ */
60
+ headers?: RequestSchema;
57
61
  /**
58
62
  * The schema to validate both body and query against (Zod, TypeBox, or plain JSON schema)
59
63
  */
@@ -93,6 +97,12 @@ type InferBodyType<T> = T extends RequestSchema ? ValidatedData<T> : unknown;
93
97
  * Infers the typed query from a schema. Returns `Record<string, string>` if no schema is provided.
94
98
  */
95
99
  type InferQueryType<T> = T extends RequestSchema ? ValidatedData<T> : Record<string, string>;
100
+ /**
101
+ * Infers the typed headers from a schema.
102
+ * Returns `Record<string, string | string[]>` if no schema is provided
103
+ * (supporting multi-value headers).
104
+ */
105
+ type InferHeadersType<T> = T extends RequestSchema ? ValidatedData<T> : Record<string, string | string[]>;
96
106
  /**
97
107
  * Extracts the body type for a specific HTTP status code from a response map.
98
108
  * When the status code has a schema defined, enforces type matching with widened
@@ -180,8 +190,9 @@ type FilePluginOptions = {
180
190
  * @template Params - The path parameters type (automatically extracted from route)
181
191
  * @template TBody - The typed body (inferred from body schema when provided)
182
192
  * @template TQuery - The typed query (inferred from query schema when provided)
193
+ * @template THeaders - The typed headers (inferred from headers schema when provided)
183
194
  */
184
- declare class Request<Params extends Record<string, string> = any, TBody = unknown, TQuery extends Record<string, any> = Record<string, string>> {
195
+ declare class Request<Params extends Record<string, string> = Record<string, string>, TBody = unknown, TQuery extends Record<string, any> = Record<string, string>, THeaders extends Record<string, any> = Record<string, string | string[]>> {
185
196
  #private;
186
197
  /**
187
198
  * Creates a new request object from a Web API Request object.
@@ -228,10 +239,17 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
228
239
  */
229
240
  method: string;
230
241
  /**
231
- * The headers of the request lazily constructed from raw Node.js headers.
242
+ * Raw Headers API object for low-level access.
243
+ * Use this for case-insensitive lookups, iteration, etc.
232
244
  */
233
- get headers(): globalThis.Headers;
234
- set headers(value: globalThis.Headers);
245
+ get rawHeaders(): globalThis.Headers;
246
+ /**
247
+ * The typed headers of the request.
248
+ * After validation with a headers schema, this contains the validated/typed header values.
249
+ * For raw Headers API access, use `rawHeaders`.
250
+ */
251
+ get headers(): THeaders;
252
+ set headers(value: THeaders);
235
253
  /**
236
254
  * The signal for aborting the request
237
255
  */
@@ -449,6 +467,12 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
449
467
  * @param throwErrorOnValidationFail - If true, throws ValidationError on validation failure. If false, returns the original data.
450
468
  */
451
469
  validateAll<T extends RequestSchema>(inputSchema: T, throwErrorOnValidationFail?: boolean): ValidatedData<T>;
470
+ /**
471
+ * Validates the headers of the request.
472
+ * @param inputSchema - The schema to validate the headers against (Zod schema, TypeBox, or JSON Schema).
473
+ * @param throwErrorOnValidationFail - If true, throws ValidationError on validation failure. If false, returns the original headers.
474
+ */
475
+ validateHeaders<T extends RequestSchema>(inputSchema: T, throwErrorOnValidationFail?: boolean): ValidatedData<T>;
452
476
  /**
453
477
  * Sets a lazy IP extractor function.
454
478
  * IP will only be extracted when `.ip` is first accessed.
@@ -1033,6 +1057,7 @@ type OpenIdConnectOptions = {
1033
1057
  /**
1034
1058
  * Decorator to mark a class as a controller, routes defined in the controller will be registered at import time when calling the `listen` method.
1035
1059
  * You can customize the path pattern for controller imports in the server options `controllerPatterns`
1060
+ * @deprecated This decorator is deprecated and class based controllers won't be supported in the future. Please use the `router` directly to define your routes in a functional way for better type-safety.
1036
1061
  * @param path - The path pattern for the controller.
1037
1062
  * @param swaggerOptions - The swagger options for the controller that will be applied to all routes defined in the controller. Controller options will override route options.
1038
1063
  * @swagger If swagger is enabled, the default service name for all routes defined in the controller will be the controller name.
@@ -1684,20 +1709,20 @@ type InferMiddlewareExtensions<T extends readonly any[]> = T extends readonly [i
1684
1709
  * ```
1685
1710
  */
1686
1711
  interface GroupRouter<TGroupExt extends Record<string, any> = Record<string, never>> {
1687
- get<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1688
- get<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1689
- post<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1690
- post<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1691
- patch<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1692
- patch<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1693
- put<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1694
- put<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1695
- delete<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1696
- delete<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1697
- options<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1698
- options<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1699
- head<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1700
- head<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1712
+ get<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1713
+ get<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1714
+ post<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1715
+ post<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1716
+ patch<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1717
+ patch<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1718
+ put<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1719
+ put<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1720
+ delete<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1721
+ delete<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1722
+ options<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1723
+ options<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1724
+ head<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1725
+ head<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1701
1726
  group<const TMiddlewares extends readonly (ServerRouteMiddleware | TypedMiddleware<any>)[] = readonly (ServerRouteMiddleware | TypedMiddleware<any>)[]>(path: string, middleware: TMiddlewares, cb: (router: GroupRouter<TGroupExt & InferMiddlewareExtensions<TMiddlewares>>) => void): void;
1702
1727
  group(path: string, cb: (router: GroupRouter<TGroupExt>) => void): void;
1703
1728
  }
@@ -1729,6 +1754,7 @@ declare class Router {
1729
1754
  addOrUpdate(method: HttpMethod, path: string, middleware: (ServerRouteMiddleware | TypedMiddleware<any>)[], handler: ServerRouteHandler, validationSchemas?: {
1730
1755
  body?: RequestSchema;
1731
1756
  query?: RequestSchema;
1757
+ headers?: RequestSchema;
1732
1758
  all?: RequestSchema;
1733
1759
  }, swaggerOptions?: SwaggerRouteOptions, responses?: Record<number, RequestSchema>, allowUpdate?: boolean): void;
1734
1760
  /**
@@ -1752,37 +1778,37 @@ declare class Router {
1752
1778
  * Register a GET route under this router's base path with type-safe path parameters.
1753
1779
  */
1754
1780
  get<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1755
- get<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1781
+ get<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1756
1782
  /**
1757
1783
  * Register a POST route under this router's base path with type-safe path parameters.
1758
1784
  */
1759
1785
  post<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1760
- post<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1786
+ post<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1761
1787
  /**
1762
1788
  * Register a PATCH route under this router's base path with type-safe path parameters.
1763
1789
  */
1764
1790
  patch<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1765
- patch<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1791
+ patch<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1766
1792
  /**
1767
1793
  * Register a PUT route under this router's base path with type-safe path parameters.
1768
1794
  */
1769
1795
  put<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1770
- put<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1796
+ put<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1771
1797
  /**
1772
1798
  * Register a DELETE route under this router's base path with type-safe path parameters.
1773
1799
  */
1774
1800
  delete<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1775
- delete<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1801
+ delete<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1776
1802
  /**
1777
1803
  * Register an OPTIONS route under this router's base path with type-safe path parameters.
1778
1804
  */
1779
1805
  options<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1780
- options<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1806
+ options<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1781
1807
  /**
1782
1808
  * Register an HEAD route under this router's base path with type-safe path parameters.
1783
1809
  */
1784
1810
  head<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1785
- head<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1811
+ head<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1786
1812
  /**
1787
1813
  * Create a grouped router that shares a base path and middlewares.
1788
1814
  * The callback receives a typed child router where routes are defined; routes
@@ -1829,12 +1855,13 @@ interface Route {
1829
1855
  */
1830
1856
  responseSchemas?: RouteResponseSchemas;
1831
1857
  /**
1832
- * Validation schemas for request body, query parameters, or both.
1858
+ * Validation schemas for request body, query parameters, headers, or all.
1833
1859
  * When provided, the handler will receive validated data as additional parameters.
1834
1860
  */
1835
1861
  validationSchemas?: {
1836
1862
  body?: RequestSchema;
1837
1863
  query?: RequestSchema;
1864
+ headers?: RequestSchema;
1838
1865
  all?: RequestSchema;
1839
1866
  };
1840
1867
  }
@@ -2791,10 +2818,11 @@ interface ServerInterface {
2791
2818
  */
2792
2819
  exit: (code?: number) => void;
2793
2820
  }
2794
- type StandardMethodOptions<TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | unknown = unknown, TQuery extends RequestSchema | unknown = unknown, TPath extends string = string, TAll extends RequestSchema | unknown = unknown, TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]> = {
2821
+ type StandardMethodOptions<TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | unknown = unknown, TQuery extends RequestSchema | unknown = unknown, THeaders extends RequestSchema | unknown = unknown, TPath extends string = string, TAll extends RequestSchema | unknown = unknown, TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]> = {
2795
2822
  middlewares?: TMiddlewares | TypedMiddleware<any>;
2796
2823
  body?: TBody;
2797
2824
  query?: TQuery;
2825
+ headers?: THeaders;
2798
2826
  all?: TAll;
2799
2827
  responses?: TResponses;
2800
2828
  swagger?: SwaggerRouteOptions;
@@ -2805,7 +2833,7 @@ type StandardMethodOptions<TResponses extends Record<number, RequestSchema> = Re
2805
2833
  };
2806
2834
  type ServerHook = () => SyncOrAsync;
2807
2835
  type SignalEvent = Deno.Signal | NodeJS.Signals;
2808
- type ControllerHandler<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | unknown = unknown, TQuery extends RequestSchema | unknown = unknown, TAll extends RequestSchema | unknown = unknown, TMiddlewareExt extends Record<string, any> = Record<string, never>> = (req: Request<ExtractParams<TPath>, TBody extends RequestSchema ? InferBodyType<TBody> : InferBodyType<TAll>, InferQueryType<TQuery> extends Record<string, any> ? InferQueryType<TQuery> : Record<string, unknown>> & TMiddlewareExt, res: Response$1<InferResponseMap<TResponses>>) => ServerHandlerReturnType<InferResponseMap<TResponses>>;
2836
+ type ControllerHandler<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | unknown = unknown, TQuery extends RequestSchema | unknown = unknown, THeaders extends RequestSchema | unknown = unknown, TAll extends RequestSchema | unknown = unknown, TMiddlewareExt extends Record<string, any> = Record<string, never>> = (req: Request<ExtractParams<TPath>, TBody extends RequestSchema ? InferBodyType<TBody> : InferBodyType<TAll>, InferQueryType<TQuery> extends Record<string, any> ? InferQueryType<TQuery> : Record<string, unknown>, THeaders extends RequestSchema ? InferHeadersType<THeaders> : Record<string, string | string[]>> & TMiddlewareExt, res: Response$1<InferResponseMap<TResponses>>) => ServerHandlerReturnType<InferResponseMap<TResponses>>;
2809
2837
 
2810
2838
  type RunTimeType = "bun" | "node" | "deno";
2811
2839
 
package/lib/index.d.ts CHANGED
@@ -54,6 +54,10 @@ interface ValidationOptions {
54
54
  * The schema to validate the query parameters against (Zod, TypeBox, or plain JSON schema)
55
55
  */
56
56
  query?: RequestSchema;
57
+ /**
58
+ * The schema to validate the request headers against (Zod, TypeBox, or plain JSON schema)
59
+ */
60
+ headers?: RequestSchema;
57
61
  /**
58
62
  * The schema to validate both body and query against (Zod, TypeBox, or plain JSON schema)
59
63
  */
@@ -93,6 +97,12 @@ type InferBodyType<T> = T extends RequestSchema ? ValidatedData<T> : unknown;
93
97
  * Infers the typed query from a schema. Returns `Record<string, string>` if no schema is provided.
94
98
  */
95
99
  type InferQueryType<T> = T extends RequestSchema ? ValidatedData<T> : Record<string, string>;
100
+ /**
101
+ * Infers the typed headers from a schema.
102
+ * Returns `Record<string, string | string[]>` if no schema is provided
103
+ * (supporting multi-value headers).
104
+ */
105
+ type InferHeadersType<T> = T extends RequestSchema ? ValidatedData<T> : Record<string, string | string[]>;
96
106
  /**
97
107
  * Extracts the body type for a specific HTTP status code from a response map.
98
108
  * When the status code has a schema defined, enforces type matching with widened
@@ -180,8 +190,9 @@ type FilePluginOptions = {
180
190
  * @template Params - The path parameters type (automatically extracted from route)
181
191
  * @template TBody - The typed body (inferred from body schema when provided)
182
192
  * @template TQuery - The typed query (inferred from query schema when provided)
193
+ * @template THeaders - The typed headers (inferred from headers schema when provided)
183
194
  */
184
- declare class Request<Params extends Record<string, string> = any, TBody = unknown, TQuery extends Record<string, any> = Record<string, string>> {
195
+ declare class Request<Params extends Record<string, string> = Record<string, string>, TBody = unknown, TQuery extends Record<string, any> = Record<string, string>, THeaders extends Record<string, any> = Record<string, string | string[]>> {
185
196
  #private;
186
197
  /**
187
198
  * Creates a new request object from a Web API Request object.
@@ -228,10 +239,17 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
228
239
  */
229
240
  method: string;
230
241
  /**
231
- * The headers of the request lazily constructed from raw Node.js headers.
242
+ * Raw Headers API object for low-level access.
243
+ * Use this for case-insensitive lookups, iteration, etc.
232
244
  */
233
- get headers(): globalThis.Headers;
234
- set headers(value: globalThis.Headers);
245
+ get rawHeaders(): globalThis.Headers;
246
+ /**
247
+ * The typed headers of the request.
248
+ * After validation with a headers schema, this contains the validated/typed header values.
249
+ * For raw Headers API access, use `rawHeaders`.
250
+ */
251
+ get headers(): THeaders;
252
+ set headers(value: THeaders);
235
253
  /**
236
254
  * The signal for aborting the request
237
255
  */
@@ -449,6 +467,12 @@ declare class Request<Params extends Record<string, string> = any, TBody = unkno
449
467
  * @param throwErrorOnValidationFail - If true, throws ValidationError on validation failure. If false, returns the original data.
450
468
  */
451
469
  validateAll<T extends RequestSchema>(inputSchema: T, throwErrorOnValidationFail?: boolean): ValidatedData<T>;
470
+ /**
471
+ * Validates the headers of the request.
472
+ * @param inputSchema - The schema to validate the headers against (Zod schema, TypeBox, or JSON Schema).
473
+ * @param throwErrorOnValidationFail - If true, throws ValidationError on validation failure. If false, returns the original headers.
474
+ */
475
+ validateHeaders<T extends RequestSchema>(inputSchema: T, throwErrorOnValidationFail?: boolean): ValidatedData<T>;
452
476
  /**
453
477
  * Sets a lazy IP extractor function.
454
478
  * IP will only be extracted when `.ip` is first accessed.
@@ -1033,6 +1057,7 @@ type OpenIdConnectOptions = {
1033
1057
  /**
1034
1058
  * Decorator to mark a class as a controller, routes defined in the controller will be registered at import time when calling the `listen` method.
1035
1059
  * You can customize the path pattern for controller imports in the server options `controllerPatterns`
1060
+ * @deprecated This decorator is deprecated and class based controllers won't be supported in the future. Please use the `router` directly to define your routes in a functional way for better type-safety.
1036
1061
  * @param path - The path pattern for the controller.
1037
1062
  * @param swaggerOptions - The swagger options for the controller that will be applied to all routes defined in the controller. Controller options will override route options.
1038
1063
  * @swagger If swagger is enabled, the default service name for all routes defined in the controller will be the controller name.
@@ -1684,20 +1709,20 @@ type InferMiddlewareExtensions<T extends readonly any[]> = T extends readonly [i
1684
1709
  * ```
1685
1710
  */
1686
1711
  interface GroupRouter<TGroupExt extends Record<string, any> = Record<string, never>> {
1687
- get<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1688
- get<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1689
- post<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1690
- post<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1691
- patch<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1692
- patch<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1693
- put<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1694
- put<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1695
- delete<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1696
- delete<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1697
- options<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1698
- options<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1699
- head<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, TGroupExt>): void;
1700
- head<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1712
+ get<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1713
+ get<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1714
+ post<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1715
+ post<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1716
+ patch<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1717
+ patch<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1718
+ put<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1719
+ put<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1720
+ delete<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1721
+ delete<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1722
+ options<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1723
+ options<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1724
+ head<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath, Record<number, RequestSchema>, unknown, unknown, unknown, unknown, TGroupExt>): void;
1725
+ head<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, TGroupExt & InferMiddlewareExtensions<TMiddlewares>>): void;
1701
1726
  group<const TMiddlewares extends readonly (ServerRouteMiddleware | TypedMiddleware<any>)[] = readonly (ServerRouteMiddleware | TypedMiddleware<any>)[]>(path: string, middleware: TMiddlewares, cb: (router: GroupRouter<TGroupExt & InferMiddlewareExtensions<TMiddlewares>>) => void): void;
1702
1727
  group(path: string, cb: (router: GroupRouter<TGroupExt>) => void): void;
1703
1728
  }
@@ -1729,6 +1754,7 @@ declare class Router {
1729
1754
  addOrUpdate(method: HttpMethod, path: string, middleware: (ServerRouteMiddleware | TypedMiddleware<any>)[], handler: ServerRouteHandler, validationSchemas?: {
1730
1755
  body?: RequestSchema;
1731
1756
  query?: RequestSchema;
1757
+ headers?: RequestSchema;
1732
1758
  all?: RequestSchema;
1733
1759
  }, swaggerOptions?: SwaggerRouteOptions, responses?: Record<number, RequestSchema>, allowUpdate?: boolean): void;
1734
1760
  /**
@@ -1752,37 +1778,37 @@ declare class Router {
1752
1778
  * Register a GET route under this router's base path with type-safe path parameters.
1753
1779
  */
1754
1780
  get<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1755
- get<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1781
+ get<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1756
1782
  /**
1757
1783
  * Register a POST route under this router's base path with type-safe path parameters.
1758
1784
  */
1759
1785
  post<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1760
- post<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1786
+ post<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1761
1787
  /**
1762
1788
  * Register a PATCH route under this router's base path with type-safe path parameters.
1763
1789
  */
1764
1790
  patch<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1765
- patch<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1791
+ patch<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1766
1792
  /**
1767
1793
  * Register a PUT route under this router's base path with type-safe path parameters.
1768
1794
  */
1769
1795
  put<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1770
- put<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1796
+ put<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1771
1797
  /**
1772
1798
  * Register a DELETE route under this router's base path with type-safe path parameters.
1773
1799
  */
1774
1800
  delete<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1775
- delete<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1801
+ delete<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1776
1802
  /**
1777
1803
  * Register an OPTIONS route under this router's base path with type-safe path parameters.
1778
1804
  */
1779
1805
  options<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1780
- options<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1806
+ options<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1781
1807
  /**
1782
1808
  * Register an HEAD route under this router's base path with type-safe path parameters.
1783
1809
  */
1784
1810
  head<TPath extends string = string>(path: TPath, handler: ControllerHandler<TPath>): void;
1785
- head<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1811
+ head<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | undefined = undefined, TQuery extends RequestSchema | undefined = undefined, THeaders extends RequestSchema | undefined = undefined, TAll extends RequestSchema | undefined = undefined, const TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]>(path: TPath, options: StandardMethodOptions<TResponses, TBody, TQuery, THeaders, TPath, TAll, TMiddlewares>, handler: ControllerHandler<TPath, TResponses, TBody, TQuery, THeaders, TAll, InferMiddlewareExtensions<TMiddlewares>>): void;
1786
1812
  /**
1787
1813
  * Create a grouped router that shares a base path and middlewares.
1788
1814
  * The callback receives a typed child router where routes are defined; routes
@@ -1829,12 +1855,13 @@ interface Route {
1829
1855
  */
1830
1856
  responseSchemas?: RouteResponseSchemas;
1831
1857
  /**
1832
- * Validation schemas for request body, query parameters, or both.
1858
+ * Validation schemas for request body, query parameters, headers, or all.
1833
1859
  * When provided, the handler will receive validated data as additional parameters.
1834
1860
  */
1835
1861
  validationSchemas?: {
1836
1862
  body?: RequestSchema;
1837
1863
  query?: RequestSchema;
1864
+ headers?: RequestSchema;
1838
1865
  all?: RequestSchema;
1839
1866
  };
1840
1867
  }
@@ -2791,10 +2818,11 @@ interface ServerInterface {
2791
2818
  */
2792
2819
  exit: (code?: number) => void;
2793
2820
  }
2794
- type StandardMethodOptions<TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | unknown = unknown, TQuery extends RequestSchema | unknown = unknown, TPath extends string = string, TAll extends RequestSchema | unknown = unknown, TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]> = {
2821
+ type StandardMethodOptions<TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | unknown = unknown, TQuery extends RequestSchema | unknown = unknown, THeaders extends RequestSchema | unknown = unknown, TPath extends string = string, TAll extends RequestSchema | unknown = unknown, TMiddlewares extends readonly TypedMiddleware<any>[] = readonly TypedMiddleware<any>[]> = {
2795
2822
  middlewares?: TMiddlewares | TypedMiddleware<any>;
2796
2823
  body?: TBody;
2797
2824
  query?: TQuery;
2825
+ headers?: THeaders;
2798
2826
  all?: TAll;
2799
2827
  responses?: TResponses;
2800
2828
  swagger?: SwaggerRouteOptions;
@@ -2805,7 +2833,7 @@ type StandardMethodOptions<TResponses extends Record<number, RequestSchema> = Re
2805
2833
  };
2806
2834
  type ServerHook = () => SyncOrAsync;
2807
2835
  type SignalEvent = Deno.Signal | NodeJS.Signals;
2808
- type ControllerHandler<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | unknown = unknown, TQuery extends RequestSchema | unknown = unknown, TAll extends RequestSchema | unknown = unknown, TMiddlewareExt extends Record<string, any> = Record<string, never>> = (req: Request<ExtractParams<TPath>, TBody extends RequestSchema ? InferBodyType<TBody> : InferBodyType<TAll>, InferQueryType<TQuery> extends Record<string, any> ? InferQueryType<TQuery> : Record<string, unknown>> & TMiddlewareExt, res: Response$1<InferResponseMap<TResponses>>) => ServerHandlerReturnType<InferResponseMap<TResponses>>;
2836
+ type ControllerHandler<TPath extends string = string, TResponses extends Record<number, RequestSchema> = Record<number, RequestSchema>, TBody extends RequestSchema | unknown = unknown, TQuery extends RequestSchema | unknown = unknown, THeaders extends RequestSchema | unknown = unknown, TAll extends RequestSchema | unknown = unknown, TMiddlewareExt extends Record<string, any> = Record<string, never>> = (req: Request<ExtractParams<TPath>, TBody extends RequestSchema ? InferBodyType<TBody> : InferBodyType<TAll>, InferQueryType<TQuery> extends Record<string, any> ? InferQueryType<TQuery> : Record<string, unknown>, THeaders extends RequestSchema ? InferHeadersType<THeaders> : Record<string, string | string[]>> & TMiddlewareExt, res: Response$1<InferResponseMap<TResponses>>) => ServerHandlerReturnType<InferResponseMap<TResponses>>;
2809
2837
 
2810
2838
  type RunTimeType = "bun" | "node" | "deno";
2811
2839