/** * Copyright (c) 2026 AzerothJS. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /** * Installing declared features on the HTTP app. * * `register(app, { keys, orgs })` walks each feature's declarations and installs one endpoint * per route with the guard chain and validation AT the boundary, so a handler's `input`/`query` * are exactly their schemas' types or the request never reaches it: * * - input/query failures throw the HTTP layer's ValidationError - the 422 whose * `details.fields` is the flat field-path map the browser form's setError consumes. * One schema, both sides: the same rules that validated the form client-side reject * the forged request server-side, in the same shape. * - OUTPUT is validated too, when declared. A handler returning something off-declaration * is a SERVER bug: it maps to a hidden 500 (code 'contract-violation'), never to a * silently wrong payload the client misparses three services later. * - a handler may return a raw Response (redirects, files) and bypass output validation * knowingly - the escape hatch is visible in the return type; `r.raw` routes are that * escape hatch declared as a KIND, guard-covered and spec-visible. * * The record you register is the record you describe and the record you type the client from - * `register` RETURNS it so the value provably flows through: the record key becomes the OpenAPI * tag, the operation-id prefix, and the client namespace, written once. */ import type { App } from '../index.ts'; import type { Feature } from './declare.ts'; /** Options for {@link register}. */ export interface RegisterOptions { /** The path prefix every feature is served under. Default '/api'. */ prefix?: string; } /** * Registers a record of features on the app and returns the SAME record, so the value handed to * `openapiPlugin({ features })` and `typeof`'d by the client is provably the one that was * installed. Route conflicts (two features declaring one method + path) fail at boot through * the router, exactly like any duplicate route. * * ```ts * export const api = register(app, { orgs, keys, webhooks }); * app.register(openapiPlugin({ features: api, info })); * ``` */ export declare function register>(app: App | App, features: Features, options?: RegisterOptions): Features;