Spaces:
Sleeping
Sleeping
| require('dotenv').config(); | |
| const express = require('express'); | |
| const cors = require('cors'); | |
| const authRoutes = require('./routes/auth'); | |
| const runsRoutes = require('./routes/runs'); | |
| const programsRoutes = require('./routes/programs'); | |
| const clubsRoutes = require('./routes/clubs'); | |
| const territoryRoutes = require('./routes/territory'); | |
| const app = express(); | |
| const PORT = process.env.PORT || 5000; | |
| app.use(cors()); | |
| app.use(express.json({ limit: '10mb' })); | |
| app.use(express.urlencoded({ extended: true })); | |
| app.get('/health', (_, res) => res.json({ status: 'ok', time: new Date().toISOString() })); | |
| app.use('/api/auth', authRoutes); | |
| app.use('/api/runs', runsRoutes); | |
| app.use('/api/programs', programsRoutes); | |
| app.use('/api/clubs', clubsRoutes); | |
| app.use('/api/territory', territoryRoutes); | |
| app.use((err, req, res, next) => { | |
| console.error(err.stack); | |
| res.status(500).json({ message: 'Internal server error' }); | |
| }); | |
| app.listen(PORT, () => { | |
| console.log(`๐ BOLT API running on http://localhost:${PORT}`); | |
| }); | |