スキル一覧に戻る
langgenius

orpc-contract-first

by langgenius

Difyフロントエンドでのcontract-first API実装ガイド。oRPCパターンを使用した型安全なAPIレイヤー構築を支援します。

126,848🍴 19,786📅 2026年1月23日4 files · 28.7 KB
GitHubで見るManusで実行

ユースケース

🔗

MCPサーバー連携

Model Context Protocolを活用したAIツール連携。orpc-contract-firstを活用。

🤖

ワークフロー自動化

繰り返し作業を自動化し、手動作業を削減。

🚀

CI/CDパイプライン構築

ビルド・テスト・デプロイの自動化パイプラインを構築。

FAQ

ファイル4
28.7 KB
component-refactoring/
references/
SKILL.md14.1 KB
frontend-code-review/
references/
SKILL.md2.8 KB
frontend-testing/
assets/
references/
SKILL.md10.1 KB
orpc-contract-first/
SKILL.md1.7 KB

SKILL.md


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>

スコア

総合スコア

80/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 1000以上

+15
最近の活動

3ヶ月以内に更新

+5
フォーク

10回以上フォークされている

+5
Issue管理

オープンIssueが50未満

0/5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

レビュー

💬

レビュー機能は近日公開予定です