45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import * as plugins from './smartnginx.plugins';
|
|
import * as paths from './smartnginx.paths';
|
|
import * as snippets from './smartnginx.snippets';
|
|
|
|
import { SmartNginx } from './smartnginx.classes.smartnginx';
|
|
|
|
import { IHostConfig } from './interfaces/hostconfig';
|
|
|
|
export enum hostTypes {
|
|
reverseProxy
|
|
}
|
|
|
|
/**
|
|
* manages a single nginx host
|
|
*/
|
|
export class NginxHost implements IHostConfig {
|
|
/**
|
|
* smartnginxInstance this NginHost belongs to
|
|
*/
|
|
smartnginxInstance: SmartNginx;
|
|
|
|
hostName: string; // the host name e.g. domain name
|
|
destination: string;
|
|
configString: string; // the actual host config file as string
|
|
privateKey: string;
|
|
publicKey: string;
|
|
|
|
constructor(smartnginxInstanceArg: SmartNginx, optionsArg: IHostConfig) {
|
|
this.smartnginxInstance = smartnginxInstanceArg;
|
|
this.hostName = optionsArg.hostName;
|
|
this.destination = optionsArg.destination;
|
|
this.configString = snippets.getHostConfigString(optionsArg.hostName, optionsArg.destination);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param certInstanceArg
|
|
*/
|
|
public async deploy() {
|
|
const filePath = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.conf`);
|
|
// writeConfig
|
|
plugins.smartfile.memory.toFsSync(this.configString, filePath);
|
|
}
|
|
}
|