Skip to Content

cat(fnKey, fn, options?)

Registers a function-style RegistryEntry: style: 'function'. The returned value is a wrapped function you should export or pass to Express so all calls go through the wrapper.

import { cat, Return } from '@gloocan/cat-inspector' export const refund = cat( 'Billing.refund', async (orderId: string, amount: number) => { // … return Return('OK', { orderId, amount }) }, { paramsJsonSchema: { /* tuple-style schema for args */ } }, )

Signature

function cat<T extends (...args: any[]) => any>( fnKey: string, fn: T, options?: CatFunctionOptions, ): T

fnKey must be unique; duplicates throw at registration time.

CatFunctionOptions

FieldTypeDescription
methodstring?HTTP method when route is set (default GET).
routestring?When set, forces mode: 'api' and sets route / httpMethod on the entry.
paramsRegistryParam[]?Manual parameter list (names + types). Overrides the default unknown types when you are not using an AST merge.
declaredReturnstring?Manual return type string for the catalog.
paramsJsonSchemaRecord<string, unknown>?Tuple-style JSON Schema for the positional args array when params schema validation is enabled (Validation).
returnJsonSchemaRecord<string, unknown>?Object JSON Schema for RPC result when return schema validation is enabled (Validation).

Mode detection

If route is not set and the parameter names include both req and res, the registrar treats the function as an Express-shaped handler and sets api_candidate until a pipeline marks the final handler as api. Otherwise the mode is service.

See also