chore: 服务端模块装配与入口更新
This commit is contained in:
@@ -1,64 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { APP_GUARD } from '@nestjs/core';
|
||||
import { LoggerModule } from 'nestjs-pino';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { EventEmitterModule } from '@nestjs/event-emitter';
|
||||
import { TypeOrmModule, type TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||
import { ThrottlerModule, ThrottlerGuard } from '@nestjs/throttler';
|
||||
import { ScheduleModule } from '@nestjs/schedule';
|
||||
import {
|
||||
Student,
|
||||
Room,
|
||||
Occupancy,
|
||||
Bed,
|
||||
Locker,
|
||||
RoomExpense,
|
||||
PersonalExpense,
|
||||
Bill,
|
||||
BillItem,
|
||||
User,
|
||||
OperationLog,
|
||||
RoomInspection,
|
||||
RoomInspectionDetail,
|
||||
Deposit,
|
||||
DepositInstallment,
|
||||
Classroom,
|
||||
Organization,
|
||||
ClassroomRental,
|
||||
Permission,
|
||||
Role,
|
||||
Class,
|
||||
ClassStudent,
|
||||
ClassTeacher,
|
||||
ClassSchedule,
|
||||
AttendanceRecord,
|
||||
AttendanceSession,
|
||||
AttendanceDevice,
|
||||
AttendancePeriodConfig,
|
||||
DingAttendanceRaw,
|
||||
SyncLog,
|
||||
SyncState,
|
||||
Notification,
|
||||
StudentProfile,
|
||||
StudentEnrollment,
|
||||
ExamScore,
|
||||
Exam,
|
||||
LearningRecord,
|
||||
ExpenseType,
|
||||
ResultArchive,
|
||||
ArchiveAttachment,
|
||||
StudentDingMapping,
|
||||
JinshujuMatchRule,
|
||||
AiConfig,
|
||||
StudentWallet,
|
||||
WalletTransaction,
|
||||
FinancialOperation,
|
||||
AiConversation,
|
||||
AiMessage,
|
||||
AiToolRun,
|
||||
AiAttachment,
|
||||
AiForm,
|
||||
AiReview,
|
||||
} from './entities';
|
||||
import * as Entities from './entities';
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { InitialSchema1784520727860 } from './migrations/1784520727860-InitialSchema';
|
||||
import { AddExamManagement1784600000000 } from './migrations/1784600000000-AddExamManagement';
|
||||
@@ -68,6 +16,8 @@ import { AddAiChat1784780000000 } from './migrations/1784780000000-AddAiChat';
|
||||
import { EnhanceAiChatForAntDesignX1784860000000 } from './migrations/1784860000000-EnhanceAiChatForAntDesignX';
|
||||
import { AddA2UiForms1784870000000 } from './migrations/1784870000000-AddA2UiForms';
|
||||
import { AddA2UiReviews1784880000000 } from './migrations/1784880000000-AddA2UiReviews';
|
||||
import { AddImportRuns1784910000000 } from './migrations/1784910000000-AddImportRuns';
|
||||
import { DropAiMessageFeedback1784920000000 } from './migrations/1784920000000-DropAiMessageFeedback';
|
||||
const allMigrations = [
|
||||
InitialSchema1784520727860,
|
||||
AddExamManagement1784600000000,
|
||||
@@ -77,6 +27,8 @@ const allMigrations = [
|
||||
EnhanceAiChatForAntDesignX1784860000000,
|
||||
AddA2UiForms1784870000000,
|
||||
AddA2UiReviews1784880000000,
|
||||
AddImportRuns1784910000000,
|
||||
DropAiMessageFeedback1784920000000,
|
||||
];
|
||||
import { AuthorizationModule } from './authorization';
|
||||
import { RbacModule } from './rbac/rbac.module';
|
||||
@@ -109,6 +61,7 @@ import { WalletsModule } from './wallets/wallets.module';
|
||||
import { FinancialOperationsModule } from './financial-operations/financial-operations.module';
|
||||
import { ExamsModule } from './exams/exams.module';
|
||||
import { AiChatModule } from './ai-chat';
|
||||
import { ImportsModule } from './imports/imports.module';
|
||||
|
||||
import {
|
||||
IntegrationConfig,
|
||||
@@ -118,6 +71,12 @@ import { IntegrationConfigModule } from './integration/config/config.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
LoggerModule.forRoot({
|
||||
pinoHttp: {
|
||||
level: process.env.LOG_LEVEL ?? 'info',
|
||||
autoLogging: process.env.NODE_ENV === 'production',
|
||||
},
|
||||
}),
|
||||
AuthorizationModule,
|
||||
ConfigModule.forRoot({ isGlobal: true }),
|
||||
ThrottlerModule.forRoot([
|
||||
@@ -134,61 +93,63 @@ import { IntegrationConfigModule } from './integration/config/config.module';
|
||||
useFactory: (config: ConfigService): TypeOrmModuleOptions => {
|
||||
const dbType = config.get('DB_TYPE', 'sqlite');
|
||||
const allEntities = [
|
||||
Student,
|
||||
Room,
|
||||
Occupancy,
|
||||
Bed,
|
||||
Locker,
|
||||
RoomExpense,
|
||||
PersonalExpense,
|
||||
Bill,
|
||||
BillItem,
|
||||
User,
|
||||
OperationLog,
|
||||
RoomInspection,
|
||||
RoomInspectionDetail,
|
||||
Deposit,
|
||||
DepositInstallment,
|
||||
Classroom,
|
||||
Organization,
|
||||
ClassroomRental,
|
||||
Class,
|
||||
ClassStudent,
|
||||
ClassTeacher,
|
||||
Permission,
|
||||
Role,
|
||||
ClassSchedule,
|
||||
AttendanceRecord,
|
||||
AttendanceSession,
|
||||
AttendanceDevice,
|
||||
AttendancePeriodConfig,
|
||||
DingAttendanceRaw,
|
||||
Notification,
|
||||
StudentProfile,
|
||||
StudentEnrollment,
|
||||
ExamScore,
|
||||
Exam,
|
||||
LearningRecord,
|
||||
StudentDingMapping,
|
||||
JinshujuMatchRule,
|
||||
ExpenseType,
|
||||
ArchiveAttachment,
|
||||
ResultArchive,
|
||||
SyncLog,
|
||||
SyncState,
|
||||
StudentDingMapping,
|
||||
Entities.Student,
|
||||
Entities.Room,
|
||||
Entities.Occupancy,
|
||||
Entities.Bed,
|
||||
Entities.Locker,
|
||||
Entities.RoomExpense,
|
||||
Entities.PersonalExpense,
|
||||
Entities.Bill,
|
||||
Entities.BillItem,
|
||||
Entities.User,
|
||||
Entities.OperationLog,
|
||||
Entities.RoomInspection,
|
||||
Entities.RoomInspectionDetail,
|
||||
Entities.Deposit,
|
||||
Entities.DepositInstallment,
|
||||
Entities.Classroom,
|
||||
Entities.Organization,
|
||||
Entities.ClassroomRental,
|
||||
Entities.Class,
|
||||
Entities.ClassStudent,
|
||||
Entities.ClassTeacher,
|
||||
Entities.Permission,
|
||||
Entities.Role,
|
||||
Entities.ClassSchedule,
|
||||
Entities.AttendanceRecord,
|
||||
Entities.AttendanceSession,
|
||||
Entities.AttendanceDevice,
|
||||
Entities.AttendancePeriodConfig,
|
||||
Entities.DingAttendanceRaw,
|
||||
Entities.Notification,
|
||||
Entities.StudentProfile,
|
||||
Entities.StudentEnrollment,
|
||||
Entities.ExamScore,
|
||||
Entities.Exam,
|
||||
Entities.LearningRecord,
|
||||
Entities.StudentDingMapping,
|
||||
Entities.JinshujuMatchRule,
|
||||
Entities.ExpenseType,
|
||||
Entities.ArchiveAttachment,
|
||||
Entities.ResultArchive,
|
||||
Entities.SyncLog,
|
||||
Entities.SyncState,
|
||||
IntegrationConfig,
|
||||
IntegrationConfigDetail,
|
||||
AiConfig,
|
||||
StudentWallet,
|
||||
WalletTransaction,
|
||||
FinancialOperation,
|
||||
AiConversation,
|
||||
AiMessage,
|
||||
AiToolRun,
|
||||
AiAttachment,
|
||||
AiForm,
|
||||
AiReview,
|
||||
Entities.AiConfig,
|
||||
Entities.StudentWallet,
|
||||
Entities.WalletTransaction,
|
||||
Entities.FinancialOperation,
|
||||
Entities.AiConversation,
|
||||
Entities.AiMessage,
|
||||
Entities.AiToolRun,
|
||||
Entities.AiAttachment,
|
||||
Entities.AiForm,
|
||||
Entities.AiReview,
|
||||
Entities.ImportRun,
|
||||
Entities.ImportStep,
|
||||
Entities.ImportRow,
|
||||
];
|
||||
if (dbType === 'mysql') {
|
||||
return {
|
||||
@@ -242,6 +203,7 @@ import { IntegrationConfigModule } from './integration/config/config.module';
|
||||
ExpenseTypesModule,
|
||||
AiConfigModule,
|
||||
AiChatModule,
|
||||
ImportsModule,
|
||||
],
|
||||
providers: [
|
||||
{ provide: APP_GUARD, useClass: ThrottlerGuard },
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import helmet from 'helmet';
|
||||
import compression from 'compression';
|
||||
import { AppModule } from './app.module';
|
||||
import { runMigrationsOnStartup } from './migration-runner';
|
||||
|
||||
@@ -8,7 +10,9 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.setGlobalPrefix('api');
|
||||
app.enableCors();
|
||||
app.use(helmet());
|
||||
app.use(compression());
|
||||
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
console.log(`Server running on http://localhost:${process.env.PORT ?? 3000}`);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
@@ -8,6 +8,8 @@ import { EnhanceAiChatForAntDesignX1784860000000 } from './migrations/1784860000
|
||||
import { AddA2UiForms1784870000000 } from './migrations/1784870000000-AddA2UiForms';
|
||||
import { AddA2UiReviews1784880000000 } from './migrations/1784880000000-AddA2UiReviews';
|
||||
import { EnlargeAiReviewSections1784900000000 } from './migrations/1784900000000-EnlargeAiReviewSections';
|
||||
import { AddImportRuns1784910000000 } from './migrations/1784910000000-AddImportRuns';
|
||||
import { DropAiMessageFeedback1784920000000 } from './migrations/1784920000000-DropAiMessageFeedback';
|
||||
import { config } from 'dotenv';
|
||||
|
||||
config();
|
||||
@@ -36,6 +38,8 @@ export async function runMigrationsOnStartup(): Promise<void> {
|
||||
AddA2UiForms1784870000000,
|
||||
AddA2UiReviews1784880000000,
|
||||
EnlargeAiReviewSections1784900000000,
|
||||
AddImportRuns1784910000000,
|
||||
DropAiMessageFeedback1784920000000,
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user