- Added a model with in-memory database, and routes, controller and middleware to enable making initial CRUD calls to endpoints; - Added jest and an initial test.
22 lines
483 B
TypeScript
22 lines
483 B
TypeScript
import express from 'express'
|
|
import topicRoutes from './routes/topicRoutes'
|
|
import { errorHandler } from './middleware/errorHandler'
|
|
|
|
const app = express()
|
|
const port = 3000
|
|
|
|
app.use(express.json())
|
|
|
|
// Routes
|
|
app.get('/', (req, res) => {
|
|
res.send('Hello World!')
|
|
})
|
|
|
|
app.use('/api/topics', topicRoutes);
|
|
|
|
// Global error handler (should be after routes)
|
|
app.use(errorHandler);
|
|
|
|
app.listen(port, () => {
|
|
return console.log(`Express is listening at http://localhost:${port}`)
|
|
})
|