- Fix @nestjs/typeorm version (^11.0.0), add socket.io - Add SSL CA cert support for Timeweb Cloud PostgreSQL - Add terminal component (xterm.js) with WebSocket streaming - Add session detail page with live terminal view - Add socket.io client utilities for real-time updates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { readFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
import { AuthModule } from './auth/auth.module';
|
|
import { UsersModule } from './users/users.module';
|
|
import { MachinesModule } from './machines/machines.module';
|
|
import { ProjectsModule } from './projects/projects.module';
|
|
import { WorkspacesModule } from './workspaces/workspaces.module';
|
|
import { SessionsModule } from './sessions/sessions.module';
|
|
import { AgentGateway } from './gateway/agent.gateway';
|
|
|
|
function buildSslConfig(config: ConfigService): false | object {
|
|
if (config.get('DATABASE_SSL', 'true') !== 'true') return false;
|
|
const caPath = config.get('DATABASE_CA_CERT', '');
|
|
if (caPath) {
|
|
const resolved = caPath.startsWith('/') || caPath.match(/^[A-Z]:/i)
|
|
? caPath
|
|
: join(process.cwd(), caPath);
|
|
return { rejectUnauthorized: true, ca: readFileSync(resolved).toString() };
|
|
}
|
|
return { rejectUnauthorized: false };
|
|
}
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({ isGlobal: true }),
|
|
TypeOrmModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: (config: ConfigService) => ({
|
|
type: 'postgres',
|
|
host: config.get('DATABASE_HOST', 'localhost'),
|
|
port: config.get<number>('DATABASE_PORT', 5432),
|
|
username: config.get('DATABASE_USER', 'gen_user'),
|
|
password: config.get('DATABASE_PASSWORD', ''),
|
|
database: config.get('DATABASE_NAME', 'default_db'),
|
|
ssl: buildSslConfig(config),
|
|
autoLoadEntities: true,
|
|
synchronize: config.get('NODE_ENV') !== 'production',
|
|
}),
|
|
}),
|
|
AuthModule,
|
|
UsersModule,
|
|
MachinesModule,
|
|
ProjectsModule,
|
|
WorkspacesModule,
|
|
SessionsModule,
|
|
],
|
|
providers: [AgentGateway],
|
|
})
|
|
export class AppModule {}
|