new file: .dockerignore
new file: .env.example new file: Dockerfile modified: backend/.env.example modified: backend/package.json renamed: backend/src/migrations/run.ts -> backend/src/scripts/run.ts renamed: backend/src/migrations/seed.ts -> backend/src/scripts/seed.ts new file: docker-compose.external-db.yml new file: docker-compose.yml
This commit is contained in:
@@ -15,31 +15,4 @@ JWT_EXPIRES_IN=24h
|
||||
|
||||
# API Rate Limiting
|
||||
RATE_LIMIT_WINDOW_MS=900000
|
||||
RATE_LIMIT_MAX_REQUESTS=100
|
||||
|
||||
# Target Databases Configuration (JSON format)
|
||||
# This is where your API endpoints will execute queries
|
||||
TARGET_DATABASES='[
|
||||
{
|
||||
"id": "main_postgres",
|
||||
"name": "Main PostgreSQL",
|
||||
"type": "postgresql",
|
||||
"host": "localhost",
|
||||
"port": 5432,
|
||||
"database": "your_database",
|
||||
"user": "your_user",
|
||||
"password": "your_password",
|
||||
"ssl": false
|
||||
},
|
||||
{
|
||||
"id": "analytics_db",
|
||||
"name": "Analytics Database",
|
||||
"type": "postgresql",
|
||||
"host": "localhost",
|
||||
"port": 5432,
|
||||
"database": "analytics",
|
||||
"user": "analytics_user",
|
||||
"password": "analytics_password",
|
||||
"ssl": false
|
||||
}
|
||||
]'
|
||||
RATE_LIMIT_MAX_REQUESTS=100
|
||||
@@ -7,8 +7,8 @@
|
||||
"dev": "nodemon",
|
||||
"build": "tsc",
|
||||
"start": "node dist/server.js",
|
||||
"migrate": "ts-node src/migrations/run.ts",
|
||||
"seed": "ts-node src/migrations/seed.ts"
|
||||
"migrate": "ts-node src/scripts/run.ts",
|
||||
"seed": "ts-node src/scripts/seed.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"api",
|
||||
|
||||
@@ -6,14 +6,18 @@ async function runMigrations() {
|
||||
console.log('Running migrations...');
|
||||
|
||||
try {
|
||||
const migrationFile = fs.readFileSync(
|
||||
path.join(__dirname, '001_initial_schema.sql'),
|
||||
'utf-8'
|
||||
);
|
||||
const migrationsDir = path.join(__dirname, '../migrations');
|
||||
const files = fs.readdirSync(migrationsDir)
|
||||
.filter(f => f.endsWith('.sql'))
|
||||
.sort();
|
||||
|
||||
for (const file of files) {
|
||||
console.log(` Running ${file}...`);
|
||||
const sql = fs.readFileSync(path.join(migrationsDir, file), 'utf-8');
|
||||
await mainPool.query(sql);
|
||||
}
|
||||
|
||||
await mainPool.query(migrationFile);
|
||||
console.log('✅ Migrations completed successfully');
|
||||
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('❌ Migration failed:', error);
|
||||
Reference in New Issue
Block a user