Dan K
2019-08-04 ac6169db7b90e950156a87d9784308429ce3bee2
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
var express = require('express');
var fs = require('fs')
app = express();
 
// read in the APP_MSG env var
var msg = process.env.APP_MSG;
 
var response;
 
app.get('/', function (req, res) {
 
    response = 'Value in the APP_MSG env var is => ' + msg + '\n';
 
    // Read in the secret file
    fs.readFile('/opt/app-root/secure/myapp.sec', 'utf8', function (secerr,secdata) {
        if (secerr) {
            console.log(secerr + '\n');
            response += secerr + '\n';
        }
        else {
            response += 'The secret is => ' + secdata + '\n';
        }
 
        //send the response to the client
        res.send(response);
    });
 
});
 
app.listen(8080, function () {
  console.log('Server listening on port 8080...');
});