smartnginx/ts/smartnginx.classes.nginxzone.ts

34 lines
1.1 KiB
TypeScript
Raw Normal View History

2016-07-06 06:30:33 +00:00
import * as plugins from "./smartnginx.plugins";
import * as paths from "./smartnginx.paths";
import * as snippets from "./smartnginx.snippets"
export enum zoneTypes {
2016-07-24 23:54:36 +00:00
reverseProxy,
static
2016-07-06 06:30:33 +00:00
}
export class NginxZone {
2016-07-24 23:54:36 +00:00
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
}) {
2016-07-08 02:24:07 +00:00
this.zoneName = optionsArg.zoneName;
this.type = optionsArg.type;
this.destination = optionsArg.destination;
2016-07-24 23:54:36 +00:00
this.configString = snippets.getZoneConfigString(optionsArg.zoneName, optionsArg.destination);
2016-07-06 06:30:33 +00:00
};
2016-07-24 23:54:36 +00:00
deploy(certInstanceArg: plugins.cert.Cert) {
2016-07-12 21:11:57 +00:00
let done = plugins.q.defer();
2016-07-24 23:54:36 +00:00
let filePath = plugins.path.join(paths.nginxZoneBase, this.zoneName + ".conf");
2016-07-12 21:11:57 +00:00
// writeConfig
2016-07-24 23:54:36 +00:00
plugins.smartfile.memory.toFsSync(this.configString, filePath);
2016-07-12 21:11:57 +00:00
// get cert
certInstanceArg.getDomainCert(this.zoneName)
.then(done.resolve);
return done.promise;
2016-07-06 06:30:33 +00:00
};
};