2025-09-21 19:35:41 +01:00
|
|
|
import 'dotenv/config';
|
2025-01-18 11:13:05 +01:00
|
|
|
|
2025-11-24 01:00:50 +01:00
|
|
|
import { API_PORT } from '@api/constants';
|
2025-11-01 15:49:29 +01:00
|
|
|
import { app } from '@api/app';
|
|
|
|
|
import { configureOpenAPI } from '@api/utils/openapi';
|
2025-09-21 19:35:41 +01:00
|
|
|
import { serve } from '@hono/node-server';
|
|
|
|
|
import { showRoutes } from 'hono/dev';
|
2026-03-09 11:18:22 +01:00
|
|
|
import { connectRedis } from '@api/utils/redis/redis';
|
2025-01-18 11:13:05 +01:00
|
|
|
|
2025-09-21 19:35:41 +01:00
|
|
|
// Start server
|
2026-03-09 11:18:22 +01:00
|
|
|
async function startServer() {
|
2025-11-24 01:00:50 +01:00
|
|
|
console.log('Starting server on port:', API_PORT);
|
2025-09-21 19:35:41 +01:00
|
|
|
|
2026-03-09 11:18:22 +01:00
|
|
|
// Connect to Redis before starting the server
|
|
|
|
|
await connectRedis();
|
|
|
|
|
console.log('Redis connected successfully');
|
|
|
|
|
|
2025-11-24 01:00:50 +01:00
|
|
|
serve({ fetch: app.fetch, port: API_PORT });
|
2025-09-21 19:35:41 +01:00
|
|
|
|
|
|
|
|
showRoutes(app, { colorize: true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
configureOpenAPI(app);
|
|
|
|
|
|
2026-03-09 11:18:22 +01:00
|
|
|
startServer().catch((error) => {
|
|
|
|
|
console.error('Failed to start server:', error);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|