-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
46 lines (36 loc) · 1.04 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
const express = require('express')
const dotenv = require('dotenv')
const morgan = require('morgan')
const colors = require('colors')
const inspect = require('inspect')
const app = express()
// Load Envs
dotenv.config({ path: './config/config.env' })
// Middlewares
const logger = require('./middleware/logger')
// Routes Files
const bootcamps = require('./routes/bootcamps')
// Use Middleware
app.use(logger)
if (process.env.NODE_ENV !== 'production') app.use(morgan('dev'))
// Mount routes
app.get('/', (req, res) => {
// inspect(req);
// debugger
res.status(404).json({ success: false })
})
app.use('/api/v1/bootcamps', bootcamps)
const PORT = process.env.PORT || 5000
app.listen(PORT, () => {
console.log(
`Server is in ${process.env.NODE_ENV} mode, and is listening on ${PORT}`
.yellow.bold
)
})
// app.get("/", (req, res) => {
// // res.send("Hello Express!")
// // res.json({ name: 'Haider Rizvi'})
// // res.send('<h1>Hello Express</h1>')
// // res.sendStatus(400)
// res.status(404).json({ success: false });
// });