Restaq
Reference

restaq

The main Restaq runtime package with restaq() and re-exports of core types.

Install

pnpm add restaq

Exports

ExportKindDescription
restaqFunctionConvenience wrapper around createRelayEngine that returns a typed relay runtime.
NormalizedEventTypeRe-exported from @restaq/core.
StepStatusTypeRe-exported from @restaq/core.
ExecutionStepTypeRe-exported from @restaq/core.
LogLevelTypeRe-exported from @restaq/core.
LogSourceTypeRe-exported from @restaq/core.
ExecutionLogTypeRe-exported from @restaq/core.
RuntimeContextTypeRe-exported from @restaq/core.
EventHandlerTypeRe-exported from @restaq/core.
ExecutionStatusTypeRe-exported from @restaq/core.
ExecutionTypeRe-exported from @restaq/core.
ExecutionStoreTypeRe-exported from @restaq/core.
RelayPluginTypeRe-exported from @restaq/core.
EventMapOfTypeRe-exported from @restaq/core.
RelayHandlerContextTypeRe-exported from @restaq/core.
RelayTypeRe-exported from @restaq/core.
RetryPolicyTypeRe-exported from @restaq/core.
RelayConfigTypeRe-exported from @restaq/core.
toNextJsHandlerFunctionExported from restaq/next-js; adapts a relay to a Next.js App Router route handler.
toExpressHandlerFunctionExported from restaq/express; adapts a relay to an Express route handler.
toHonoHandlerFunctionExported from restaq/hono; adapts a relay to a Hono handler.
toNestJsHandlerFunctionExported from restaq/nestjs; adapts a relay to a NestJS controller method.

Functions

restaq

function restaq<const TPlugins extends readonly RelayPlugin<any>[] = []>(
  config: RelayConfig<TPlugins>,
): Relay<EventMapOf<TPlugins>>;

Creates a Restaq runtime instance. This is the main entry point for developers: register event handlers via restaq.on(), receive provider webhooks through restaq.handler, and configure persistence via config.database — a Postgres/SQLite/MySQL client (auto-detected), a { dialect } Kysely escape hatch, or a custom ExecutionStore. The relay's event types are inferred from the plugins you register—typed plugins make restaq.on() autocomplete event names and narrow event payloads.

restaq/next-js

Next.js support is a subpath export of this package — no separate install.

ExportKindDescription
toNextJsHandlerFunctionAdapts a relay to a Next.js App Router catch-all route handler.
function toNextJsHandler<TEventMap extends Record<string, unknown>>(
  relay: Relay<TEventMap>,
): {
  POST: (req: Request, ctx: { params: Promise<{ all: string[] }> }) => Promise<Response>;
};

Adapts a relay instance to a Next.js App Router catch-all route. Returns an object with a POST handler that integrates the relay's webhook handler. Uses only web-standard Request/Response plus Next.js's promise-shaped route params—no import from 'next' is required.

// app/api/webhook/[...all]/route.ts
import { toNextJsHandler } from 'restaq/next-js';
import { restaq } from '@/relay';

export const { POST } = toNextJsHandler(restaq);

Provider webhooks are then received at /api/webhook/<provider> (e.g., /api/webhook/stripe).

Other framework adapters

Express, Hono, and NestJS support are subpath exports of this package — no separate installs.

import { toExpressHandler } from 'restaq/express';
import { toHonoHandler } from 'restaq/hono';
import { toNestJsHandler } from 'restaq/nestjs';

See the framework guides for setup examples and raw-body notes.

See also

On this page