-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (23 loc) · 783 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require('dotenv').config() //always comes firrst
require('./models')
const express = require('express')
const cors = require('cors')
const app = express()
const PORT = process.env.PORT || 6001
// middlewares
app.use(cors())
app.use(express.json())
const myMiddleWare = (req, res, next) => {
console.log(`incoming request: ${req.method} - ${req.url}`)
// move along there
next()
}
app.use(myMiddleWare)
app.get('/', (req, res) => {
res.json({ msg: 'welcome to the user app 👋' })
})
// controllers
app.use('/api-v1/users', require('./controllers/api-v1/users'))
app.use('/recipe', require('./controllers/recipe'))
app.use('/note', require('./controllers/note'))
app.listen(PORT, () => console.log(`listening to the smooth sounds of port ${PORT} in the morning 🌊`))