35 lines
2.6 KiB
JavaScript
35 lines
2.6 KiB
JavaScript
"use strict";
|
|
const plugins = require("./smartnginx.plugins");
|
|
const paths = require("./smartnginx.paths");
|
|
const snippets = require("./smartnginx.snippets");
|
|
(function (hostTypes) {
|
|
hostTypes[hostTypes["reverseProxy"] = 0] = "reverseProxy";
|
|
hostTypes[hostTypes["static"] = 1] = "static";
|
|
})(exports.hostTypes || (exports.hostTypes = {}));
|
|
var hostTypes = exports.hostTypes;
|
|
/**
|
|
* manages a single nginx host
|
|
*/
|
|
class NginxHost {
|
|
constructor(optionsArg) {
|
|
this.hostName = optionsArg.hostName;
|
|
this.type = optionsArg.type;
|
|
this.destination = optionsArg.destination;
|
|
this.configString = snippets.getHostConfigString(optionsArg.hostName, optionsArg.destination);
|
|
}
|
|
;
|
|
deploy(certInstanceArg) {
|
|
let done = plugins.q.defer();
|
|
let filePath = plugins.path.join(paths.nginxHostFileBase, this.hostName + ".conf");
|
|
// writeConfig
|
|
plugins.smartfile.memory.toFsSync(this.configString, filePath);
|
|
// get cert
|
|
certInstanceArg.getDomainCert(this.hostName)
|
|
.then(done.resolve);
|
|
return done.promise;
|
|
}
|
|
;
|
|
}
|
|
exports.NginxHost = NginxHost;
|
|
;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jbGFzc2VzLm5naW54aG9zdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bmdpbnguY2xhc3Nlcy5uZ2lueGhvc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsTUFBWSxLQUFLLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUM1QyxNQUFZLFFBQVEsV0FBTSx1QkFLMUIsQ0FBQyxDQUxnRDtBQVdqRCxXQUFZLFNBQVM7SUFDakIseUR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