-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (22 loc) · 651 Bytes
/
Copy pathapp.js
File metadata and controls
27 lines (22 loc) · 651 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
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const path = require('path');
const poll = require('./routes/poll');
const db = require('./config/database');
const app = express();
// Set public folder
app.use(express.static(path.join(__dirname, 'public')));
// Body parser middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
// Enable CORS
app.use(cors());
// Setup port
const port = process.env.PORT || 3000;
// Routes
app.use('/poll', poll);
// Start server
app.listen(port, () => {
console.log(`Server is started up on port ${port}`);
});