update project
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
import knex from 'knex';
|
||||
import knexConfig from './db/knexfile';
|
||||
import app from './app';
|
||||
import { env } from './config/env';
|
||||
import { env, initEnv } from './config/env';
|
||||
import { createRabbitConnection } from './events/connection';
|
||||
import { startConsumer } from './events/consumer';
|
||||
|
||||
async function main() {
|
||||
const db = knex(knexConfig);
|
||||
await initEnv();
|
||||
|
||||
console.log('[API] Running migrations...');
|
||||
await db.migrate.latest();
|
||||
console.log('[API] Migrations complete.');
|
||||
|
||||
await db.destroy();
|
||||
// Start RabbitMQ consumer
|
||||
try {
|
||||
const channel = await createRabbitConnection();
|
||||
await startConsumer(channel);
|
||||
console.log('[API] RabbitMQ consumer started');
|
||||
} catch (err: any) {
|
||||
console.warn('[API] RabbitMQ not available, events will not be consumed:', err.message);
|
||||
}
|
||||
|
||||
app.listen(env.port, () => {
|
||||
console.log(`[API] Server running on port ${env.port}`);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error('[API] Failed to start:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
main().catch(console.error);
|
||||
|
||||
Reference in New Issue
Block a user