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,
): TfnKey must be unique; duplicates throw at registration time.
CatFunctionOptions
| Field | Type | Description |
|---|---|---|
method | string? | HTTP method when route is set (default GET). |
route | string? | When set, forces mode: 'api' and sets route / httpMethod on the entry. |
params | RegistryParam[]? | Manual parameter list (names + types). Overrides the default unknown types when you are not using an AST merge. |
declaredReturn | string? | Manual return type string for the catalog. |
paramsJsonSchema | Record<string, unknown>? | Tuple-style JSON Schema for the positional args array when params schema validation is enabled (Validation). |
returnJsonSchema | Record<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
catModule— batch register{ methodName: fn }under one module prefix.- AST type expansion — backfill
params/declaredReturnfrom source afterbootstrap.