-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
45 lines (33 loc) · 954 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
37
38
39
40
41
42
43
44
45
// Load environment variables
require('dotenv').config()
// Import packages
const express = require('express')
const cors = require('cors')
// Import database connection
const connectDB = require('./config/db')
// Start db
connectDB()
// Create an express app
const app = express()
app.use(cors())
app.use(express.urlencoded({ extended: false }))
app.use(express.json())
app.set('view engine', 'ejs')
// Logg requests
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line import/no-extraneous-dependencies
const morgan = require('morgan')
app.use(morgan('dev'))
}
// Routes
app.get('/', (req, res) => {
res.send('<h3> <center> Hello from ayyo </center> </h3>')
})
// Api routes
app.use('/api/v1', require('./routes/index'))
// Import and run jobs
const runJobs = require('./jobRunner')
runJobs()
const PORT = process.env.PORT || 5000
// Start server
app.listen(PORT, console.log(`Server Runnig at PORT: ${PORT}`))