feat(backend): implement knowledge base management backend API

This commit is contained in:
AI Clinical Dev Team
2025-10-11 11:32:47 +08:00
parent 8a4c703128
commit b26700a7d5
9 changed files with 1346 additions and 0 deletions

View File

@@ -1,10 +1,17 @@
import Fastify from 'fastify';
import cors from '@fastify/cors';
import multipart from '@fastify/multipart';
import { config, validateEnv } from './config/env.js';
import { testDatabaseConnection, prisma } from './config/database.js';
import { projectRoutes } from './routes/projects.js';
import { agentRoutes } from './routes/agents.js';
import { conversationRoutes } from './routes/conversations.js';
import knowledgeBaseRoutes from './routes/knowledgeBases.js';
// 全局处理BigInt序列化
(BigInt.prototype as any).toJSON = function() {
return Number(this);
};
const fastify = Fastify({
logger: {
@@ -26,6 +33,13 @@ await fastify.register(cors, {
credentials: true,
});
// 注册文件上传插件
await fastify.register(multipart, {
limits: {
fileSize: 10 * 1024 * 1024, // 10MB
},
});
// 健康检查路由
fastify.get('/health', async () => {
// 检查数据库连接
@@ -63,6 +77,9 @@ await fastify.register(agentRoutes, { prefix: '/api/v1' });
// 注册对话管理路由
await fastify.register(conversationRoutes, { prefix: '/api/v1' });
// 注册知识库管理路由
await fastify.register(knowledgeBaseRoutes, { prefix: '/api/v1' });
// 启动服务器
const start = async () => {
try {