-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
56 lines (47 loc) · 1.2 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
'use strict';
var async = require('async');
var hdb = require('hdb');
var client = require('./lib/client');
var sql_command = "";
const express = require('express');
const app = express();
// [START hdb_client]
function connect(cb) {
client.connect(cb);
}
function disconnect(rows, cb) {
function done(err) {
cb(err, rows);
}
client.disconnect(done);
}
function executeSQLArray(cb) {
var options = {
rowsAsArray: true
};
client.exec(sql_command, options, cb);
}
function executeSQL(cb) {
client.exec(sql_command, cb);
}
// [END hdb_client]
app.get('/', function (req, res) {
// Execute a SQL command to access the version of the SAP HANA server
sql_command = "SELECT VALUE FROM SYS.M_SYSTEM_OVERVIEW WHERE NAME = 'Version'";
async.waterfall([connect, executeSQL, disconnect], function (err, rows) {
client.end();
if (err) {
return console.error(err);
}
res.send("System Version: " + rows[0].VALUE);
});
})
if (module === require.main) {
// [START server]
const server = app.listen(process.env.PORT || 8080, () => {
const port = server.address().port;
console.log(`App listening on port ${port}`);
});
// [END server]
}
module.exports = app;