mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 21:01:23 +02:00
Implement custom NestJS API Gateway for mana-search, mana-stt, and mana-tts: - API Key management with CRUD operations and key regeneration - Redis-based sliding window rate limiting - Credit-based billing with tier support (free, pro, enterprise) - Usage tracking with daily aggregates - Proxy services to backend microservices - Prometheus metrics endpoint - JWT auth for management API, API key auth for public API Database schema uses separate `api_gateway` schema in shared manacore DB.
24 lines
611 B
TypeScript
24 lines
611 B
TypeScript
import { Global, Module } from '@nestjs/common';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { getDb } from './connection';
|
|
|
|
export const DATABASE_CONNECTION = 'DATABASE_CONNECTION';
|
|
|
|
@Global()
|
|
@Module({
|
|
providers: [
|
|
{
|
|
provide: DATABASE_CONNECTION,
|
|
useFactory: (configService: ConfigService) => {
|
|
const databaseUrl = configService.get<string>('database.url');
|
|
if (!databaseUrl) {
|
|
throw new Error('DATABASE_URL is not configured');
|
|
}
|
|
return getDb(databaseUrl);
|
|
},
|
|
inject: [ConfigService],
|
|
},
|
|
],
|
|
exports: [DATABASE_CONNECTION],
|
|
})
|
|
export class DatabaseModule {}
|