generate-nginx-config-for-thingies
Version:
Small cli which generates the appropriate nginx configuration files which will then later reside in /etc/nginx/sites-enabled directory.
63 lines (51 loc) • 1.93 kB
JavaScript
// Generated by CoffeeScript 2.5.1
(function() {
var fs, genconfigprocessmodule, log, nginxConf, pathHandler, processAllThingies;
genconfigprocessmodule = {
name: "genconfigprocessmodule"
};
//###########################################################
log = function(arg) {
if (allModules.debugmodule.modulesToDebug["genconfigprocessmodule"] != null) {
console.log("[genconfigprocessmodule]: " + arg);
}
};
//###########################################################
fs = require("fs");
//###########################################################
pathHandler = null;
nginxConf = null;
//###########################################################
genconfigprocessmodule.initialize = function() {
log("genconfigprocessmodule.initialize");
pathHandler = allModules.pathhandlermodule;
return nginxConf = allModules.nginxconfigmodule;
};
//###########################################################
processAllThingies = async function() {
var config, promises, requirePath, thingy;
log("processAllThingies");
requirePath = pathHandler.getConfigRequirePath();
config = require(requirePath);
promises = (function() {
var i, len, ref, results;
ref = config.thingies;
results = [];
for (i = 0, len = ref.length; i < len; i++) {
thingy = ref[i];
results.push(nginxConf.generateForThingy(thingy));
}
return results;
})();
return (await Promise.all(promises));
};
//###########################################################
genconfigprocessmodule.execute = async function(configPath, outputDirectory) {
log("genconfigprocessmodule.execute");
await pathHandler.setConfigFilePath(configPath);
await pathHandler.setOutputDirectory(outputDirectory);
await processAllThingies();
return true;
};
module.exports = genconfigprocessmodule;
}).call(this);