-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainserver.js
More file actions
33 lines (25 loc) · 964 Bytes
/
mainserver.js
File metadata and controls
33 lines (25 loc) · 964 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
var express = require('express');
var app = express(); // Create our Express application
var config = require('./config.js');
//In order to accept data via POST or PUT, we need to add another package called body-parser.
var bodyParser = require('body-parser');
var router = express.Router();
//module.exports = app;
app.disable('x-powered-by'); //security purpose to block server info
app.set('port', process.env.PORT || config.webport);
app.use(express.static(__dirname + config.publicdir));
require("./rest/services")(app);
require("./routes")(router);
router.get('/', function(req, res){
res.send('Welcome');
console.log("Welcome");
});
// Use the body-parser package in our application
app.use(bodyParser.urlencoded({
extended: true
}));
// mount the router on the app
app.use('/', router);
app.listen(app.get('port'), function () {
console.log('Express started on localhost:' + app.get('port') + ' [Ctl-C] to terminate');
});