<commit_before>module.exports = function (app) {
    var SSH = require('simple-ssh');
    var Client = require('node-rest-client').Client;
    var client = new Client();

    // application -------------------------------------------------------------
    app.post('/rest/topology', function (req, res) {
        var server = "http://" + req.body.server;
        var args = {
            data: req.body.view, //"queryNodes",
            headers: {"Content-Type": "text/plain"},
            requestConfig: {timeout: 2000},
            responseConfig: {timeout: 5000}
        };

        var req = client.post(server + "/rest/topology/", args, function (data, response) {
            res.json(data);
        });

        //req.on('requestTimeout', function (req) {
        //    console.log(server + "/rest/topology/" + 'request has expired');
        //    req.abort();
        //});
        //
        //req.on('responseTimeout', function (res) {
        //    console.log('response has expired');
        //    res.abort();
        //});
        //
        //req.on('error', function (err) {
        //    console.log('request error');
        //});

    });

    app.post('/am/rest', function (req, res) {
        var url = "http://" + req.body.server + req.body.context + req.body.table;
        var auth = 'Basic ' + new Buffer(req.body.user + ':' + req.body.password).toString('base64');
        var args = {
            headers: {
                "Content-Type": "application/json",
                "Authorization": auth
            }
        };

        var req = client.get(url, args, function (data, response) {
            console.log("url: " + url);
            res.json(data);
        });

        req.on('error', function (err) {
            console.log('request error: ' + err);
        });
    });

    app.post('/ssh/exec', function (req, res) {
        console.log("req.body.cmd: " + req.body.cmd);
        var ssh = new SSH({
            host: req.body.host,
            user: req.body.user,
            pass: req.body.pass
        });

        ssh.exec(req.body.cmd, {
            out: function (stdout) {
                console.log("stdout: " + stdout);<commit_msg>use rest client path parameters<commit_after>module.exports = function (app) {
    var SSH = require('simple-ssh');
    var Client = require('node-rest-client').Client;
    var client = new Client();

    // application -------------------------------------------------------------
    app.post('/rest/topology', function (req, res) {
        var server = "http://" + req.body.server;
        var args = {
            data: req.body.view, //"queryNodes",
            headers: {"Content-Type": "text/plain"},
            requestConfig: {timeout: 2000},
            responseConfig: {timeout: 5000}
        };

        var req = client.post(server + "/rest/topology/", args, function (data, response) {
            res.json(data);
        });

        //req.on('requestTimeout', function (req) {
        //    console.log(server + "/rest/topology/" + 'request has expired');
        //    req.abort();
        //});
        //
        //req.on('responseTimeout', function (res) {
        //    console.log('response has expired');
        //    res.abort();
        //});
        //
        //req.on('error', function (err) {
        //    console.log('request error');
        //});

    });

    app.post('/am/rest', function (req, res) {
//        var url = "http://" + req.body.server + req.body.context + req.body.table;
        var url = "http://${server}${context}${table}";
        var auth = 'Basic ' + new Buffer(req.body.user + ':' + req.body.password).toString('base64');
        var args = {
            path: req.body,
            headers: {
                "Content-Type": "application/json",
                "Authorization": auth
            }
        };

        var req = client.get(url, args, function (data, response) {
            console.log("url: " + url);
            res.json(data);
        });

        req.on('error', function (err) {
            console.log('request error: ' + err);
        });
    });

    app.post('/ssh/exec', function (req, res) {
        console.log("req.body.cmd: " + req.body.cmd);
        var ssh = new SSH({
            host: req.body.host,
            user: req.body.user,
            pass: req.body.pass
        });

        ssh.exec(req.body.cmd, {
            out: function (stdout) {
                console.log("stdout: " + stdout);
{'fraction_non_alphanumeric': 0.19772117962466487, 'fraction_numerical': 0.004468275245755138, 'mean_word_length': 1.5095291479820627, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5122862', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1259, 'n_words': 262}