Basic structure of the project
- 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.
This commit is contained in:
parent
74c1ee1b7b
commit
9c4ea4ca90
11 changed files with 3841 additions and 1 deletions
11
src/app.ts
11
src/app.ts
|
@ -1,11 +1,22 @@
|
|||
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}`)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue