-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (37 loc) · 1.49 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//=============================================================================
// Basic Config
//=============================================================================
const express = require('express')
// instantiate express
const app = express()
require('dotenv').config()
app.set('port', process.env.PORT || 8005)
const cors = require('cors')
app.use(cors())
//=============================================================================
// Middleware
//=============================================================================
// `express.json` parses application/json request data and
// adds it to the request object as request.body
app.use(express.json())
// `express.urlencoded` parses x-ww-form-urlencoded request data and
// adds it to the request object as request.body
app.use(express.urlencoded({ extended: true }))
// in middleware
//=============================================================================
// ROUTES
//=============================================================================
// Redirect
app.get('/', (req, res) => {
res.redirect('/todo')
})
/* START CONTROLLERS HERE */
const toDoController = require('./controllers/toDoController')
app.use('/todo/', toDoController)
/* END CONTROLLERS HERE */
//=============================================================================
// START SERVER
//=============================================================================
app.listen(app.get('port'), () => {
console.log(`✅ PORT: ${app.get('port')} 🌟`)
})