Connect node js to SAP code example

Example: sap get hana connection from node

'use strict';
const { PerformanceObserver, performance } = require('perf_hooks');
var t0 = performance.now();
var util = require('util');
var hana = require('@sap/hana-client');

var connOptions = {
    serverNode: '@User1UserKey',
    //serverNode: 'your host:your port',
    //UID: 'USER1',
    //PWD: 'Password1',
    encrypt: 'true',  //Must be set to true when connecting to SAP HANA Cloud
    sslValidateCertificate: 'false',  //Must be set to false when connecting
    //to an SAP HANA, express edition instance that uses a self signed certificate.

    //Below setting is used to specify where the trust store is
    //ssltruststore: '/home/dan/.ssl/trust2.pem',

    //Alternatively provide the contents of the certificate directly (DigiCertGlobalRootCA.pem)
    //ssltruststore: '-----BEGIN CERTIFICATE-----MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQkCAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=-----END CERTIFICATE-----'
};

var connection = hana.createConnection();
connection.connect(connOptions, function(err) {
    if (err) {
        return console.error(err);
    }
    var sql = 'select TITLE, FIRSTNAME, NAME from HOTEL.CUSTOMER;';
    var rows = connection.exec(sql, function(err, rows) {
        if (err) {
            return console.error(err);
        }
        console.log(util.inspect(rows, { colors: false }));
        var t1 = performance.now();
        console.log("time in ms " +  (t1 - t0));
        connection.disconnect(function(err) {
            if (err) {
                return console.error(err);
            }   
        });
    });
});