-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (23 loc) · 857 Bytes
/
server.js
File metadata and controls
37 lines (23 loc) · 857 Bytes
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
const express = require('express');
// const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const cors = require('cors');
const dotenv = require('dotenv');
dotenv.config();
// Load the routes from the api
const incoming = require('./routes/api/incoming');
// 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/incoming', incoming);
// Select the port for the application
const port = process.env.PORT || 5000;
// Listen on the selected ports for any incoming requests
app.listen(port, () => {
console.log(`Server has started on port ${port}`);
})