2025-04-01 17:58:14 -03:00
|
|
|
import express from 'express'
|
2025-04-02 16:34:16 -03:00
|
|
|
import topicRoutes from './routes/topicRoutes'
|
|
|
|
import { errorHandler } from './middleware/errorHandler'
|
|
|
|
|
2025-04-01 17:58:14 -03:00
|
|
|
const app = express()
|
|
|
|
const port = 3000
|
|
|
|
|
2025-04-02 16:34:16 -03:00
|
|
|
app.use(express.json())
|
|
|
|
|
|
|
|
// Routes
|
2025-04-01 17:58:14 -03:00
|
|
|
app.get('/', (req, res) => {
|
|
|
|
res.send('Hello World!')
|
|
|
|
})
|
|
|
|
|
2025-04-02 16:34:16 -03:00
|
|
|
app.use('/api/topics', topicRoutes);
|
|
|
|
|
|
|
|
// Global error handler (should be after routes)
|
|
|
|
app.use(errorHandler);
|
|
|
|
|
2025-04-01 17:58:14 -03:00
|
|
|
app.listen(port, () => {
|
|
|
|
return console.log(`Express is listening at http://localhost:${port}`)
|
|
|
|
})
|