orpc-contract-first

orpc-contract-first

Populer

Guide for implementing oRPC contract-first API patterns in Dify frontend. Triggers when creating new API contracts, adding service endpoints, integrating TanStack Query with typed contracts, or migrating legacy service calls to oRPC. Use for all API layer work in web/contract and web/service directories.

127Kbintang
20Kfork
Diperbarui 1/21/2026
SKILL.md
readonlyread-only
name
orpc-contract-first
description

Guide for implementing oRPC contract-first API patterns in Dify frontend. Triggers when creating new API contracts, adding service endpoints, integrating TanStack Query with typed contracts, or migrating legacy service calls to oRPC. Use for all API layer work in web/contract and web/service directories.

oRPC Contract-First Development

Project Structure

web/contract/
├── base.ts           # Base contract (inputStructure: 'detailed')
├── router.ts         # Router composition & type exports
├── marketplace.ts    # Marketplace contracts
└── console/          # Console contracts by domain
    ├── system.ts
    └── billing.ts

Workflow

  1. Create contract in web/contract/console/{domain}.ts

    • Import base from ../base and type from @orpc/contract
    • Define route with path, method, input, output
  2. Register in router at web/contract/router.ts

    • Import directly from domain file (no barrel files)
    • Nest by API prefix: billing: { invoices, bindPartnerStack }
  3. Create hooks in web/service/use-{domain}.ts

    • Use consoleQuery.{group}.{contract}.queryKey() for query keys
    • Use consoleClient.{group}.{contract}() for API calls

Key Rules

  • Input structure: Always use { params, query?, body? } format
  • Path params: Use {paramName} in path, match in params object
  • Router nesting: Group by API prefix (e.g., /billing/*billing: {})
  • No barrel files: Import directly from specific files
  • Types: Import from @/types/, use type<T>() helper

Type Export

export type ConsoleInputs = InferContractRouterInputs<typeof consoleRouterContract>

You Might Also Like

Related Skills

gog

gog

169Kdev-api

Google Workspace CLI for Gmail, Calendar, Drive, Contacts, Sheets, and Docs.

openclaw avataropenclaw
Ambil
weather

weather

169Kdev-api

Get current weather and forecasts (no API key required).

openclaw avataropenclaw
Ambil
blucli

blucli

92Kdev-api

BluOS CLI (blu) for discovery, playback, grouping, and volume.

moltbot avatarmoltbot
Ambil
ordercli

ordercli

92Kdev-api

Foodora-only CLI for checking past orders and active order status (Deliveroo WIP).

moltbot avatarmoltbot
Ambil
gifgrep

gifgrep

92Kdev-api

Search GIF providers with CLI/TUI, download results, and extract stills/sheets.

moltbot avatarmoltbot
Ambil
camsnap

camsnap

92Kdev-api

Capture frames or clips from RTSP/ONVIF cameras.

moltbot avatarmoltbot
Ambil