Procházet zdrojové kódy

✨ feat(api): add file routes and client

- 导出FileRoutes类型定义以支持类型检查
- 添加fileClient客户端以提供文件相关API调用能力
yourname před 4 měsíci
rodič
revize
149a181741
2 změnil soubory, kde provedl 7 přidání a 1 odebrání
  1. 6 1
      src/client/api.ts
  2. 1 0
      src/server/api.ts

+ 6 - 1
src/client/api.ts

@@ -1,7 +1,8 @@
 import axios, { isAxiosError } from 'axios';
 import { hc } from 'hono/client'
 import type {
-  AuthRoutes, UserRoutes, RoleRoutes
+  AuthRoutes, UserRoutes, RoleRoutes,
+  FileRoutes
 } from '@/server/api';
 
 // 创建 axios 适配器
@@ -70,3 +71,7 @@ export const userClient = hc<UserRoutes>('/', {
 export const roleClient = hc<RoleRoutes>('/', {
   fetch: axiosFetch,
 }).api.v1.roles;
+
+export const fileClient = hc<FileRoutes>('/', {
+  fetch: axiosFetch,
+}).api.v1.files;

+ 1 - 0
src/server/api.ts

@@ -59,5 +59,6 @@ const fileApiRoutes = api.route('/api/v1/files', fileRoutes)
 export type AuthRoutes = typeof authRoutes
 export type UserRoutes = typeof userRoutes
 export type RoleRoutes = typeof roleRoutes
+export type FileRoutes = typeof fileApiRoutes
 
 export default api