simple-prom/index.ts

34 lines
734 B
TypeScript

// Copyright (c) Holly Stubbs (tgpholly) - Licensed under MIT
// Check LICENSE in repository root for more information.
import { createServer, Server } from "http";
import IConfig from "./interfaces/IConfig";
export default abstract class SimpleProm {
static instance?:SimpleProm;
public config:IConfig;
public selfHostServer?:Server;
private constructor(config:IConfig) {
SimpleProm.instance?.end();
SimpleProm.instance = this;
this.config = config;
this.selfHostServer = createServer((req, res) => {
res.end("SimpleProm exporter");
});
}
static init(config:IConfig) {
}
public end() {
if (this.selfHostServer) {
this.selfHostServer.close();
this.selfHostServer.closeAllConnections();
}
}
}