<commit_before>// Add dependencies
var restify = require('restify');
const corsMiddleware = require('restify-cors-middleware')

// Load code from sub modules
var globals = require('./globals');
var rest = require('./rest');
var mqtt = require('./mqtt');
var udp = require('./udp');



// Set default debug level
// { error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5 }
globals.logger.transports.console.level = 'warn';


// ---------------------------------------------------
// Create restServer object
var restServer = restify.createServer({
    name: 'Butler for Qlik Sense'
});


const cors = corsMiddleware({
    preflightMaxAge: 5, //Optional
    origins: ['*'],
    allowHeaders: ['API-Token'],
    exposeHeaders: ['API-Token-Expiry']
})



// Set up restify
restServer.use(restify.plugins.queryParser({
    mapParams: true
})); // Parses the HTTP query string (i.e., /foo?id=bar&name=mark). 
restServer.use(restify.plugins.fullResponse()); // sets up all of the default headers for the system
restServer.use(restify.plugins.bodyParser()); // remaps the body content of a request to the req.params variable, allowing both GET and POST/PUT routes to use the same interface

restServer.pre(cors.preflight)
restServer.use(cors.actual)



// Set up endpoints for REST server
restServer.get('/v2/activeUserCount', rest.activeUserCount.respondActiveUserCount);
restServer.get('/v2/activeUsers', rest.activeUsers.respondActiveUsers);
restServer.get('/v2/slackPostMessage', rest.slackPostMessage.respondSlackPostMessage);
restServer.get('/v2/createDir', rest.createDir.respondCreateDir);
restServer.get('/v2/createDirQVD', rest.createDirQVD.respondCreateDirQVD);
//restServer.get('/v2/getDiskSpace', rest.getDiskSpace.respondGetDiskSpace);
restServer.get('/v2/mqttPublishMessage', rest.mqttPublishMessage.respondMQTTPublishMessage);
restServer.get('/v2/senseStartTask', rest.senseStartTask.respondSenseStartTask);
//restServer.get('/v2/senseQRSPing', rest.senseQRSPing.respondSenseQRSPing);
restServer.get('/v2/senseAppDump', rest.senseAppDump.respondSenseAppDump);
restServer.get('/v2/senseListApps', rest.senseListApps.respondSenseListApps);
restServer.get('/v2/butlerPing', rest.butlerPing.respondButlerPing);
restServer.get('/v2/base62ToBase16', rest.base62ToBase16.respondBase62ToBase16);
restServer.get('/v2/base16ToBase62', rest.base16ToBase62.respondBase16ToBase62);


// ---------------------------------------------------
// Set up MQTT
mqtt.mqtt.mqttInitHandlers();



// ---------------------------------------------------
// Set up UDP handlers
udp.udp.udpInitTaskErrorServer();<commit_msg>minor restify fixes<commit_after>// Add dependencies
var restify = require('restify');
var corsMiddleware = require('restify-cors-middleware');

// Load code from sub modules
var globals = require('./globals');
var rest = require('./rest');
var mqtt = require('./mqtt');
var udp = require('./udp');



// Set default debug level
// { error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5 }
globals.logger.transports.console.level = 'warn';


// ---------------------------------------------------
// Create restServer object
var restServer = restify.createServer({
    name: 'Butler for Qlik Sense'
});


var cors = corsMiddleware({
    preflightMaxAge: 5, //Optional
    origins: ['*'],
    allowHeaders: ['API-Token'],
    exposeHeaders: ['API-Token-Expiry']
});



// Set up restify
restServer.use(restify.plugins.queryParser({
    mapParams: true
})); // Parses the HTTP query string (i.e., /foo?id=bar&name=mark). 
restServer.use(restify.plugins.fullResponse()); // sets up all of the default headers for the system
restServer.use(restify.plugins.bodyParser()); // remaps the body content of a request to the req.params variable, allowing both GET and POST/PUT routes to use the same interface

restServer.pre(cors.preflight);
restServer.use(cors.actual);



// Set up endpoints for REST server
restServer.get('/v2/activeUserCount', rest.activeUserCount.respondActiveUserCount);
restServer.get('/v2/activeUsers', rest.activeUsers.respondActiveUsers);
restServer.get('/v2/slackPostMessage', rest.slackPostMessage.respondSlackPostMessage);
restServer.get('/v2/createDir', rest.createDir.respondCreateDir);
restServer.get('/v2/createDirQVD', rest.createDirQVD.respondCreateDirQVD);
//restServer.get('/v2/getDiskSpace', rest.getDiskSpace.respondGetDiskSpace);
restServer.get('/v2/mqttPublishMessage', rest.mqttPublishMessage.respondMQTTPublishMessage);
restServer.get('/v2/senseStartTask', rest.senseStartTask.respondSenseStartTask);
//restServer.get('/v2/senseQRSPing', rest.senseQRSPing.respondSenseQRSPing);
restServer.get('/v2/senseAppDump', rest.senseAppDump.respondSenseAppDump);
restServer.get('/v2/senseListApps', rest.senseListApps.respondSenseListApps);
restServer.get('/v2/butlerPing', rest.butlerPing.respondButlerPing);
restServer.get('/v2/base62ToBase16', rest.base62ToBase16.respondBase62ToBase16);
restServer.get('/v2/base16ToBase62', rest.base16ToBase62.respondBase16ToBase62);


// ---------------------------------------------------
// Set up MQTT
mqtt.mqtt.mqttInitHandlers();



// ---------------------------------------------------
// Set up UDP handlers
udp.udp.udpInitTaskErrorServer();
{'fraction_non_alphanumeric': 0.1954858454475899, 'fraction_numerical': 0.017214996174445295, 'mean_word_length': 3.8823529411764706, 'pattern_counts': {'":': 0, '<': 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': '292779', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1609, 'n_words': 317}