-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (28 loc) · 977 Bytes
/
app.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
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
// --------------- Importing Routes ---------------------
const booksRoutes = require('./routes/books')
const usersRoute = require('./routes/users')
// --------------- Third Party Middleware ---------------
app.use(express.static('public'))
app.use(bodyParser.json())
// ---------------- Template engine ---------------------
app.set('view engine', 'ejs')
app.set('views', 'views')
// ---------------- Use API Routes ------------------------
app.use('/books', booksRoutes)
app.use('/users', usersRoute)
// ---------------- Get All Routes ----------------------
app.get("/", (req, res) => {
res.status(200).send('Welcome to Home Page')
})
// app.get('*', (req, res) => {
// res.status(404)
// res.send('404 Not Found')
// })
// Server Configuration
const PORT = '4000'
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`)
})