Files
whattoplay/features/keycrow/src/index.ts
2026-03-10 17:03:13 +01:00

44 lines
1.3 KiB
TypeScript

import express, { Express } from 'express';
import cors from 'cors';
import path from 'path';
import { config } from './config';
import authRoutes from './routes/auth';
import listingsRoutes from './routes/listings';
import transactionsRoutes from './routes/transactions';
import theoreticalRoutes from './routes/theoretical';
const app: Express = express();
app.use(cors());
app.use(express.json());
app.use(express.static(path.join(__dirname, 'gui')));
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'gui', 'index.html'));
});
app.get('/health', (req, res) => {
res.json({ status: 'ok', timestamp: new Date().toISOString() });
});
app.use('/auth', authRoutes);
app.use('/listings', listingsRoutes);
app.use('/transactions', transactionsRoutes);
app.use('/theoretical', theoreticalRoutes);
app.use((err: Error, req: express.Request, res: express.Response, next: express.NextFunction) => {
console.error('Unhandled error:', err);
res.status(500).json({ success: false, error: 'Internal server error' });
});
const startServer = () => {
app.listen(config.port, () => {
console.log(`Server running on port ${config.port}`);
console.log(`Theoretical activation: ${config.features.allowTheoreticalActivation ? 'ENABLED' : 'DISABLED'}`);
});
};
startServer();
export default app;