mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-24 01:16:42 +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.
25 lines
715 B
TypeScript
25 lines
715 B
TypeScript
import 'dotenv/config';
|
|
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
import { migrate } from 'drizzle-orm/postgres-js/migrator';
|
|
import postgres from 'postgres';
|
|
|
|
async function main() {
|
|
const databaseUrl =
|
|
process.env.DATABASE_URL || 'postgresql://manacore:devpassword@localhost:5432/manacore';
|
|
|
|
console.log('Connecting to database...');
|
|
const connection = postgres(databaseUrl, { max: 1 });
|
|
const db = drizzle(connection);
|
|
|
|
console.log('Running migrations...');
|
|
await migrate(db, { migrationsFolder: './src/db/migrations' });
|
|
|
|
console.log('Migrations complete!');
|
|
await connection.end();
|
|
process.exit(0);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error('Migration failed:', err);
|
|
process.exit(1);
|
|
});
|