规定数据类型

This commit is contained in:
2026-04-24 01:45:29 +08:00
parent ab860c61d9
commit d1943f564a
18 changed files with 546 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { PersistenceModule } from './persistence/persistence.module';
import { ChatModule } from './modules/chat/chat.module';
import { CharacterModule } from './modules/character/character.module';
import { LLMModule } from './modules/llm/llm.module';
import { ImportExportModule } from './modules/import-export/import-export.module';
import { WorkflowModule } from './modules/workflow/workflow.module';
@Module({
imports: [
// 配置模块
ConfigModule.forRoot({
isGlobal: true,
envFilePath: ['.env.local', '.env'],
}),
// 持久化层
PersistenceModule,
// 业务模块
ChatModule,
CharacterModule,
LLMModule,
ImportExportModule,
WorkflowModule,
],
})
export class AppModule {}

View File

@@ -0,0 +1,41 @@
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { AppModule } from './app.module';
import { HttpExceptionFilter } from './core/filters/http-exception.filter';
import { LoggingInterceptor, ResponseInterceptor } from './core/interceptors';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// 全局前缀
app.setGlobalPrefix('api');
// CORS 配置
app.enableCors({
origin: process.env.FRONTEND_URL || 'http://localhost:5173',
credentials: true,
});
// 全局验证管道
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
transform: true,
forbidNonWhitelisted: true,
}),
);
// 全局异常过滤器
app.useGlobalFilters(new HttpExceptionFilter());
// 全局拦截器
app.useGlobalInterceptors(new LoggingInterceptor());
app.useGlobalInterceptors(new ResponseInterceptor());
const port = process.env.PORT || 3000;
await app.listen(port);
console.log(`🚀 Server is running on http://localhost:${port}`);
}
bootstrap();

View File

@@ -0,0 +1,9 @@
import { Module, Global } from '@nestjs/common';
import { FileSystemRepository } from './file-system/file-system.repository';
@Global()
@Module({
providers: [FileSystemRepository],
exports: [FileSystemRepository],
})
export class PersistenceModule {}