mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-17 08:37:59 +00:00

* feat: integrate ts-rest * chore: classify core contract and pro contract * chore: update lockfile * chore: tweak dir structure * chore: tweak dir structure
22 lines
586 B
TypeScript
22 lines
586 B
TypeScript
import { proContract } from './contracts';
|
|
import { createNextRoute, createNextRouter } from '@ts-rest/next';
|
|
|
|
/**
|
|
* 创建 Pro 单个路由
|
|
*/
|
|
export function createProServerRoute(
|
|
implementation: Parameters<typeof createNextRoute<typeof proContract>>[1]
|
|
) {
|
|
return createNextRoute(proContract, implementation);
|
|
}
|
|
|
|
/**
|
|
* 创建 Pro 路由器
|
|
* 只需实现 Pro 接口(路径已自动转换 /proApi → 空)
|
|
*/
|
|
export function createProServerRouter(
|
|
router: Parameters<typeof createNextRouter<typeof proContract>>[1]
|
|
) {
|
|
return createNextRouter(proContract, router);
|
|
}
|