Files
classroomio/apps/api/src/index.ts
T

29 lines
736 B
TypeScript
Raw Normal View History

import 'dotenv/config';
2025-01-18 11:13:05 +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';
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
// Start server
2026-03-09 11:18:22 +01:00
async function startServer() {
console.log('Starting server on port:', API_PORT);
2026-03-09 11:18:22 +01:00
// Connect to Redis before starting the server
await connectRedis();
console.log('Redis connected successfully');
serve({ fetch: app.fetch, port: API_PORT });
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);
});