-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (36 loc) · 935 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
/**
@author: Karthik Sukumaran
@version: 1.0
@Website karthiksukumaran.com
@date: 13-Jan-2017
@Description: Basic NodeJS Service Example
**/
var express = require('express');
var bodyParser = require('body-parser');
var http = require('http');
var httpServer;
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
var routes = [
"sendandreceivejson_routes"
]
function setupRoutes(){
for(var route of routes){
app.use('/' , require("./routes/"+ route));
}
}
function startServer() {
try{
var portnumber = 8888;
setupRoutes();
httpServer = http.createServer(app).listen(portnumber, '0.0.0.0');
console.log("Server started at port "+portnumber);
console.log("URL http://localhost:"+portnumber);
}
catch(err){
console.log("app.js startServer :: err :: ", err);
}
}
startServer();