-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
24 lines (19 loc) · 790 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
var express = require('express'),
path = require('path'),
bodyParser = require('body-parser'),
cors = require('cors');
require('./models/db');
var router = require('./routes/index'),
app = express();
// Parse the incoming request's body as JSON
app.use(bodyParser.json());
// Parse the incoming request's body as URL encoded data
app.use(bodyParser.urlencoded({extended: false}));
// Use the cors middleware to add necessary response headers to allow CORS
app.use(cors());
// Use the express router to decide the controllers that will handle the incoming URL
app.use('/api', router);
// Start the server by listening on a specific port (3000 here)
app.listen(3000, function() {
console.log('==================SERVER LISTENING ON PORT 3000=======================');
});