Skip to content

API reference / @chanx-js/server / core / asyncapiHandler

Function: asyncapiHandler() ​

ts
function asyncapiHandler(chanx, __namedParameters?): AsyncAPIHandler;

Defined in: packages/server/src/asyncapi-http.ts:35

Serve the AsyncAPI document as chanx does: a docs page at /asyncapi, the document at /asyncapi.json and /asyncapi.yaml. The server's host and protocol default to the request's. YAML needs the yaml package.

ts
const asyncapi = asyncapiHandler(chanx, { title: 'Chat API' });
app.get('/asyncapi*', async (c, next) => (await asyncapi(c.req.raw)) ?? next());

Parameters ​

ParameterType
chanxChanx
__namedParametersAsyncAPIServeOptions

Returns ​

AsyncAPIHandler

MIT licensed