---
title: Routes API
description: Generated public TypeScript reference for @relkit/routes.
search:
  exclude: true
sidebar:
  icon: braces
---

{/* Generated by apps/docs/scripts/generate.ts. Do not edit. */}

## Common APIs

- [defineRoute](/docs/api/routes#defineroute)
- [defineMiddleware](/docs/api/routes#definemiddleware)

For configuration and examples, read [define](/docs/modules/http/define), [middleware](/docs/modules/http/middleware), [routes](/docs/modules/service/routes).

For a complete workflow, follow [upload product images](/guides/storage/upload-product-images), [connect react](/guides/frontend/connect-react), [register users in a transaction](/guides/database/register-users-in-a-transaction), [email password sign in](/guides/auth/email-password-sign-in), [create and build an api](/guides/cli/create-and-build-an-api).

## Frontend usage

[Call a defined route](/docs/modules/http/define#use-from-the-frontend) shows the client side of this capability.

## Public imports

- `@relkit/routes` — 91 exports

## All exported APIs

Names link to their complete contracts. Re-exports share their original contract; legacy exports keep their separate identity. Examples link to the API's inline sample, a maintained repository usage, or the shared module walkthrough.

| API                                                                                | Kind  | Import from      | Example                                                                                                               |
| ---------------------------------------------------------------------------------- | ----- | ---------------- | --------------------------------------------------------------------------------------------------------------------- |
| [assertRequestMapping](/docs/api/routes#assertrequestmapping)                      | Value | `@relkit/routes` | [API example](/docs/api/routes#assertrequestmapping)                                                                  |
| [assertRequestMappingEffect](/docs/api/routes#assertrequestmappingeffect)          | Value | `@relkit/routes` | [API example](/docs/api/routes#assertrequestmappingeffect)                                                            |
| [assertResponse](/docs/api/routes#assertresponse)                                  | Value | `@relkit/routes` | [API example](/docs/api/routes#assertresponse)                                                                        |
| [assertResponseEffect](/docs/api/routes#assertresponseeffect)                      | Value | `@relkit/routes` | [API example](/docs/api/routes#assertresponseeffect)                                                                  |
| [ContinueMapping](/docs/api/routes#continuemapping-interface)                      | Type  | `@relkit/routes` | [API example](/docs/api/routes#continuemapping-interface)                                                             |
| [defineMiddleware](/docs/api/routes#definemiddleware)                              | Value | `@relkit/routes` | [API example](/docs/api/routes#definemiddleware)                                                                      |
| [defineMiddlewareEffect](/docs/api/routes#definemiddlewareeffect)                  | Value | `@relkit/routes` | [API example](/docs/api/routes#definemiddlewareeffect)                                                                |
| [defineRequestTransform](/docs/api/routes#definerequesttransform)                  | Value | `@relkit/routes` | [API example](/docs/api/routes#definerequesttransform)                                                                |
| [defineRequestTransformEffect](/docs/api/routes#definerequesttransformeffect)      | Value | `@relkit/routes` | [API example](/docs/api/routes#definerequesttransformeffect)                                                          |
| [defineRoute](/docs/api/routes#defineroute)                                        | Value | `@relkit/routes` | [API example](/docs/api/routes#defineroute)                                                                           |
| [defineRouteEffect](/docs/api/routes#definerouteeffect)                            | Value | `@relkit/routes` | [API example](/docs/api/routes#definerouteeffect)                                                                     |
| [defineServiceRoutes](/docs/api/routes#defineserviceroutes)                        | Value | `@relkit/routes` | [API example](/docs/api/routes#defineserviceroutes)                                                                   |
| [defineServiceRoutesEffect](/docs/api/routes#defineservicerouteseffect)            | Value | `@relkit/routes` | [API example](/docs/api/routes#defineservicerouteseffect)                                                             |
| [defineTransform](/docs/api/routes#definetransform)                                | Value | `@relkit/routes` | [API example](/docs/api/routes#definetransform)                                                                       |
| [defineTransformEffect](/docs/api/routes#definetransformeffect)                    | Value | `@relkit/routes` | [API example](/docs/api/routes#definetransformeffect)                                                                 |
| [DefineTransformOptions](/docs/api/routes#definetransformoptions-interface)        | Type  | `@relkit/routes` | [API example](/docs/api/routes#definetransformoptions-interface)                                                      |
| [FunctionRouteDescriptor](/docs/api/routes#functionroutedescriptor-interface)      | Type  | `@relkit/routes` | [API example](/docs/api/routes#functionroutedescriptor-interface)                                                     |
| [FunctionRouteOptions](/docs/api/routes#functionrouteoptions-interface)            | Type  | `@relkit/routes` | [API example](/docs/api/routes#functionrouteoptions-interface)                                                        |
| [http](/docs/api/routes#http)                                                      | Value | `@relkit/routes` | [API example](/docs/api/routes#http)                                                                                  |
| [HttpBodyMapping](/docs/api/routes#httpbodymapping-interface)                      | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpbodymapping-interface)                                                             |
| [HttpConstantMapping](/docs/api/routes#httpconstantmapping-interface)              | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpconstantmapping-interface)                                                         |
| [HttpCookieMapping](/docs/api/routes#httpcookiemapping-interface)                  | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpcookiemapping-interface)                                                           |
| [HttpDefaultMapping](/docs/api/routes#httpdefaultmapping-interface)                | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpdefaultmapping-interface)                                                          |
| [HttpDsl](/docs/api/routes#httpdsl-interface)                                      | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpdsl-interface)                                                                     |
| [httpEffects](/docs/api/routes#httpeffects)                                        | Value | `@relkit/routes` | [API example](/docs/api/routes#httpeffects)                                                                           |
| [HttpHeaderMapping](/docs/api/routes#httpheadermapping-interface)                  | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpheadermapping-interface)                                                           |
| [HttpInputMapping](/docs/api/routes#httpinputmapping-interface)                    | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpinputmapping-interface)                                                            |
| [HttpMapping](/docs/api/routes#httpmapping-interface)                              | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpmapping-interface)                                                                 |
| [HttpMappingNode](/docs/api/routes#httpmappingnode-type-alias)                     | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpmappingnode-type-alias)                                                            |
| [HttpMappingOutput](/docs/api/routes#httpmappingoutput-type-alias)                 | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpmappingoutput-type-alias)                                                          |
| [HttpMappingShape](/docs/api/routes#httpmappingshape-type-alias)                   | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpmappingshape-type-alias)                                                           |
| [HttpMethod](/docs/api/routes#httpmethod-type-alias)                               | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpmethod-type-alias)                                                                 |
| [HttpMultipartAllMapping](/docs/api/routes#httpmultipartallmapping-interface)      | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpmultipartallmapping-interface)                                                     |
| [HttpMultipartMapping](/docs/api/routes#httpmultipartmapping-interface)            | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpmultipartmapping-interface)                                                        |
| [HttpNestedMapping](/docs/api/routes#httpnestedmapping-interface)                  | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpnestedmapping-interface)                                                           |
| [HttpOptionalMapping](/docs/api/routes#httpoptionalmapping-interface)              | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpoptionalmapping-interface)                                                         |
| [HttpPathMapping](/docs/api/routes#httppathmapping-interface)                      | Type  | `@relkit/routes` | [API example](/docs/api/routes#httppathmapping-interface)                                                             |
| [HttpPathSegmentsMapping](/docs/api/routes#httppathsegmentsmapping-interface)      | Type  | `@relkit/routes` | [API example](/docs/api/routes#httppathsegmentsmapping-interface)                                                     |
| [HttpQueryMapping](/docs/api/routes#httpquerymapping-interface)                    | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpquerymapping-interface)                                                            |
| [HttpRateLimitKey](/docs/api/routes#httpratelimitkey-type-alias)                   | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpratelimitkey-type-alias)                                                           |
| [HttpRequestContentType](/docs/api/routes#httprequestcontenttype-type-alias)       | Type  | `@relkit/routes` | [API example](/docs/api/routes#httprequestcontenttype-type-alias)                                                     |
| [HttpRequestMapping](/docs/api/routes#httprequestmapping-type-alias)               | Type  | `@relkit/routes` | [API example](/docs/api/routes#httprequestmapping-type-alias)                                                         |
| [HttpResponseMapping](/docs/api/routes#httpresponsemapping-interface)              | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpresponsemapping-interface)                                                         |
| [HttpSourceOptions](/docs/api/routes#httpsourceoptions-interface)                  | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpsourceoptions-interface)                                                           |
| [HttpTransformDescriptor](/docs/api/routes#httptransformdescriptor-interface)      | Type  | `@relkit/routes` | [API example](/docs/api/routes#httptransformdescriptor-interface)                                                     |
| [HttpTransformMapping](/docs/api/routes#httptransformmapping-interface)            | Type  | `@relkit/routes` | [API example](/docs/api/routes#httptransformmapping-interface)                                                        |
| [HttpTransformRef](/docs/api/routes#httptransformref-interface)                    | Type  | `@relkit/routes` | [API example](/docs/api/routes#httptransformref-interface)                                                            |
| [HttpWholeBodyMapping](/docs/api/routes#httpwholebodymapping-interface)            | Type  | `@relkit/routes` | [API example](/docs/api/routes#httpwholebodymapping-interface)                                                        |
| [isHttpMapping](/docs/api/routes#ishttpmapping)                                    | Value | `@relkit/routes` | [API example](/docs/api/routes#ishttpmapping)                                                                         |
| [isHttpMappingEffect](/docs/api/routes#ishttpmappingeffect)                        | Value | `@relkit/routes` | [API example](/docs/api/routes#ishttpmappingeffect)                                                                   |
| [isHttpRequestMapping](/docs/api/routes#ishttprequestmapping)                      | Value | `@relkit/routes` | [API example](/docs/api/routes#ishttprequestmapping)                                                                  |
| [isHttpRequestMappingEffect](/docs/api/routes#ishttprequestmappingeffect)          | Value | `@relkit/routes` | [API example](/docs/api/routes#ishttprequestmappingeffect)                                                            |
| [isHttpResponseMapping](/docs/api/routes#ishttpresponsemapping)                    | Value | `@relkit/routes` | [API example](/docs/api/routes#ishttpresponsemapping)                                                                 |
| [isHttpResponseMappingEffect](/docs/api/routes#ishttpresponsemappingeffect)        | Value | `@relkit/routes` | [API example](/docs/api/routes#ishttpresponsemappingeffect)                                                           |
| [isMiddlewareDecision](/docs/api/routes#ismiddlewaredecision)                      | Value | `@relkit/routes` | [API example](/docs/api/routes#ismiddlewaredecision)                                                                  |
| [isMiddlewareDecisionEffect](/docs/api/routes#ismiddlewaredecisioneffect)          | Value | `@relkit/routes` | [API example](/docs/api/routes#ismiddlewaredecisioneffect)                                                            |
| [isMiddlewareDescriptor](/docs/api/routes#ismiddlewaredescriptor)                  | Value | `@relkit/routes` | [API example](/docs/api/routes#ismiddlewaredescriptor)                                                                |
| [isMiddlewareDescriptorEffect](/docs/api/routes#ismiddlewaredescriptoreffect)      | Value | `@relkit/routes` | [API example](/docs/api/routes#ismiddlewaredescriptoreffect)                                                          |
| [isMiddlewarePath](/docs/api/routes#ismiddlewarepath)                              | Value | `@relkit/routes` | [API example](/docs/api/routes#ismiddlewarepath)                                                                      |
| [isMiddlewarePathEffect](/docs/api/routes#ismiddlewarepatheffect)                  | Value | `@relkit/routes` | [API example](/docs/api/routes#ismiddlewarepatheffect)                                                                |
| [isTransformRef](/docs/api/routes#istransformref)                                  | Value | `@relkit/routes` | [API example](/docs/api/routes#istransformref)                                                                        |
| [isTransformRefEffect](/docs/api/routes#istransformrefeffect)                      | Value | `@relkit/routes` | [API example](/docs/api/routes#istransformrefeffect)                                                                  |
| [MappingShapeOutput](/docs/api/routes#mappingshapeoutput-type-alias)               | Type  | `@relkit/routes` | [API example](/docs/api/routes#mappingshapeoutput-type-alias)                                                         |
| [MiddlewareContext](/docs/api/routes#middlewarecontext-interface)                  | Type  | `@relkit/routes` | [API example](/docs/api/routes#middlewarecontext-interface)                                                           |
| [MiddlewareDecisionMapping](/docs/api/routes#middlewaredecisionmapping-type-alias) | Type  | `@relkit/routes` | [API example](/docs/api/routes#middlewaredecisionmapping-type-alias)                                                  |
| [MiddlewareDescriptor](/docs/api/routes#middlewaredescriptor-interface)            | Type  | `@relkit/routes` | [API example](/docs/api/routes#middlewaredescriptor-interface)                                                        |
| [MiddlewareHandler](/docs/api/routes#middlewarehandler-type-alias)                 | Type  | `@relkit/routes` | [API example](/docs/api/routes#middlewarehandler-type-alias)                                                          |
| [NativeStreamFormat](/docs/api/routes#nativestreamformat-type-alias)               | Type  | `@relkit/routes` | [API example](/docs/api/routes#nativestreamformat-type-alias)                                                         |
| [RawHttpHandler](/docs/api/routes#rawhttphandler-type-alias)                       | Type  | `@relkit/routes` | [API example](/docs/api/routes#rawhttphandler-type-alias)                                                             |
| [RawRouteDescriptor](/docs/api/routes#rawroutedescriptor-interface)                | Type  | `@relkit/routes` | [API example](/docs/api/routes#rawroutedescriptor-interface)                                                          |
| [RawRouteOptions](/docs/api/routes#rawrouteoptions-interface)                      | Type  | `@relkit/routes` | [API example](/docs/api/routes#rawrouteoptions-interface)                                                             |
| [RespondMapping](/docs/api/routes#respondmapping-interface)                        | Type  | `@relkit/routes` | [API example](/docs/api/routes#respondmapping-interface)                                                              |
| [RouteClientPolicy](/docs/api/routes#routeclientpolicy-type-alias)                 | Type  | `@relkit/routes` | [API example](/docs/api/routes#routeclientpolicy-type-alias)                                                          |
| [RouteDescriptor](/docs/api/routes#routedescriptor-type-alias)                     | Type  | `@relkit/routes` | [API example](/docs/api/routes#routedescriptor-type-alias)                                                            |
| [RouteInputError](/docs/api/routes#routeinputerror-class)                          | Value | `@relkit/routes` | [API example](/docs/api/routes#routeinputerror-class)                                                                 |
| [RouteModuleContract](/docs/api/routes#routemodulecontract-type-alias)             | Type  | `@relkit/routes` | [Source example](https://github.com/rel-kit/relkit/blob/main/tests/types/route-modules.ts#L18)                        |
| [RouteModuleMethod](/docs/api/routes#routemodulemethod-type-alias)                 | Type  | `@relkit/routes` | [Module example](/docs/modules/http/define)                                                                           |
| [RouteOperation](/docs/api/routes#routeoperation-type-alias)                       | Type  | `@relkit/routes` | [API example](/docs/api/routes#routeoperation-type-alias)                                                             |
| [RouteOperationError](/docs/api/routes#routeoperationerror-class)                  | Value | `@relkit/routes` | [API example](/docs/api/routes#routeoperationerror-class)                                                             |
| [RouteRateLimit](/docs/api/routes#routeratelimit-interface)                        | Type  | `@relkit/routes` | [API example](/docs/api/routes#routeratelimit-interface)                                                              |
| [RouteTelemetry](/docs/api/routes#routetelemetry-class)                            | Value | `@relkit/routes` | [API example](/docs/api/routes#routetelemetry-class)                                                                  |
| [RouteTelemetryLive](/docs/api/routes#routetelemetrylive-1)                        | Value | `@relkit/routes` | [API example](/docs/api/routes#routetelemetrylive-1)                                                                  |
| [RouteTelemetryService](/docs/api/routes#routetelemetryservice-interface)          | Type  | `@relkit/routes` | [API example](/docs/api/routes#routetelemetryservice-interface)                                                       |
| [SERVICE_ROUTE_METHODS](/docs/api/routes#service_route_methods)                    | Value | `@relkit/routes` | [Source example](https://github.com/rel-kit/relkit/blob/main/packages/routes/tests/define-service-routes.test.ts#L26) |
| [ServiceRouteEntry](/docs/api/routes#servicerouteentry-type-alias)                 | Type  | `@relkit/routes` | [API example](/docs/api/routes#servicerouteentry-type-alias)                                                          |
| [ServiceRouteMethod](/docs/api/routes#serviceroutemethod-type-alias)               | Type  | `@relkit/routes` | [API example](/docs/api/routes#serviceroutemethod-type-alias)                                                         |
| [ServiceRouteOptions](/docs/api/routes#servicerouteoptions-type-alias)             | Type  | `@relkit/routes` | [API example](/docs/api/routes#servicerouteoptions-type-alias)                                                        |
| [ServiceRoutesOptions](/docs/api/routes#serviceroutesoptions-type-alias)           | Type  | `@relkit/routes` | [API example](/docs/api/routes#serviceroutesoptions-type-alias)                                                       |
| [ServiceRoutesResult](/docs/api/routes#serviceroutesresult-type-alias)             | Type  | `@relkit/routes` | [API example](/docs/api/routes#serviceroutesresult-type-alias)                                                        |
| [TransformOutput](/docs/api/routes#transformoutput-type-alias)                     | Type  | `@relkit/routes` | [API example](/docs/api/routes#transformoutput-type-alias)                                                            |
| [TransformReference](/docs/api/routes#transformreference-interface)                | Type  | `@relkit/routes` | [API example](/docs/api/routes#transformreference-interface)                                                          |

## `define-middleware.ts`

### defineMiddleware

Defines one automatically discovered path-scoped HTTP middleware handler.

**Throws**

TypeError for an invalid path or handler.

**Example**

```ts
import { defineMiddleware } from "@relkit/app/routes";

export default defineMiddleware("/orders/*", async (context, next) => {
  if (context.req.header("authorization") === undefined) {
    return context.json({ error: "unauthorized" }, 401);
  }
  await next();
});
```

**Signature**

```ts
declare const defineMiddleware: (
  path: string,
  handler: MiddlewareHandler,
) => MiddlewareDescriptor<string>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.ts#L72)

Since v0.1.0

### MiddlewareContext

**Signature**

```ts
declare const MiddlewareContext: MiddlewareContext;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.ts#L15)

### MiddlewareDescriptor

**Signature**

```ts
declare const MiddlewareDescriptor: MiddlewareDescriptor<Id>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.ts#L16)

### MiddlewareHandler

**Signature**

```ts
declare const MiddlewareHandler: MiddlewareHandler;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.ts#L17)

### defineMiddlewareEffect

Defines path-scoped middleware through a typed Effect.

**Example**

```ts
Effect.runSync(defineMiddlewareEffect("/orders/*", handler));
```

**Signature**

```ts
declare const defineMiddlewareEffect: (
  path: string,
  handler: MiddlewareHandler,
) => Effect.Effect<MiddlewareDescriptor<string>, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.ts#L26)

### isMiddlewareDescriptor

Checks a middleware descriptor synchronously.

**Example**

```ts
isMiddlewareDescriptor(value);
```

**Signature**

```ts
declare const isMiddlewareDescriptor: (value: unknown) => value is MiddlewareDescriptor;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.ts#L94)

### isMiddlewareDescriptorEffect

Checks a middleware descriptor through Effect.

**Example**

```ts
Effect.runSync(isMiddlewareDescriptorEffect(value));
```

**Signature**

```ts
declare const isMiddlewareDescriptorEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.ts#L84)

### isMiddlewarePath

Checks a middleware path synchronously.

**Example**

```ts
isMiddlewarePath("/orders/*");
```

**Signature**

```ts
declare const isMiddlewarePath: (value: unknown) => value is string;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.ts#L122)

### isMiddlewarePathEffect

Checks an HTTP middleware path through Effect.

**Example**

```ts
Effect.runSync(isMiddlewarePathEffect("/orders/*"));
```

**Signature**

```ts
declare const isMiddlewarePathEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.ts#L113)

## `define-middleware.types.ts`

### MiddlewareContext (interface)

Invocation-scoped capabilities provided to middleware.

**Example**

```ts
const context: MiddlewareContext = relkit;
```

**Signature**

```ts
export interface MiddlewareContext {
  readonly signal: AbortSignal;
  readonly env: ResolvedApplicationEnv;
  readonly auth: AuthContext;
  readonly log: PublicLogger;
  readonly time: PublicClock;
  readonly trace: PublicTrace;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.types.ts#L9)

### MiddlewareDescriptor (interface)

Frozen descriptor for one middleware handler.

**Example**

```ts
const descriptor: MiddlewareDescriptor = defineMiddleware("/orders", handler);
```

**Signature**

```ts
export interface MiddlewareDescriptor<Id extends string = string> extends DescriptorBase<
  "middleware",
  Id
> {
  readonly path: string;
  readonly handler: MiddlewareHandler;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.types.ts#L30)

### MiddlewareHandler (type alias)

A path-scoped HTTP middleware callback.

**Example**

```ts
const handler: MiddlewareHandler = async (_context, next) => next();
```

**Signature**

```ts
type MiddlewareHandler = (
  context: Context,
  next: Next,
  relkit: MiddlewareContext,
) => MaybePromise<Response | void>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-middleware.types.ts#L21)

## `define-route.ts`

### defineRoute

Defines one HTTP method exported by a nested `route.ts` module.

The compiler derives the method from the named export and the path from the
file. Omit `id` for a source-derived route identity, and omit `request` and
`responses` when schema-based inference represents the transport; explicit
mappings replace inference completely. Matching path names map into reusable
function input.

**Throws**

TypeError for invalid authoring input.

**Example**

````ts
A GET route with inferred path and query input
```ts
import { defineFunction } from "@relkit/app/functions"
import { defineRoute } from "@relkit/app/routes"
import { z } from "@relkit/app/schema"

const listOrders = defineFunction({
  id: "orders.list",
  input: z.object({ status: z.string().optional() }),
  output: z.object({ count: z.number().int() }),
  handler: async () => ({ count: 0 })
})

export const GET = defineRoute({ target: listOrders })
````

````

**Signature**

```ts
declare const defineRoute: { <const Id extends string, const Handler extends RawRouteOptions<Id>["handler"]>(options: RawRouteOptions<Id, Handler>): RawRouteDescriptor<Id, Handler>; <const Id extends string, const Target extends FunctionRefAny, const Request extends HttpRequestMapping | undefined = undefined>(options: FunctionRouteOptions<Id, Target, Request>): FunctionRouteDescriptor<Id, Target, Request>; }
````

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-route.ts#L103)

Since v0.1.0

#### Backend and frontend example

**Backend** — these maintained files define the operation used by the frontend below.

```ts title="templates/default/v1/api/src/routes/echo/route.ts"
/** Maps the HTTP endpoint to its owning service's public member. */
import { defineRoute } from "@relkit/app/routes";
import echo from "@app/services/echo/service.js";

export const POST = defineRoute({
  target: echo.echo,
});
```

**Frontend**

After [frontend installation, contract pull, and provider setup](/guides/frontend/connect-react),
call this `POST /echo` operation with its domain input. The route produces both the React selector
`POST /echo` and the TypeScript operation `route.post.echo`.

**React**

Render this component under `RelkitClientProvider`. Clicking the button sends `{ message }` and
displays the inferred `{ message: string }` result:

```tsx title="src/EchoButton.tsx"
"use client";

/** Calls the documented POST /echo function route after an explicit user action. */
import { useRelkitClient, useRouteMutation } from "@relkit/client/react";

/** Sends domain input and renders the validated output; the hook owns mutation state.
 * @returns An Echo button with pending, failure, and success feedback. */
export function EchoButton() {
  const { status } = useRelkitClient();
  const echo = useRouteMutation("POST /echo");

  return (
    <section>
      <button
        disabled={status !== "ready" || echo.isPending}
        onClick={() => echo.mutate({ message: "Hello from the frontend" })}
      >
        Send message
      </button>
      {echo.isPending && <p role="status">Sending…</p>}
      {echo.isError && <p role="alert">{String(echo.error)}</p>}
      {echo.isSuccess && <p>{echo.data.message}</p>}
    </section>
  );
}
```

**TypeScript**

Without React, load the browser identity before the mutation and call the generated operation:

```ts title="src/echo-client.ts"
/** Calls the Echo contract from a TypeScript browser frontend without React or backend source imports. */
import { createClient } from "@relkit/client";

/** Sends one message over RPC using types from the caller's pulled contract.
 * @param baseUrl - Public backend origin, or the frontend origin when proxying RPC.
 * @param message - Nonempty message accepted by the Echo function.
 * @returns The validated message output; transport and application failures reject. */
export async function echoMessage(baseUrl: string, message: string) {
  const response = await fetch(new URL("/_relkit/v1/client/identity", baseUrl), {
    credentials: "include",
    cache: "no-store",
  });
  if (!response.ok) throw new Error(`Identity request failed (${response.status})`);
  const identity = await response.json();
  if (
    !identity ||
    typeof identity.identityScope !== "string" ||
    typeof identity.sessionEpoch !== "string"
  ) {
    throw new Error("The backend returned an invalid client identity");
  }
  const client = createClient({
    baseUrl,
    headers: {
      "x-relkit-identity-scope": identity.identityScope,
      "x-relkit-session-epoch": identity.sessionEpoch,
    },
  });
  return client["route.post.echo"]({ message });
}
```

The React provider performs this identity step for hooks.

These calls use RPC over `/rpc`, with the same authorization and policy. Pass domain input rather
than assembling the route's REST mapping. Raw handlers and routes with `client: false` do not
generate these operations. Never import the backend descriptor into the browser.

Reference: [`useRouteMutation`](/docs/api/client#useroutemutation),
[`createClient`](/docs/api/client#createclient). Continue with [mutations](/docs/modules/client/mutations).

### "./route.types.js" (namespace export)

Re-exports all named exports from the "./route.types.js" module.

**Signature**

```ts
export * from "./route.types.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-route.ts#L20)

### defineRouteEffect

Defines a raw or function route through Effect.

**Example**

```ts
Effect.runSync(defineRouteEffect({ target: listOrders }));
```

**Signature**

```ts
declare const defineRouteEffect: {
  <const Id extends string, const Handler extends RawRouteOptions<Id>["handler"]>(
    options: RawRouteOptions<Id, Handler>,
  ): Effect.Effect<RawRouteDescriptor<Id, Handler>, RouteOperationError>;
  <
    const Id extends string,
    const Target extends FunctionRefAny,
    const Request extends HttpRequestMapping | undefined = undefined,
  >(
    options: FunctionRouteOptions<Id, Target, Request>,
  ): Effect.Effect<FunctionRouteDescriptor<Id, Target, Request>, RouteOperationError>;
};
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-route.ts#L55)

## `define-service-routes.ts`

### SERVICE_ROUTE_METHODS

**Signature**

```ts
declare const SERVICE_ROUTE_METHODS: readonly [
  "GET",
  "POST",
  "PUT",
  "PATCH",
  "DELETE",
  "HEAD",
  "OPTIONS",
];
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.ts#L25)

### ServiceRouteEntry

**Signature**

```ts
declare const ServiceRouteEntry: ServiceRouteEntry<Service>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.ts#L20)

### ServiceRouteMethod

**Signature**

```ts
declare const ServiceRouteMethod: ServiceRouteMethod;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.ts#L18)

### ServiceRouteOptions

**Signature**

```ts
declare const ServiceRouteOptions: ServiceRouteOptions<Name, Target>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.ts#L19)

### ServiceRoutesOptions

**Signature**

```ts
declare const ServiceRoutesOptions: Partial<
  Readonly<Record<ServiceRouteMethod, ServiceRouteEntry<Service>>>
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.ts#L21)

### ServiceRoutesResult

**Signature**

```ts
declare const ServiceRoutesResult: Readonly<{
  [Method in keyof Options]: FunctionRouteDescriptor<
    string,
    Extract<
      ServiceFunctions<Service>[Extract<
        EntryName<Options[Method]>,
        Extract<keyof ServiceFunctions<Service>, string>
      >],
      FunctionRefAny
    >,
    EntryRequest<Options[Method]>
  >;
}>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.ts#L22)

### defineServiceRoutes

Creates explicit HTTP routes for a service synchronously.

**Throws**

TypeError for invalid method or member references.

**Example**

```ts
defineServiceRoutes(service, { GET: "list" });
```

**Signature**

```ts
declare const defineServiceRoutes: <
  const Service extends ServiceDescriptor<string, any, any>,
  const Options extends ServiceRoutesOptions<Service>,
>(
  service: Service,
  options: Options & Record<Exclude<keyof Options, ServiceRouteMethod>, never>,
) => ServiceRoutesResult<Service, Options>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.ts#L82)

#### Backend and frontend example

**Backend** — these maintained files define the operation used by the frontend below.

```ts title="examples/commerce/src/routes/orders/route.ts"
/**
 * Maps order HTTP operations to public service members with the existing request
 * and rate-limit policies. The rate-limit reference addresses the declared cache
 * by its stable identity without importing a private service implementation.
 */
import { defineServiceRoutes, http } from "@relkit/app/routes";
import { z } from "@relkit/app/schema";
import orders from "../../services/orders/service.js";

export const { GET, POST } = defineServiceRoutes(orders, {
  GET: "searchOrders",
  POST: {
    member: "createOrder",
    request: http.input({
      orderId: http.header("idempotency-key"),
      customerEmail: http.header("x-customer-email"),
      sku: http.body("sku"),
      quantity: http.body("quantity"),
    }),
    rateLimit: {
      limit: 20,
      windowMs: 60_000,
      key: http.header("x-customer-email"),
      store: {
        ref: { kind: "cache", id: "orders.rate-limits" },
        key: z.string(),
        value: z.number().int().nonnegative(),
      },
    },
    successStatus: 201,
  },
});
```

**Frontend**

After [frontend setup and pulling this backend's contract](/guides/frontend/connect-react),
render this component under `RelkitClientProvider`. Each exported service-route method produces
its own typed operation: `GET /orders` reads the search count, while `POST /orders` creates an order.

```tsx title="src/Orders.tsx"
"use client";

/** Calls both commerce service-route methods using their generated domain inputs inside the frontend provider. */
import { useRelkitClient, useRoute, useRouteMutation } from "@relkit/client/react";

/** Reads the Orders search count and submits one explicit creation without replaying a failed write.
 * @returns Typed query results, creation feedback, and an action available after identity is ready. */
export function Orders() {
  const { status } = useRelkitClient();
  const orders = useRoute("GET /orders", { input: { status: "pending" } });
  const create = useRouteMutation("POST /orders");

  return (
    <section>
      {orders.isPending && <p role="status">Loading orders…</p>}
      {orders.data && <p>{orders.data.count} orders</p>}
      {orders.isError && <p role="alert">{orders.error.message}</p>}
      <button
        disabled={status !== "ready" || !create.isIdle}
        onClick={() =>
          create.mutate({
            orderId: crypto.randomUUID(),
            customerEmail: "reader@example.com",
            sku: "book",
            quantity: 1,
          })
        }
      >
        Create an order
      </button>
      {create.isPending && <p role="status">Creating…</p>}
      {create.isSuccess && <p>Created: {create.data.orderId}</p>}
      {create.isError && (
        <p role="alert">{create.error.message}. Check the outcome before retrying.</p>
      )}
    </section>
  );
}
```

`status`, `count`, and the creation input come from the selected functions' schemas. RPC receives
`orderId` and `customerEmail` as input fields even though REST maps them from headers. A service's
public member alone is not a browser endpoint: the client-exposed route supplies that boundary.

Reference: [`useRoute`](/docs/api/client#useroute), [`useRouteMutation`](/docs/api/client#useroutemutation).
See [request mapping](/docs/modules/http/requests) for the REST side and
[mutations](/docs/modules/client/mutations) for submission and recovery behavior.

### defineServiceRoutesEffect

Creates explicit service routes through an Effect.

**Example**

```ts
Effect.runSync(defineServiceRoutesEffect(service, { GET: "list" }));
```

**Signature**

```ts
declare const defineServiceRoutesEffect: <
  const Service extends ServiceDescriptor<string, any, any>,
  const Options extends Partial<Readonly<Record<ServiceRouteMethod, ServiceRouteEntry<Service>>>>,
>(
  service: Service,
  options: Options & Record<Exclude<keyof Options, ServiceRouteMethod>, never>,
) => Effect.Effect<
  Readonly<{
    [Method in keyof Options]: FunctionRouteDescriptor<
      string,
      Extract<
        ServiceFunctions<Service>[Extract<
          EntryName<Options[Method]>,
          Extract<keyof ServiceFunctions<Service>, string>
        >],
        FunctionRefAny
      >,
      EntryRequest<Options[Method]>
    >;
  }>,
  RouteOperationError,
  never
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.ts#L41)

## `define-service-routes.types.ts`

### ServiceRouteEntry (type alias)

Member name or options for a service route.

**Example**

```ts
type Entry = ServiceRouteEntry<typeof service>;
```

**Signature**

```ts
type ServiceRouteEntry<Service> = {
  [Name in ServiceFunctionName<Service>]:
    Name | ServiceRouteOptions<Name, ServiceFunction<Service, Name>>;
}[ServiceFunctionName<Service>];
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.types.ts#L27)

### ServiceRouteMethod (type alias)

Explicit HTTP methods supported by a service route table.

**Example**

```ts
const method: ServiceRouteMethod = "GET";
```

**Signature**

```ts
type ServiceRouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.types.ts#L9)

### ServiceRouteOptions (type alias)

Expanded options selecting one service function.

**Example**

```ts
type Options = ServiceRouteOptions<"list", typeof list>;
```

**Signature**

```ts
type ServiceRouteOptions<Name extends string, Target extends FunctionRefAny> = Omit<
  FunctionRouteOptions<string, Target, HttpRequestMapping | undefined>,
  "target"
> & { readonly member: Name };
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.types.ts#L19)

### ServiceRoutesOptions (type alias)

Partial HTTP method table for a service.

**Example**

```ts
type Options = ServiceRoutesOptions<typeof service>;
```

**Signature**

```ts
type ServiceRoutesOptions<Service> = Partial<
  Readonly<Record<ServiceRouteMethod, ServiceRouteEntry<Service>>>
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.types.ts#L35)

### ServiceRoutesResult (type alias)

Route descriptors inferred from a service route table.

**Example**

```ts
type Routes = ServiceRoutesResult<typeof service, { GET: "list" }>;
```

**Signature**

```ts
type ServiceRoutesResult<Service, Options> = Readonly<{
  [Method in keyof Options]: FunctionRouteDescriptor<
    string,
    ServiceFunction<Service, Extract<EntryName<Options[Method]>, ServiceFunctionName<Service>>>,
    EntryRequest<Options[Method]>
  >;
}>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/define-service-routes.types.ts#L54)

## `http-dsl-mapping-validation.ts`

### assertMapping

Asserts a serializable mapping synchronously.

**Throws**

TypeError for invalid mapping values.

**Example**

```ts
assertMapping(http.path("id"));
```

**Signature**

```ts
declare const assertMapping: (value: unknown) => asserts value is HttpMappingNode;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L79)

### assertMappingEffect

Asserts a serializable mapping through Effect.

**Example**

```ts
Effect.runSync(assertMappingEffect(http.path("id")));
```

**Signature**

```ts
declare const assertMappingEffect: (
  value: unknown,
) => Effect.Effect<void, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L69)

### assertMappingValue

Validates a mapping inside an already observed operation.

**Throws**

RouteInputError for an invalid mapping.

**Example**

```ts
assertMappingValue({ kind: "path", name: "id" });
```

**Signature**

```ts
declare const assertMappingValue: (value: unknown) => asserts value is HttpMappingNode;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L89)

### assertRequestMapping

Asserts a request input mapping synchronously.

**Throws**

TypeError for invalid request mappings.

**Example**

```ts
assertRequestMapping(http.input({}));
```

**Signature**

```ts
declare const assertRequestMapping: (value: unknown) => asserts value is HttpRequestMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L130)

### assertRequestMappingEffect

Asserts a request input mapping through Effect.

**Example**

```ts
Effect.runSync(assertRequestMappingEffect(http.input({})));
```

**Signature**

```ts
declare const assertRequestMappingEffect: (
  value: unknown,
) => Effect.Effect<void, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L120)

### assertRequestMappingValue

Validates a request mapping inside an already observed operation.

**Throws**

RouteInputError for an invalid request mapping.

**Example**

```ts
assertRequestMappingValue({ kind: "input", fields: {} });
```

**Signature**

```ts
declare const assertRequestMappingValue: (value: unknown) => asserts value is HttpRequestMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L140)

### isHttpMapping

Checks a serializable mapping synchronously.

**Example**

```ts
isHttpMapping(http.path("id"));
```

**Signature**

```ts
declare const isHttpMapping: (value: unknown) => value is HttpMappingNode;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L21)

### isHttpMappingEffect

Checks a serializable mapping through Effect.

**Example**

```ts
Effect.runSync(isHttpMappingEffect(http.path("id")));
```

**Signature**

```ts
declare const isHttpMappingEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L12)

### isHttpRequestMapping

Checks a request input mapping synchronously.

**Example**

```ts
isHttpRequestMapping(http.input({}));
```

**Signature**

```ts
declare const isHttpRequestMapping: (value: unknown) => value is HttpRequestMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L108)

### isHttpRequestMappingEffect

Checks a request input mapping through Effect.

**Example**

```ts
Effect.runSync(isHttpRequestMappingEffect(http.input({})));
```

**Signature**

```ts
declare const isHttpRequestMappingEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L99)

### isMappingValue

Checks a non-root mapping during recursive validation.

**Example**

```ts
isMappingValue(http.path("id"));
```

**Signature**

```ts
declare const isMappingValue: (value: unknown) => value is HttpMappingNode;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-mapping-validation.ts#L149)

## `http-dsl-methods.types.ts`

### HttpDslMethods (interface)

Constructor methods for serializable HTTP mappings.

**Example**

```ts
const request = http.input({ id: http.path("id") });
```

**Signature**

```ts
export interface HttpDslMethods extends HttpDslSources {
  /** Named request fields.
   * @param fields - Serializable field mappings.
   * @returns An input mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.input({ id: http.path("id") });
   */
  input<const S extends HttpMappingShape>(fields: S): HttpInputMapping<S>;
  /** Named nested fields.
   * @param fields - Serializable field mappings.
   * @returns A nested object mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.nested({ id: http.path("id") });
   */
  nested<const S extends HttpMappingShape>(fields: S): HttpNestedMapping<S>;
  /** A serializable constant.
   * @param value - JSON-compatible value.
   * @returns A constant mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.constant("all");
   */
  constant<const V extends JsonValue>(value: V): HttpConstantMapping<V>;
  /** An optional source value.
   * @param value - Existing mapping node.
   * @returns An optional mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.optional(http.query("page"));
   */
  optional<const M extends HttpMappingNode>(value: M): HttpOptionalMapping<M>;
  /** A source value with a fallback.
   * @param value - Existing mapping node
   * @param fallback - JSON-compatible default.
   * @returns A default mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.default(http.query("page"), "1");
   */
  default<const M extends HttpMappingNode, const V extends JsonValue>(
    value: M,
    fallback: V,
  ): HttpDefaultMapping<M, V>;
  /** A registered transformation.
   * @param transform - Reference or stable ID
   * @param value - Optional input mapping.
   * @returns A transform mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.transform("text.upper", http.body("name"));
   */
  transform<const T extends HttpTransformRef | string, const M extends HttpMappingNode>(
    transform: T,
    value?: M,
  ): HttpTransformMapping<TransformOutput<T>>;
  /** A successful response.
   * @param status - HTTP status
   * @param schema - Optional body schema.
   * @returns A response mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.success(200);
   */
  success(status: number, schema?: StandardSchemaV1): HttpResponseMapping;
  /** An error response.
   * @param errorId - Stable error ID
   * @param status - HTTP status
   * @param schema - Optional body schema.
   * @returns An error response mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.error("not-found", 404);
   */
  error(errorId: string, status: number, schema?: StandardSchemaV1): HttpResponseMapping;
  /** A validation failure response.
   * @param status - HTTP status
   * @param schema - Optional body schema.
   * @returns A validation-error mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.validationError(422);
   */
  validationError(status?: number, schema?: StandardSchemaV1): HttpResponseMapping;
  /** A named response.
   * @param id - Stable response ID
   * @param status - HTTP status
   * @param schema - Optional body schema.
   * @returns A named response mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.response("accepted", 202);
   */
  response(id: string, status: number, schema?: StandardSchemaV1): HttpResponseMapping;
  /** A middleware continue decision.
   * @returns A continue decision.
   * @example http.continue();
   */
  continue(): ContinueMapping;
  /** A middleware response decision.
   * @param response - Mapping or stable response ID
   * @param body - Optional body mapping.
   * @returns A respond decision.
   * @throws TypeError when the mapping input is invalid.
   * @example http.respond("accepted");
   */
  respond(response: HttpResponseMapping | string, body?: HttpMappingNode): RespondMapping;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-methods.types.ts#L25)

## `http-dsl-operations.ts`

### httpEffects

Effect implementations for each HTTP mapping constructor.

**Example**

```ts
Effect.runSync(httpEffects.input({ id: httpEffects.path("id") }));
```

**Signature**

```ts
declare const httpEffects: {
  constant: <const V extends JsonValue>(
    value: V,
  ) => Effect.Effect<HttpConstantMapping<V>, RouteOperationError, never>;
  optional: <const M extends HttpMappingNode>(
    value: M,
  ) => Effect.Effect<HttpOptionalMapping<M>, RouteOperationError, never>;
  default: <const M extends HttpMappingNode, const V extends JsonValue>(
    value: M,
    fallback: V,
  ) => Effect.Effect<HttpDefaultMapping<M, V>, RouteOperationError, never>;
  transform: <const T extends HttpTransformRef | string, const M extends HttpMappingNode>(
    transform: T,
    value?: M | undefined,
  ) => Effect.Effect<HttpTransformMapping<TransformOutput<T>>, RouteOperationError, never>;
  success: (
    status: number,
    schema?: StandardSchemaV1<unknown, unknown> | undefined,
  ) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
  error: (
    errorId: string,
    status: number,
    schema?: StandardSchemaV1<unknown, unknown> | undefined,
  ) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
  validationError: (
    status?: number | undefined,
    schema?: StandardSchemaV1<unknown, unknown> | undefined,
  ) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
  response: (
    id: string,
    status: number,
    schema?: StandardSchemaV1<unknown, unknown> | undefined,
  ) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
  continue: () => Effect.Effect<ContinueMapping, RouteOperationError, never>;
  respond: (
    response: string | HttpResponseMapping,
    body?: HttpMappingNode | undefined,
  ) => Effect.Effect<RespondMapping, RouteOperationError, never>;
  input: <const S extends HttpMappingShape>(
    fields: S,
  ) => Effect.Effect<HttpInputMapping<S>, RouteOperationError, never>;
  nested: <const S extends HttpMappingShape>(
    fields: S,
  ) => Effect.Effect<HttpNestedMapping<S>, RouteOperationError, never>;
  path: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  pathSegments: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  query: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  header: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  cookie: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  body: (
    name?: string | undefined,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  wholeBody: () => Effect.Effect<HttpWholeBodyMapping<unknown>, RouteOperationError, never>;
  multipart: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  multipartAll: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
};
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-operations.ts#L12)

## `http-dsl-response-validation.ts`

### assertResponse

Asserts a response mapping synchronously.

**Throws**

TypeError for invalid response mappings.

**Example**

```ts
assertResponse(http.success(200));
```

**Signature**

```ts
declare const assertResponse: (value: unknown) => HttpResponseMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-response-validation.ts#L56)

### assertResponseEffect

Asserts a response mapping through Effect.

**Example**

```ts
Effect.runSync(assertResponseEffect(http.success(200)));
```

**Signature**

```ts
declare const assertResponseEffect: (
  value: unknown,
) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-response-validation.ts#L46)

### assertResponseValue

Validates a response inside an already observed operation.

**Throws**

RouteInputError for an invalid response.

**Example**

```ts
assertResponseValue({ kind: "success", id: "success.200", status: 200 });
```

**Signature**

```ts
declare const assertResponseValue: (value: unknown) => HttpResponseMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-response-validation.ts#L66)

### isHttpResponseMapping

Checks a response mapping synchronously.

**Example**

```ts
isHttpResponseMapping(http.success(200));
```

**Signature**

```ts
declare const isHttpResponseMapping: (value: unknown) => value is HttpResponseMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-response-validation.ts#L27)

### isHttpResponseMappingEffect

Checks a response mapping through Effect.

**Example**

```ts
Effect.runSync(isHttpResponseMappingEffect(http.success(200)));
```

**Signature**

```ts
declare const isHttpResponseMappingEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-response-validation.ts#L18)

### isMiddlewareDecision

Checks a middleware response decision synchronously.

**Example**

```ts
isMiddlewareDecision(http.continue());
```

**Signature**

```ts
declare const isMiddlewareDecision: (value: unknown) => value is MiddlewareDecisionMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-response-validation.ts#L85)

### isMiddlewareDecisionEffect

Checks a middleware response decision through Effect.

**Example**

```ts
Effect.runSync(isMiddlewareDecisionEffect(http.continue()));
```

**Signature**

```ts
declare const isMiddlewareDecisionEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-response-validation.ts#L76)

## `http-dsl-source-operations.ts`

### httpSourceEffects

Effect constructors for request input and source mappings.

**Example**

```ts
Effect.runSync(httpSourceEffects.path("id"));
```

**Signature**

```ts
declare const httpSourceEffects: {
  input: <const S extends HttpMappingShape>(
    fields: S,
  ) => Effect.Effect<HttpInputMapping<S>, RouteOperationError, never>;
  nested: <const S extends HttpMappingShape>(
    fields: S,
  ) => Effect.Effect<HttpNestedMapping<S>, RouteOperationError, never>;
  path: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  pathSegments: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  query: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  header: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  cookie: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  body: (
    name?: string | undefined,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  wholeBody: () => Effect.Effect<HttpWholeBodyMapping<unknown>, RouteOperationError, never>;
  multipart: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  multipartAll: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
};
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-source-operations.ts#L9)

## `http-dsl-sources.types.ts`

### HttpDslSources (interface)

Source constructors for serializable HTTP request mappings.

**Example**

```ts
const id = http.path("id");
```

**Signature**

```ts
export interface HttpDslSources {
  /** One path parameter.
   * @param name - Path parameter name
   * @returns A path source mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.path("id");
   */
  path(name: string): HttpPathMapping;
  /** Maps a named path parameter with optionality or a default.
   * @param name - Source name.
   * @param options - Optionality or JSON fallback.
   * @returns A source mapping, optionally wrapped by a default or optional node.
   * @throws TypeError when the mapping input is invalid.
   * @example http.path("id", { optional: true });
   */
  path(name: string, options: HttpSourceOptions): HttpMappingNode;
  /** Captured path segments.
   * @param name - Segment parameter name
   * @returns A path segments mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.pathSegments("parts");
   */
  pathSegments(name: string): HttpPathSegmentsMapping;
  /** Maps a captured path segments with optionality or a default.
   * @param name - Source name.
   * @param options - Optionality or JSON fallback.
   * @returns A source mapping, optionally wrapped by a default or optional node.
   * @throws TypeError when the mapping input is invalid.
   * @example http.pathSegments("parts", { optional: true });
   */
  pathSegments(name: string, options: HttpSourceOptions): HttpMappingNode;
  /** One query parameter.
   * @param name - Query parameter name
   * @returns A query source mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.query("page");
   */
  query(name: string): HttpQueryMapping;
  /** Maps a named query parameter with optionality or a default.
   * @param name - Source name.
   * @param options - Optionality or JSON fallback.
   * @returns A source mapping, optionally wrapped by a default or optional node.
   * @throws TypeError when the mapping input is invalid.
   * @example http.query("page", { default: "1" });
   */
  query(name: string, options: HttpSourceOptions): HttpMappingNode;
  /** One request header.
   * @param name - Header name
   * @returns A header source mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.header("authorization");
   */
  header(name: string): HttpHeaderMapping;
  /** Maps a named request header with optionality or a default.
   * @param name - Source name.
   * @param options - Optionality or JSON fallback.
   * @returns A source mapping, optionally wrapped by a default or optional node.
   * @throws TypeError when the mapping input is invalid.
   * @example http.header("authorization", { optional: true });
   */
  header(name: string, options: HttpSourceOptions): HttpMappingNode;
  /** One request cookie.
   * @param name - Cookie name
   * @returns A cookie source mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.cookie("session");
   */
  cookie(name: string): HttpCookieMapping;
  /** Maps a named request cookie with optionality or a default.
   * @param name - Source name.
   * @param options - Optionality or JSON fallback.
   * @returns A source mapping, optionally wrapped by a default or optional node.
   * @throws TypeError when the mapping input is invalid.
   * @example http.cookie("session", { optional: true });
   */
  cookie(name: string, options: HttpSourceOptions): HttpMappingNode;
  /** The whole body or one body field.
   * @param name - Optional body field name
   * @param options - Optionality or fallback.
   * @returns A body source mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.body("name");
   */
  /** The complete request body.
   * @returns A whole-body mapping.
   * @example http.body();
   */
  body(): HttpWholeBodyMapping;
  /** Maps one named body field.
   * @param name - Body field name.
   * @returns A body field mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.body("name");
   */
  body(name: string): HttpBodyMapping;
  /** Maps a named body field with optionality or a default.
   * @param name - Source name.
   * @param options - Optionality or JSON fallback.
   * @returns A source mapping, optionally wrapped by a default or optional node.
   * @throws TypeError when the mapping input is invalid.
   * @example http.body("name", { optional: true });
   */
  body(name: string, options: HttpSourceOptions): HttpMappingNode;
  /** The complete request body.
   * @returns A whole-body mapping.
   * @example http.wholeBody();
   */
  wholeBody(): HttpWholeBodyMapping;
  /** One multipart form field.
   * @param name - Form field name
   * @returns A multipart source mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.multipart("photo");
   */
  multipart(name: string): HttpMultipartMapping;
  /** Maps a named multipart field with optionality or a default.
   * @param name - Source name.
   * @param options - Optionality or JSON fallback.
   * @returns A source mapping, optionally wrapped by a default or optional node.
   * @throws TypeError when the mapping input is invalid.
   * @example http.multipart("photo", { optional: true });
   */
  multipart(name: string, options: HttpSourceOptions): HttpMappingNode;
  /** All values of one multipart field.
   * @param name - Form field name
   * @returns A multipart-array source mapping.
   * @throws TypeError when the mapping input is invalid.
   * @example http.multipartAll("files");
   */
  multipartAll(name: string): HttpMultipartAllMapping;
  /** Maps a all values of a multipart field with optionality or a default.
   * @param name - Source name.
   * @param options - Optionality or JSON fallback.
   * @returns A source mapping, optionally wrapped by a default or optional node.
   * @throws TypeError when the mapping input is invalid.
   * @example http.multipartAll("files", { optional: true });
   */
  multipartAll(name: string, options: HttpSourceOptions): HttpMappingNode;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-sources.types.ts#L18)

## `http-dsl-validation.ts`

### "./http-dsl-mapping-validation.js" (namespace export)

Re-exports all named exports from the "./http-dsl-mapping-validation.js" module.

**Signature**

```ts
export * from "./http-dsl-mapping-validation.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-validation.ts#L2)

### "./http-dsl-response-validation.js" (namespace export)

Re-exports all named exports from the "./http-dsl-response-validation.js" module.

**Signature**

```ts
export * from "./http-dsl-response-validation.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-validation.ts#L3)

### "./http-dsl-value-validation.js" (namespace export)

Re-exports all named exports from the "./http-dsl-value-validation.js" module.

**Signature**

```ts
export * from "./http-dsl-value-validation.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-validation.ts#L1)

## `http-dsl-value-validation.ts`

### assertSchema

Asserts a Standard Schema validator synchronously.

**Throws**

TypeError for invalid schemas.

**Example**

```ts
assertSchema(schema, "response schema");
```

**Signature**

```ts
declare const assertSchema: (value: unknown, name: string) => asserts value is StandardSchemaV1;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L55)

### assertSchemaEffect

Asserts a Standard Schema validator through Effect.

**Example**

```ts
Effect.runSync(assertSchemaEffect(schema, "response schema"));
```

**Signature**

```ts
declare const assertSchemaEffect: (
  value: unknown,
  name: string,
) => Effect.Effect<void, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L43)

### assertSchemaValue

Validates a schema inside an already observed operation.

**Throws**

RouteInputError for an invalid schema.

**Example**

```ts
assertSchemaValue(schema, "response schema");
```

**Signature**

```ts
declare const assertSchemaValue: (
  value: unknown,
  name: string,
) => asserts value is StandardSchemaV1;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L66)

### isJsonValue

Checks JSON compatibility without leaking a validation exception.

**Example**

```ts
isJsonValue({ ok: true });
```

**Signature**

```ts
declare const isJsonValue: (value: unknown) => value is JsonValue;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L101)

### isRecord

Checks an ordinary non-array object synchronously.

**Example**

```ts
isRecord({});
```

**Signature**

```ts
declare const isRecord: (value: unknown) => value is Record<string, any>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L132)

### isRecordEffect

Checks an ordinary non-array object through Effect.

**Example**

```ts
Effect.runSync(isRecordEffect({}));
```

**Signature**

```ts
declare const isRecordEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L123)

### isRecordValue

Checks the object shape inside another observed operation.

**Example**

```ts
isRecordValue({ kind: "path" });
```

**Signature**

```ts
declare const isRecordValue: (value: unknown) => value is Record<string, any>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L140)

### isSchema

Checks a Standard Schema validator synchronously.

**Example**

```ts
isSchema(schema);
```

**Signature**

```ts
declare const isSchema: (value: unknown) => value is StandardSchemaV1;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L21)

### isSchemaEffect

Checks a Standard Schema validator through Effect.

**Example**

```ts
Effect.runSync(isSchemaEffect(schema));
```

**Signature**

```ts
declare const isSchemaEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L12)

### isSchemaValue

Checks the Standard Schema shape inside a parent operation.

**Example**

```ts
isSchemaValue(z.string());
```

**Signature**

```ts
declare const isSchemaValue: (value: unknown) => value is StandardSchemaV1;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L29)

### isStatus

Checks an HTTP response status synchronously.

**Example**

```ts
isStatus(200);
```

**Signature**

```ts
declare const isStatus: (value: unknown) => value is number;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L85)

### isStatusEffect

Checks an HTTP response status through Effect.

**Example**

```ts
Effect.runSync(isStatusEffect(200));
```

**Signature**

```ts
declare const isStatusEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L76)

### isStatusValue

Checks an HTTP status inside response validation.

**Example**

```ts
isStatusValue(200);
```

**Signature**

```ts
declare const isStatusValue: (value: unknown) => value is number;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L93)

### ownKeys

Checks that a mapping has only its allowed own property names.

**Example**

```ts
ownKeys({ kind: "continue" }, "kind");
```

**Signature**

```ts
declare const ownKeys: (value: object, ...keys: string[]) => boolean;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-value-validation.ts#L115)

## `http-dsl-values.ts`

### httpValue

Internal pure constructors evaluated only inside the public Effect operations.

**Signature**

```ts
declare const httpValue: HttpDsl;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-values.ts#L26)

### isTransformRefValue

Checks a transform reference without running another Effect adapter.

**Example**

```ts
isTransformRefValue({ ref: { kind: "transform", id: "x" }, schema });
```

**Signature**

```ts
declare const isTransformRefValue: (value: unknown) => value is HttpTransformRef;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl-values.ts#L137)

## `http-dsl.ts`

### "./http-dsl.types.js" (namespace export)

Re-exports all named exports from the "./http-dsl.types.js" module.

**Signature**

```ts
export * from "./http-dsl.types.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L23)

### assertRequestMapping

**Signature**

```ts
declare const assertRequestMapping: (value: unknown) => asserts value is HttpRequestMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L25)

### assertRequestMappingEffect

**Signature**

```ts
declare const assertRequestMappingEffect: (
  value: unknown,
) => Effect.Effect<void, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L26)

### assertResponse

**Signature**

```ts
declare const assertResponse: (value: unknown) => HttpResponseMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L27)

### assertResponseEffect

**Signature**

```ts
declare const assertResponseEffect: (
  value: unknown,
) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L28)

### defineRequestTransform

Alias for request transform definitions.

**Throws**

TypeError for invalid transform input.

**Example**

```ts
defineRequestTransform({ schema });
```

**Signature**

```ts
declare const defineRequestTransform: <
  const Id extends string,
  const Schema extends StandardSchemaV1,
>(
  options: DefineTransformOptions<Id, Schema>,
) => HttpTransformDescriptor<Id, Schema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L84)

### defineRequestTransformEffect

Effect alias for request transform definitions.

**Example**

```ts
Effect.runSync(defineRequestTransformEffect({ schema }));
```

**Signature**

```ts
declare const defineRequestTransformEffect: <
  const Id extends string,
  const Schema extends StandardSchemaV1,
>(
  options: DefineTransformOptions<Id, Schema>,
) => Effect.Effect<HttpTransformDescriptor<Id, Schema>, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L91)

### defineTransform

Defines a serializable HTTP transform.

**Throws**

TypeError for invalid input or a closure-bearing transform.

**Example**

```ts
defineTransform({ schema });
```

**Signature**

```ts
declare const defineTransform: <const Id extends string, const Schema extends StandardSchemaV1>(
  options: DefineTransformOptions<Id, Schema>,
) => HttpTransformDescriptor<Id, Schema>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L72)

### defineTransformEffect

Defines a serializable transform through Effect.

**Example**

```ts
Effect.runSync(defineTransformEffect({ schema }));
```

**Signature**

```ts
declare const defineTransformEffect: <
  const Id extends string,
  const Schema extends StandardSchemaV1,
>(
  options: DefineTransformOptions<Id, Schema>,
) => Effect.Effect<HttpTransformDescriptor<Id, Schema>, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L45)

### http

Creates serializable HTTP request and response mappings.

**Example**

```ts
const request = http.input({ id: http.path("id") });
```

**Signature**

```ts
declare const http: HttpDsl;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L131)

### httpEffects

**Signature**

```ts
declare const httpEffects: {
  constant: <const V extends JsonValue>(
    value: V,
  ) => Effect.Effect<HttpConstantMapping<V>, RouteOperationError, never>;
  optional: <const M extends HttpMappingNode>(
    value: M,
  ) => Effect.Effect<HttpOptionalMapping<M>, RouteOperationError, never>;
  default: <const M extends HttpMappingNode, const V extends JsonValue>(
    value: M,
    fallback: V,
  ) => Effect.Effect<HttpDefaultMapping<M, V>, RouteOperationError, never>;
  transform: <const T extends HttpTransformRef | string, const M extends HttpMappingNode>(
    transform: T,
    value?: M | undefined,
  ) => Effect.Effect<HttpTransformMapping<TransformOutput<T>>, RouteOperationError, never>;
  success: (
    status: number,
    schema?: StandardSchemaV1<unknown, unknown> | undefined,
  ) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
  error: (
    errorId: string,
    status: number,
    schema?: StandardSchemaV1<unknown, unknown> | undefined,
  ) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
  validationError: (
    status?: number | undefined,
    schema?: StandardSchemaV1<unknown, unknown> | undefined,
  ) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
  response: (
    id: string,
    status: number,
    schema?: StandardSchemaV1<unknown, unknown> | undefined,
  ) => Effect.Effect<HttpResponseMapping, RouteOperationError, never>;
  continue: () => Effect.Effect<ContinueMapping, RouteOperationError, never>;
  respond: (
    response: string | HttpResponseMapping,
    body?: HttpMappingNode | undefined,
  ) => Effect.Effect<RespondMapping, RouteOperationError, never>;
  input: <const S extends HttpMappingShape>(
    fields: S,
  ) => Effect.Effect<HttpInputMapping<S>, RouteOperationError, never>;
  nested: <const S extends HttpMappingShape>(
    fields: S,
  ) => Effect.Effect<HttpNestedMapping<S>, RouteOperationError, never>;
  path: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  pathSegments: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  query: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  header: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  cookie: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  body: (
    name?: string | undefined,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  wholeBody: () => Effect.Effect<HttpWholeBodyMapping<unknown>, RouteOperationError, never>;
  multipart: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
  multipartAll: (
    name: string,
    options?: HttpSourceOptions | undefined,
  ) => Effect.Effect<HttpMappingNode, RouteOperationError, never>;
};
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L38)

### isHttpMapping

**Signature**

```ts
declare const isHttpMapping: (value: unknown) => value is HttpMappingNode;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L29)

### isHttpMappingEffect

**Signature**

```ts
declare const isHttpMappingEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L30)

### isHttpRequestMapping

**Signature**

```ts
declare const isHttpRequestMapping: (value: unknown) => value is HttpRequestMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L31)

### isHttpRequestMappingEffect

**Signature**

```ts
declare const isHttpRequestMappingEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L32)

### isHttpResponseMapping

**Signature**

```ts
declare const isHttpResponseMapping: (value: unknown) => value is HttpResponseMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L33)

### isHttpResponseMappingEffect

**Signature**

```ts
declare const isHttpResponseMappingEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L34)

### isMiddlewareDecision

**Signature**

```ts
declare const isMiddlewareDecision: (value: unknown) => value is MiddlewareDecisionMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L35)

### isMiddlewareDecisionEffect

**Signature**

```ts
declare const isMiddlewareDecisionEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L36)

### isTransformRef

Checks a transform reference synchronously.

**Example**

```ts
isTransformRef(transform);
```

**Signature**

```ts
declare const isTransformRef: (value: unknown) => value is HttpTransformRef;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L123)

### isTransformRefEffect

Checks a transform reference through Effect.

**Example**

```ts
Effect.runSync(isTransformRefEffect(transform));
```

**Signature**

```ts
declare const isTransformRefEffect: (
  value: unknown,
) => Effect.Effect<boolean, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.ts#L114)

## `http-dsl.types.ts`

### "./http-mapping.types.js" (namespace export)

Re-exports all named exports from the "./http-mapping.types.js" module.

**Signature**

```ts
export * from "./http-mapping.types.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L6)

### ContinueMapping (interface)

Middleware decision that delegates to the next handler.

**Example**

```ts
const decision: ContinueMapping = http.continue();
```

**Signature**

```ts
export interface ContinueMapping {
  readonly kind: "continue";
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L75)

### DefineTransformOptions (interface)

Authoring options for a serializable transform.

**Example**

```ts
type Options = DefineTransformOptions<"text.upper", typeof schema>;
```

**Signature**

```ts
export interface DefineTransformOptions<
  Id extends string,
  Schema extends StandardSchemaV1,
> extends DescriptorMetadata {
  readonly id?: Id;
  readonly schema: Schema;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L54)

### HttpDsl (interface)

Synchronous HTTP mapping constructor API.

**Example**

```ts
const request = http.input({ id: http.path("id") });
```

**Signature**

```ts
export interface HttpDsl extends HttpDslMethods {}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L94)

### HttpMethod (type alias)

HTTP methods recognized by the compiler.

**Example**

```ts
const method: HttpMethod = "GET";
```

**Signature**

```ts
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "ALL";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L11)

### HttpRequestContentType (type alias)

Supported explicit request content types.

**Example**

```ts
const accept: HttpRequestContentType = "application/json";
```

**Signature**

```ts
type HttpRequestContentType = "application/json" | "multipart/form-data";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L15)

### HttpResponseMapping (interface)

Serializable response status and schema mapping.

**Example**

```ts
const response: HttpResponseMapping = http.success(200);
```

**Signature**

```ts
export interface HttpResponseMapping {
  readonly kind: "success" | "error" | "validation-error" | "response";
  readonly id: string;
  readonly status: number;
  readonly errorId?: string;
  readonly schema?: StandardSchemaV1;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L65)

### HttpTransformDescriptor (interface)

Frozen authoring descriptor for a transform.

**Example**

```ts
type Upper = HttpTransformDescriptor<"text.upper", typeof schema>;
```

**Signature**

```ts
export interface HttpTransformDescriptor<
  Id extends string,
  Schema extends StandardSchemaV1,
> extends HttpTransformRef<Id, Schema> {
  readonly kind: "transform";
  readonly id: Id;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L36)

### HttpTransformRef (interface)

Transform reference paired with its output schema.

**Example**

```ts
const ref: HttpTransformRef = { ref: transform.ref, schema: transform.schema };
```

**Signature**

```ts
export interface HttpTransformRef<
  Id extends string = string,
  Schema extends StandardSchemaV1 = StandardSchemaV1,
> {
  readonly ref: TransformReference<Id>;
  readonly schema: Schema;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L26)

### MiddlewareDecisionMapping (type alias)

Union of middleware response decisions.

**Example**

```ts
const decision: MiddlewareDecisionMapping = http.continue();
```

**Signature**

```ts
type MiddlewareDecisionMapping = ContinueMapping | RespondMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L89)

### RespondMapping (interface)

Middleware decision selecting a response mapping.

**Example**

```ts
const decision: RespondMapping = http.respond("success.200");
```

**Signature**

```ts
export interface RespondMapping {
  readonly kind: "respond";
  readonly responseId: string;
  readonly body?: HttpMappingNode;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L81)

### TransformOutput (type alias)

Output type inferred from a transform schema.

**Example**

```ts
type Output = TransformOutput<typeof transform>;
```

**Signature**

```ts
type TransformOutput<T> = T extends { readonly schema: infer Schema }
  ? Schema extends StandardSchemaV1
    ? InferOutput<Schema>
    : unknown
  : unknown;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L46)

### TransformReference (interface)

Stable serializable transform identity.

**Example**

```ts
const ref: TransformReference = { kind: "transform", id: "text.upper" };
```

**Signature**

```ts
export interface TransformReference<Id extends string = string> {
  readonly kind: "transform";
  readonly id: Id;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-dsl.types.ts#L19)

## `http-mapping.types.ts`

### HttpBodyMapping (interface)

One named field from a request body.

**Example**

```ts
const mapping: HttpBodyMapping = http.body("name");
```

**Signature**

```ts
export interface HttpBodyMapping<Output = unknown> extends HttpMapping<Output> {
  readonly kind: "body";
  readonly name: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L61)

### HttpConstantMapping (interface)

A serializable constant input.

**Example**

```ts
const mapping: HttpConstantMapping<string> = http.constant("all");
```

**Signature**

```ts
export interface HttpConstantMapping<
  Output extends JsonValue = JsonValue,
> extends HttpMapping<Output> {
  readonly kind: "constant";
  readonly value: Output;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L90)

### HttpCookieMapping (interface)

One named request cookie.

**Example**

```ts
const mapping: HttpCookieMapping = http.cookie("session");
```

**Signature**

```ts
export interface HttpCookieMapping<Output = string> extends HttpMapping<Output> {
  readonly kind: "cookie";
  readonly name: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L54)

### HttpDefaultMapping (interface)

A source mapping with a serializable fallback.

**Example**

```ts
const mapping: HttpDefaultMapping = http.default(http.query("page"), "1");
```

**Signature**

```ts
export interface HttpDefaultMapping<
  M extends HttpMappingNode = HttpMappingNode,
  Default extends JsonValue = JsonValue,
> extends HttpMapping<Exclude<HttpMappingOutput<M>, undefined> | Default> {
  readonly kind: "default";
  readonly value: M;
  readonly default: Default;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L126)

### HttpHeaderMapping (interface)

One named request header.

**Example**

```ts
const mapping: HttpHeaderMapping = http.header("authorization");
```

**Signature**

```ts
export interface HttpHeaderMapping<Output = string> extends HttpMapping<Output> {
  readonly kind: "header";
  readonly name: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L47)

### HttpInputMapping (interface)

The root request input assembled from field mappings.

**Example**

```ts
const mapping: HttpInputMapping = http.input({ id: http.path("id") });
```

**Signature**

```ts
export interface HttpInputMapping<
  S extends HttpMappingShape = HttpMappingShape,
> extends HttpMapping<MappingShapeOutput<S>> {
  readonly kind: "input";
  readonly fields: S;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L108)

### HttpMapping (interface)

Base phantom output contract for every HTTP mapping.

**Example**

```ts
const mapping: HttpMapping<string> = http.path("id");
```

**Signature**

```ts
export interface HttpMapping<Output = unknown> {
  readonly __output?: Output;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L6)

### HttpMappingNode (type alias)

Union of supported serializable request mapping nodes.

**Example**

```ts
const mapping: HttpMappingNode = http.path("id");
```

**Signature**

```ts
type HttpMappingNode =
  | HttpPathMapping
  | HttpPathSegmentsMapping
  | HttpQueryMapping
  | HttpHeaderMapping
  | HttpCookieMapping
  | HttpBodyMapping
  | HttpWholeBodyMapping
  | HttpMultipartMapping
  | HttpMultipartAllMapping
  | HttpConstantMapping
  | HttpInputMapping
  | HttpNestedMapping
  | HttpOptionalMapping
  | HttpDefaultMapping
  | HttpTransformMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L145)

### HttpMappingOutput (type alias)

Output value inferred from one mapping node.

**Example**

```ts
type Output = HttpMappingOutput<HttpPathMapping>;
```

**Signature**

```ts
type HttpMappingOutput<M> = M extends HttpMapping<infer Output> ? Output : never;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L22)

### HttpMappingShape (type alias)

Named fields in a nested or request input mapping.

**Example**

```ts
const fields: HttpMappingShape = { id: http.path("id") };
```

**Signature**

```ts
type HttpMappingShape = Readonly<Record<string, HttpMappingNode>>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L12)

### HttpMultipartAllMapping (interface)

All values of a multipart form field.

**Example**

```ts
const mapping: HttpMultipartAllMapping = http.multipartAll("files");
```

**Signature**

```ts
export interface HttpMultipartAllMapping<
  Output = readonly (string | File)[],
> extends HttpMapping<Output> {
  readonly kind: "multipart-all";
  readonly name: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L81)

### HttpMultipartMapping (interface)

One multipart form field.

**Example**

```ts
const mapping: HttpMultipartMapping = http.multipart("photo");
```

**Signature**

```ts
export interface HttpMultipartMapping<Output = string | File> extends HttpMapping<Output> {
  readonly kind: "multipart";
  readonly name: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L74)

### HttpNestedMapping (interface)

A nested object assembled from field mappings.

**Example**

```ts
const mapping: HttpNestedMapping = http.nested({ id: http.path("id") });
```

**Signature**

```ts
export interface HttpNestedMapping<
  S extends HttpMappingShape = HttpMappingShape,
> extends HttpMapping<MappingShapeOutput<S>> {
  readonly kind: "nested";
  readonly fields: S;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L99)

### HttpOptionalMapping (interface)

A source mapping whose absence is allowed.

**Example**

```ts
const mapping: HttpOptionalMapping = http.optional(http.query("page"));
```

**Signature**

```ts
export interface HttpOptionalMapping<
  M extends HttpMappingNode = HttpMappingNode,
> extends HttpMapping<HttpMappingOutput<M> | undefined> {
  readonly kind: "optional";
  readonly value: M;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L117)

### HttpPathMapping (interface)

One named route path parameter.

**Example**

```ts
const mapping: HttpPathMapping = http.path("id");
```

**Signature**

```ts
export interface HttpPathMapping<Output = string> extends HttpMapping<Output> {
  readonly kind: "path";
  readonly name: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L26)

### HttpPathSegmentsMapping (interface)

All segments captured by a route path parameter.

**Example**

```ts
const mapping: HttpPathSegmentsMapping = http.pathSegments("parts");
```

**Signature**

```ts
export interface HttpPathSegmentsMapping<Output = readonly string[]> extends HttpMapping<Output> {
  readonly kind: "path-segments";
  readonly name: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L33)

### HttpQueryMapping (interface)

One named query parameter.

**Example**

```ts
const mapping: HttpQueryMapping = http.query("page");
```

**Signature**

```ts
export interface HttpQueryMapping<Output = string> extends HttpMapping<Output> {
  readonly kind: "query";
  readonly name: string;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L40)

### HttpRequestMapping (type alias)

The required root shape for explicit request mapping.

**Example**

```ts
const mapping: HttpRequestMapping = http.input({ id: http.path("id") });
```

**Signature**

```ts
type HttpRequestMapping = HttpInputMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L164)

### HttpSourceOptions (interface)

Optionality and fallback options for one request source.

**Example**

```ts
const options: HttpSourceOptions = { optional: true };
```

**Signature**

```ts
export interface HttpSourceOptions {
  readonly optional?: boolean;
  readonly default?: JsonValue;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L168)

### HttpTransformMapping (interface)

A value transformed by a registered transform ID.

**Example**

```ts
const mapping: HttpTransformMapping = http.transform("upper", http.body("name"));
```

**Signature**

```ts
export interface HttpTransformMapping<Output = unknown> extends HttpMapping<Output> {
  readonly kind: "transform";
  readonly transformId: string;
  readonly value: HttpMappingNode;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L137)

### HttpWholeBodyMapping (interface)

The complete request body.

**Example**

```ts
const mapping: HttpWholeBodyMapping = http.wholeBody();
```

**Signature**

```ts
export interface HttpWholeBodyMapping<Output = unknown> extends HttpMapping<Output> {
  readonly kind: "whole-body";
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L68)

### MappingShapeOutput (type alias)

Output shape inferred from named mapping fields.

**Example**

```ts
type Output = MappingShapeOutput<{ id: HttpPathMapping }>;
```

**Signature**

```ts
type MappingShapeOutput<S extends HttpMappingShape> = {
  readonly [K in keyof S]: HttpMappingOutput<S[K]>;
};
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/http-mapping.types.ts#L16)

## `index.ts`

### "./define-middleware.js" (namespace export)

Re-exports all named exports from the "./define-middleware.js" module.

**Signature**

```ts
export * from "./define-middleware.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L2)

### "./define-route.js" (namespace export)

Re-exports all named exports from the "./define-route.js" module.

**Signature**

```ts
export * from "./define-route.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L3)

### "./define-service-routes.js" (namespace export)

Re-exports all named exports from the "./define-service-routes.js" module.

**Signature**

```ts
export * from "./define-service-routes.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L4)

### "./http-dsl.js" (namespace export)

Re-exports all named exports from the "./http-dsl.js" module.

**Signature**

```ts
export * from "./http-dsl.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L1)

### "./route-module.types.js" (namespace export)

Re-exports all named exports from the "./route-module.types.js" module.

**Signature**

```ts
export * from "./route-module.types.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L13)

### "./route.types.js" (namespace export)

Re-exports all named exports from the "./route.types.js" module.

**Signature**

```ts
export * from "./route.types.js";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L12)

### HttpRateLimitKey

**Signature**

```ts
declare const HttpRateLimitKey: HttpRateLimitKey;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L14)

### RouteInputError

**Signature**

```ts
declare const RouteInputError: typeof RouteInputError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L6)

### RouteOperation

**Signature**

```ts
declare const RouteOperation: RouteOperation;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L11)

### RouteOperationError

**Signature**

```ts
declare const RouteOperationError: typeof RouteOperationError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L7)

### RouteRateLimit

**Signature**

```ts
declare const RouteRateLimit: RouteRateLimit;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L14)

### RouteTelemetry

**Signature**

```ts
declare const RouteTelemetry: typeof RouteTelemetry;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L8)

### RouteTelemetryLive

**Signature**

```ts
declare const RouteTelemetryLive: Layer<RouteTelemetry, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L9)

### RouteTelemetryService

**Signature**

```ts
declare const RouteTelemetryService: RouteTelemetryService;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/index.ts#L11)

## `route-auth.ts`

### BetterAuthRegistration

**Signature**

```ts
declare const BetterAuthRegistration: BetterAuthRegistration;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-auth.ts#L6)

### copyProtectedPaths

Validates and copies protected route patterns synchronously.

**Throws**

TypeError for invalid patterns.

**Example**

```ts
copyProtectedPaths(["/admin/*"]);
```

**Signature**

```ts
declare const copyProtectedPaths: (values: readonly string[] | undefined) => readonly string[];
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-auth.ts#L67)

### copyProtectedPathsEffect

Validates and copies protected paths through Effect.

**Example**

```ts
Effect.runSync(copyProtectedPathsEffect(["/admin/*"]));
```

**Signature**

```ts
declare const copyProtectedPathsEffect: (
  values: ReadonlyArray<string> | undefined,
) => Effect.Effect<ReadonlyArray<string>, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-auth.ts#L56)

### copyProtectedValues

Copies protected paths inside an already observed operation.

**Throws**

RouteInputError for an invalid pattern.

**Example**

```ts
copyProtectedValues(["/admin/*"]);
```

**Signature**

```ts
declare const copyProtectedValues: (values: readonly string[] | undefined) => readonly string[];
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-auth.ts#L77)

### readBetterAuthRegistration

Reads a Better Auth handler registration synchronously.

**Throws**

TypeError for malformed handler input.

**Example**

```ts
readBetterAuthRegistration(handler);
```

**Signature**

```ts
declare const readBetterAuthRegistration: (
  handler: RawRouteOptions<string>["handler"],
) => BetterAuthRegistration | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-auth.ts#L24)

### readBetterAuthRegistrationEffect

Reads a Better Auth handler registration through Effect.

**Example**

```ts
Effect.runSync(readBetterAuthRegistrationEffect(handler));
```

**Signature**

```ts
declare const readBetterAuthRegistrationEffect: (
  handler: RawHttpHandler,
) => Effect.Effect<BetterAuthRegistration | undefined, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-auth.ts#L13)

### readRegistrationValue

Reads registration metadata inside an already observed operation.

**Example**

```ts
readRegistrationValue(handler);
```

**Signature**

```ts
declare const readRegistrationValue: (
  handler: RawRouteOptions<string>["handler"],
) => BetterAuthRegistration | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-auth.ts#L35)

## `route-auth.types.ts`

Better Auth identity attached to a raw handler.

**Example**

```ts
const registration: BetterAuthRegistration = {
  kind: "better-auth",
  service: { ref: { kind: "service", id: "auth" } },
};
```

### BetterAuthRegistration (interface)

Better Auth identity attached to a raw handler.

**Example**

```ts
const registration: BetterAuthRegistration = {
  kind: "better-auth",
  service: { ref: { kind: "service", id: "auth" } },
};
```

**Signature**

```ts
export interface BetterAuthRegistration {
  readonly kind: "better-auth";
  readonly service: { readonly ref: { readonly kind: "service"; readonly id: string } };
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-auth.types.ts#L4)

## `route-client.ts`

### copyClient

Copies a client policy for synchronous authoring.

**Throws**

TypeError when the policy is invalid.

**Example**

```ts
copyClient({ operation: "query" });
```

**Signature**

```ts
declare const copyClient: (value: unknown) => RouteClientPolicy | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-client.ts#L22)

### copyClientEffect

Copies a client policy through a typed Effect.

**Example**

```ts
Effect.runSync(copyClientEffect({ operation: "query" }));
```

**Signature**

```ts
declare const copyClientEffect: (
  value: unknown,
) => Effect.Effect<RouteClientPolicy | undefined, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-client.ts#L12)

### copyClientValue

Copies client policy inside an already observed operation.

**Throws**

RouteInputError for an invalid policy.

**Example**

```ts
copyClientValue({ operation: "query" });
```

**Signature**

```ts
declare const copyClientValue: (value: unknown) => RouteClientPolicy | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-client.ts#L32)

### copyStream

Copies a native stream policy for synchronous authoring.

**Throws**

TypeError when the policy or output schema is incompatible.

**Example**

```ts
copyStream(undefined, output);
```

**Signature**

```ts
declare const copyStream: (
  value: unknown,
  output: StandardSchemaV1,
) => { readonly format: NativeStreamFormat } | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-client.ts#L65)

### copyStreamEffect

Copies a native stream policy through a typed Effect.

**Example**

```ts
Effect.runSync(copyStreamEffect(undefined, output));
```

**Signature**

```ts
declare const copyStreamEffect: (
  value: unknown,
  output: StandardSchemaV1<unknown, unknown>,
) => Effect.Effect<{ readonly format: NativeStreamFormat } | undefined, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-client.ts#L53)

### copyStreamValue

Copies stream policy inside an already observed operation.

**Throws**

RouteInputError for invalid stream settings.

**Example**

```ts
copyStreamValue({ format: "sse" }, streamOutput);
```

**Signature**

```ts
declare const copyStreamValue: (
  value: unknown,
  output: StandardSchemaV1,
) => { readonly format: NativeStreamFormat } | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-client.ts#L79)

## `route-definition.ts`

### prepareRouteValue

Validates route options before acquiring an unbound identity.

**Throws**

RouteInputError for invalid route inputs.

**Example**

```ts
prepareRouteValue({ target })("orders.get");
```

**Signature**

```ts
declare const prepareRouteValue: (
  options:
    | FunctionRouteOptions<string, FunctionRefAny, HttpRequestMapping | undefined>
    | RawRouteOptions<string>,
) => (id: string) => RouteDescriptor<string>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-definition.ts#L30)

## `route-module.types.ts`

### RouteModuleContract (type alias)

Expected types for a route module's exports, used by generated module validators.
Rejects untyped exports and requires at least one named HTTP method.

**Signature**

```ts
type RouteModuleContract<Module, Parameters extends string = never> = keyof Module extends never
  ? { readonly __relkit_route_method_required: never }
  : {
      readonly [Method in keyof Module]: Method extends RouteModuleMethod
        ? CheckedRoute<Module[Method], Method, Parameters>
        : never;
    };
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-module.types.ts#L29)

### RouteModuleMethod (type alias)

Value exports accepted by a filesystem route module.

**Signature**

```ts
type RouteModuleMethod = ServiceRouteMethod | "ALL";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-module.types.ts#L6)

## `route-observability.ts`

### RouteInputError (class)

Marks invalid route authoring input while preserving TypeError compatibility.

**Example**

```ts
throw new RouteInputError("Route target is invalid");
```

**Signature**

```ts
declare class RouteInputError
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L11)

### RouteOperation

**Signature**

```ts
declare const RouteOperation: RouteOperation;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L6)

### RouteOperationError (class)

Expected failure from a route authoring Effect.

**Example**

```ts
const error = new RouteOperationError({
  operation: "route.define",
  reason: "Invalid route",
  cause: new TypeError("Invalid route"),
});
```

**Signature**

```ts
declare class RouteOperationError
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L16)

### RouteTelemetry (class)

Injectable observer for route authoring operations.

**Example**

```ts
Effect.provide(defineRouteEffect(options), RouteTelemetryLive);
```

**Signature**

```ts
declare class RouteTelemetry
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L24)

### RouteTelemetryLive

Default route observer with an Effect span, counters, and duration histogram.

**Example**

```ts
Effect.runSync(Effect.provide(Effect.void, RouteTelemetryLive));
```

**Signature**

```ts
declare const RouteTelemetryLive: Layer.Layer<RouteTelemetry, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L37)

### RouteTelemetryService

**Signature**

```ts
declare const RouteTelemetryService: RouteTelemetryService;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L6)

### measureRoute

Records route metrics without creating a second span inside named Effect functions.

**Example**

```ts
measureRoute("route.define", Effect.succeed(route));
```

**Signature**

```ts
declare const measureRoute: <A, E, R>(
  operation: RouteOperation,
  effect: Effect.Effect<A, E, R>,
) => Effect.Effect<A, E, R>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L58)

### observeRoute

Observes a route operation with an injectable test observer.

**Example**

```ts
observeRoute("route.define", Effect.succeed(route));
```

**Signature**

```ts
declare const observeRoute: <A, E, R>(
  operation: RouteOperation,
  effect: Effect.Effect<A, E, R>,
) => Effect.Effect<A, E, R>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L45)

### routeAttempt

Evaluates a calculation inside an already observed route operation.

**Example**

```ts
yield * routeAttempt("route.define", () => descriptor);
```

**Signature**

```ts
declare const routeAttempt: <A>(
  operation: RouteOperation,
  evaluate: () => A,
) => Effect.Effect<A, RouteOperationError>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L107)

### routeIdentity

Acquires an unbound route identity through the caller's IdentityStore Layer.

**Example**

```ts
yield * routeIdentity("middleware.define");
```

**Signature**

```ts
declare const routeIdentity: (
  operation: RouteOperation,
) => Effect.Effect<string, RouteOperationError>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L128)

### routeTry

Evaluates synchronous authoring logic inside a typed and observed Effect.

**Example**

```ts
routeTry("route.define", () => descriptor);
```

**Signature**

```ts
declare const routeTry: <A>(
  operation: RouteOperation,
  evaluate: () => A,
) => Effect.Effect<A, RouteOperationError>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L94)

### runRouteSync

Runs a synchronous compatibility API and restores its original error.

**Throws**

The original validation error or an unexpected defect.

**Example**

```ts
runRouteSync(Effect.succeed(true));
```

**Signature**

```ts
declare const runRouteSync: <A, E>(effect: Effect.Effect<A, E>) => A;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.ts#L149)

## `route-observability.types.ts`

### RouteOperation (type alias)

Bounded name for a route authoring operation.

**Example**

```ts
const operation: RouteOperation = "route.define";
```

**Signature**

```ts
type RouteOperation =
  | "middleware.define"
  | "middleware.is-descriptor"
  | "middleware.is-path"
  | "route.define"
  | "service-routes.define"
  | "auth.read-registration"
  | "auth.copy-protected"
  | "client.copy"
  | "stream.copy"
  | "options.copy-rate-limit"
  | "options.positive"
  | "options.success-status"
  | "dsl.define-transform"
  | "dsl.is-transform-ref"
  | "dsl.input"
  | "dsl.nested"
  | "dsl.source"
  | "dsl.whole-body"
  | "dsl.constant"
  | "dsl.optional"
  | "dsl.default"
  | "dsl.transform"
  | "dsl.response"
  | "dsl.continue"
  | "dsl.respond"
  | "validation.is-mapping"
  | "validation.assert-mapping"
  | "validation.is-request"
  | "validation.assert-request"
  | "validation.is-response"
  | "validation.assert-response"
  | "validation.is-decision"
  | "validation.is-schema"
  | "validation.assert-schema"
  | "validation.is-status"
  | "validation.is-record";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.types.ts#L6)

### RouteTelemetryService (interface)

Replaceable observer for route operations.

**Example**

```ts
const telemetry: RouteTelemetryService = { observe: (_operation, effect) => effect };
```

**Signature**

```ts
export interface RouteTelemetryService {
  /**
   * Measures an operation without changing its success or failure channel.
   * @param operation - Fixed route operation name.
   * @param effect - Work to observe.
   * @returns The observed Effect with unchanged channels.
   * @example telemetry.observe("route.define", Effect.succeed(route));
   */
  readonly observe: <A, E, R>(
    operation: RouteOperation,
    effect: Effect.Effect<A, E, R>,
  ) => Effect.Effect<A, E, R>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-observability.types.ts#L47)

## `route-options.ts`

### HttpRateLimitKey

**Signature**

```ts
declare const HttpRateLimitKey: HttpRateLimitKey;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L8)

### RouteRateLimit

**Signature**

```ts
declare const RouteRateLimit: RouteRateLimit;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L8)

### copyRateLimit

Copies a route rate-limit policy synchronously.

**Throws**

TypeError for invalid policy fields.

**Example**

```ts
copyRateLimit(undefined);
```

**Signature**

```ts
declare const copyRateLimit: (value: RouteRateLimit | undefined) => RouteRateLimit | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L26)

### copyRateLimitEffect

Copies a rate-limit policy through Effect.

**Example**

```ts
Effect.runSync(copyRateLimitEffect(undefined));
```

**Signature**

```ts
declare const copyRateLimitEffect: (
  value: RouteRateLimit | undefined,
) => Effect.Effect<RouteRateLimit | undefined, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L15)

### copyRateLimitValue

Copies a rate limit inside an already observed operation.

**Throws**

RouteInputError for invalid policy fields.

**Example**

```ts
copyRateLimitValue(undefined);
```

**Signature**

```ts
declare const copyRateLimitValue: (value: RouteRateLimit | undefined) => RouteRateLimit | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L36)

### positive

Validates an optional positive integer synchronously.

**Throws**

TypeError for nonpositive or unsafe integers.

**Example**

```ts
positive(5, "timeoutMs");
```

**Signature**

```ts
declare const positive: (value: number | undefined, name: string) => number | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L75)

### positiveEffect

Validates an optional positive integer through Effect.

**Example**

```ts
Effect.runSync(positiveEffect(5, "timeoutMs"));
```

**Signature**

```ts
declare const positiveEffect: (
  value: number | undefined,
  name: string,
) => Effect.Effect<number | undefined, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L63)

### positiveValue

Checks an optional positive integer inside an already observed operation.

**Throws**

RouteInputError for invalid integers.

**Example**

```ts
positiveValue(5, "timeoutMs");
```

**Signature**

```ts
declare const positiveValue: (value: number | undefined, name: string) => number | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L86)

### successStatus

Validates an optional HTTP success status synchronously.

**Throws**

TypeError for values outside 200–299.

**Example**

```ts
successStatus(201);
```

**Signature**

```ts
declare const successStatus: (value: number | undefined) => number | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L109)

### successStatusEffect

Validates a success status through Effect.

**Example**

```ts
Effect.runSync(successStatusEffect(201));
```

**Signature**

```ts
declare const successStatusEffect: (
  value: number | undefined,
) => Effect.Effect<number | undefined, RouteOperationError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L98)

### successStatusValue

Checks an optional success status inside an already observed operation.

**Throws**

RouteInputError for invalid statuses.

**Example**

```ts
successStatusValue(201);
```

**Signature**

```ts
declare const successStatusValue: (value: number | undefined) => number | undefined;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.ts#L119)

## `route-options.types.ts`

### HttpRateLimitKey (type alias)

Scalar request source used for rate-limit keys.

**Example**

```ts
const key: HttpRateLimitKey = http.header("x-api-key");
```

**Signature**

```ts
type HttpRateLimitKey =
  HttpPathMapping | HttpQueryMapping | HttpHeaderMapping | HttpCookieMapping | HttpConstantMapping;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.types.ts#L13)

### RouteRateLimit (interface)

Immutable per-route rate-limit policy.

**Example**

```ts
const policy: RouteRateLimit = { limit: 10, windowMs: 60_000, key: http.header("x-api-key") };
```

**Signature**

```ts
export interface RouteRateLimit {
  readonly limit: number;
  readonly windowMs: number;
  readonly key: HttpRateLimitKey;
  readonly store?: CacheRefAny;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route-options.types.ts#L19)

## `route.types.ts`

### FunctionRouteDescriptor (interface)

Frozen descriptor for a function-backed route.

**Example**

```ts
type Route = FunctionRouteDescriptor<"orders.get">;
```

**Signature**

```ts
export interface FunctionRouteDescriptor<
  Id extends string,
  Target extends FunctionRefAny = FunctionRefAny,
  Request extends HttpRequestMapping | undefined = HttpRequestMapping | undefined,
> extends DescriptorBase<"route", Id> {
  readonly method?: HttpMethod;
  readonly path?: string;
  readonly runtimePaths?: readonly string[];
  readonly target: Target;
  readonly accept?: HttpRequestContentType;
  readonly request?: Request;
  readonly responses?: readonly HttpResponseMapping[];
  readonly successStatus?: number;
  readonly maxBodyBytes?: number;
  readonly rateLimit?: RouteRateLimit;
  readonly timeoutMs?: number;
  readonly client?: RouteClientPolicy;
  readonly stream?: { readonly format: NativeStreamFormat };
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route.types.ts#L66)

### FunctionRouteOptions (interface)

Authoring options for a function-backed route.

**Example**

```ts
type Options = FunctionRouteOptions<"orders.get", typeof getOrder>;
```

**Signature**

```ts
export interface FunctionRouteOptions<
  Id extends string,
  Target extends FunctionRefAny,
  Request extends HttpRequestMapping | undefined = undefined,
> extends RouteSharedOptions<Id> {
  readonly target: Target;
  readonly handler?: never;
  readonly accept?: HttpRequestContentType;
  readonly request?: Request;
  readonly responses?: readonly HttpResponseMapping[];
  readonly successStatus?: number;
  readonly maxBodyBytes?: number;
  readonly rateLimit?: RouteRateLimit;
  readonly timeoutMs?: number;
  readonly client?: RouteClientPolicy;
  readonly stream?: { readonly format: NativeStreamFormat };
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route.types.ts#L31)

### NativeStreamFormat (type alias)

Native streaming transport formats.

**Example**

```ts
const format: NativeStreamFormat = "sse";
```

**Signature**

```ts
type NativeStreamFormat = "sse" | "text" | "bytes";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route.types.ts#L22)

### RawHttpHandler (type alias)

A raw HTTP handler receiving the incoming Request.

**Example**

```ts
const handler: RawHttpHandler = () => new Response("ok");
```

**Signature**

```ts
type RawHttpHandler = (request: Request) => MaybePromise<Response>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route.types.ts#L14)

### RawRouteDescriptor (interface)

Frozen descriptor for a raw HTTP route.

**Example**

```ts
type Route = RawRouteDescriptor<"health">;
```

**Signature**

```ts
export interface RawRouteDescriptor<
  Id extends string,
  Handler extends RawHttpHandler = RawHttpHandler,
> extends DescriptorBase<"route", Id> {
  readonly method?: HttpMethod;
  readonly path?: string;
  readonly runtimePaths?: readonly string[];
  readonly raw: true;
  readonly handler: Handler;
  readonly auth?: {
    readonly kind: "better-auth";
    readonly protected: readonly string[];
    readonly service: { readonly ref: { readonly kind: "service"; readonly id: string } };
  };
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route.types.ts#L89)

### RawRouteOptions (interface)

Authoring options for a raw HTTP route.

**Example**

```ts
const options: RawRouteOptions<"health"> = { handler: () => new Response("ok") };
```

**Signature**

```ts
export interface RawRouteOptions<
  Id extends string,
  Handler extends RawHttpHandler = RawHttpHandler,
> extends RouteSharedOptions<Id> {
  readonly handler: Handler;
  readonly target?: never;
  readonly auth?: {
    readonly protected?: readonly string[];
  };
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route.types.ts#L52)

### RouteClientPolicy (type alias)

Client exposure and operation policy for a route.

**Example**

```ts
const policy: RouteClientPolicy = { operation: "query" };
```

**Signature**

```ts
type RouteClientPolicy = false | { readonly operation?: "query" | "mutation" };
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route.types.ts#L18)

### RouteDescriptor (type alias)

Union of function-backed and raw route descriptors.

**Example**

```ts
type Route = RouteDescriptor<"orders.get">;
```

**Signature**

```ts
type RouteDescriptor<
  Id extends string,
  Target extends FunctionRefAny = FunctionRefAny,
  Request extends HttpRequestMapping | undefined = HttpRequestMapping | undefined,
> = FunctionRouteDescriptor<Id, Target, Request> | RawRouteDescriptor<Id>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/routes/src/route.types.ts#L108)
