forked from andrescisneroscampos/ci-demo-node-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (28 loc) · 897 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
var express = require('express')
var app = express()
var configService = require('./configService.js');
app.get('/', function(req, res) {
//Sending Json Response
res.setHeader('Content-Type', 'application/json');
//Reading Environment values
var envKey = process.env.ENVIRONMENT;
if (envKey === undefined) {
envKey = "dev";
}
//Reading configuration file
var config = JSON.parse(configService.readConfiguration(envKey, "config.json"));
//Creating response
var response = new ServiceResponse(envKey, config);
res.json(response);
})
app.listen(8080, function() {
//Start NodeJS server
console.log('Example app listening on port 8080!')
})
//Response Object
var ServiceResponse = function(envKey, config) {
this.envKey = envKey;
this.envName = config.envName;
this.version = "1.1";
this.timestamp = new Date();
}