-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.module.ts
More file actions
81 lines (69 loc) · 2.08 KB
/
app.module.ts
File metadata and controls
81 lines (69 loc) · 2.08 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
77
78
79
80
81
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { APP_GUARD } from '@nestjs/core';
import { ThrottlerModule, ThrottlerGuard } from '@nestjs/throttler';
import { HttpModule } from '@nestjs/axios';
import { HealthController } from './health.controller';
import { CommonModule } from './common/common.module';
import { ProxyModule } from './proxy/proxy.module';
import { DiscoveryModule } from './discovery/discovery.module';
import { AuthModule } from './auth/auth.module';
import { ToolsModule } from './tools/tools.module';
import { McpModule } from './mcp/mcp.module';
import { RedisModule } from './redis/redis.module';
import { WidgetsModule } from './widgets/widgets.module';
import { AliasModule } from './alias/alias.module';
@Module({
imports: [
// Configuration
ConfigModule.forRoot({
isGlobal: true,
envFilePath: '.env',
}),
// Rate limiting (configurable via env vars)
ThrottlerModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (config: ConfigService) => {
const enabled = config.get<string>('ENABLE_RATE_LIMIT', 'true') !== 'false';
return [
{
ttl: enabled ? config.get<number>('RATE_LIMIT_WINDOW', 60000) : 60000,
limit: enabled ? config.get<number>('RATE_LIMIT_MAX', 100) : 0,
},
];
},
}),
// HTTP client
HttpModule.register({
timeout: 30000,
maxRedirects: 5,
}),
// Shared utilities
CommonModule,
// Redis (global)
RedisModule,
// Alias lookup (external Redis — partner alias → project API key)
AliasModule,
// Proxy to Old API
ProxyModule,
// OAuth Discovery
DiscoveryModule,
// OAuth Authentication
AuthModule,
// MCP Tools
ToolsModule,
// MCP Widgets (ChatGPT interactive UI)
WidgetsModule,
// MCP Protocol
McpModule,
],
controllers: [HealthController],
providers: [
{
provide: APP_GUARD,
useClass: ThrottlerGuard,
},
],
})
export class AppModule {}