-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
44 lines (28 loc) · 1.01 KB
/
server.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
const express = require('express');
const bodyParser = require('body-parser');
// const passport = require('passport');
const cors = require('cors');
const dotenv = require('dotenv');
dotenv.config();
// Load the routes from the api
const order = require('./routes/api/order');
const stats = require('./routes/api/stats');
// Initialize the app
const app = express();
// Enable cors middleware for enabling cross origin requests
app.use(cors());
// Body parser middleware for parsing requests to json formats
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
// Load the routes into the application
app.use('/api/order', order);
app.use('/api/stats', stats);
// Select the port for the application
const port = process.env.PORT || 5000;
app.get('/', (req, res) => {
res.json({status: 'Working'})
})
// Listen on the selected ports for any incoming requests
app.listen(port, () => {
console.log(`Server has started on port ${port}`);
})