smartnginx/ts/smartnginx.classes.nginxzone.ts
2016-07-25 01:54:36 +02:00

34 lines
1.1 KiB
TypeScript

import * as plugins from "./smartnginx.plugins";
import * as paths from "./smartnginx.paths";
import * as snippets from "./smartnginx.snippets"
export enum zoneTypes {
reverseProxy,
static
}
export class NginxZone {
zoneName: string; // the zone name e.g. domain name
type: zoneTypes;
destination: string;
configString: string; // the actual zone config file as string
constructor(optionsArg: {
zoneName: string,
type: zoneTypes,
destination: string
}) {
this.zoneName = optionsArg.zoneName;
this.type = optionsArg.type;
this.destination = optionsArg.destination;
this.configString = snippets.getZoneConfigString(optionsArg.zoneName, optionsArg.destination);
};
deploy(certInstanceArg: plugins.cert.Cert) {
let done = plugins.q.defer();
let filePath = plugins.path.join(paths.nginxZoneBase, this.zoneName + ".conf");
// writeConfig
plugins.smartfile.memory.toFsSync(this.configString, filePath);
// get cert
certInstanceArg.getDomainCert(this.zoneName)
.then(done.resolve);
return done.promise;
};
};