generated from jphacks/JP_sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.ts
More file actions
76 lines (70 loc) · 2.33 KB
/
api.ts
File metadata and controls
76 lines (70 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* APIルーターの統合管理
*
* このファイルでは、全てのAPIエンドポイントをまとめて管理します。
* 各機能ごとにルートモジュールを分割し、/api 配下にマウントします。
*/
import { createRoute, z } from "@hono/zod-openapi";
// ルートモジュールのインポート
import agoraRoutes from "./modules/agora.routes";
import authRoutes from "./modules/auth.routes";
import conversationRoutes from "./modules/conversation.routes";
import debugRoutes from "./modules/debug.routes";
import feedbackRoutes from "./modules/feedback.routes";
import messagesRoutes from "./modules/messages.routes";
import partnersRoutes from "./modules/partners.routes";
import sessionsRoutes from "./modules/sessions.routes";
import speechRoutes from "./modules/speech.routes";
import { createApiRoute } from "./utils";
// APIルーターを作成
const api = createApiRoute();
/**
* ヘルスチェックエンドポイント
* GET /api/health
* APIサーバーの稼働状態を確認します
*/
const healthRoute = createRoute({
method: "get",
path: "/health",
tags: ["Health"],
responses: {
200: {
description: "API is healthy",
content: {
"application/json": {
schema: z.object({
status: z.string().openapi({ example: "ok" }),
}),
},
},
},
},
});
api.openapi(healthRoute, (c) => {
return c.json({ status: "ok" });
});
/**
* ルートモジュールをマウント
*
* 各ルートは以下のように構成されます:
* - /auth: 認証関連(サインアップ、ログイン等)
* - /sessions: セッション管理、メッセージ、フィードバック
* - /conversation: AI会話生成とフィードバック
* - /speech: STT/TTS機能
* - /partners: パートナー管理
* - /agora: Agora RTC token generation
*/
[
{ basePath: "/agora", router: agoraRoutes },
{ basePath: "/auth", router: authRoutes },
{ basePath: "/sessions", router: sessionsRoutes },
{ basePath: "/sessions", router: messagesRoutes },
{ basePath: "/sessions", router: feedbackRoutes },
{ basePath: "/conversation", router: conversationRoutes },
{ basePath: "/", router: speechRoutes },
{ basePath: "/partners", router: partnersRoutes },
{ basePath: "/", router: debugRoutes },
].forEach(({ basePath, router }) => {
api.route(basePath, router);
});
export default api;