This commit is contained in:
Holly Stubbs 2024-07-02 10:20:16 +01:00
parent 8966727672
commit fdc66a6bc4
5 changed files with 1728 additions and 1705 deletions

View File

@ -3,8 +3,9 @@
import { createServer, Server } from "http";
import IConfig from "./interfaces/IConfig";
import IMetric from "./interfaces/IMetric";
export default abstract class SimpleProm {
export default class SimpleProm {
static instance?:SimpleProm;
public config:IConfig;
@ -16,12 +17,26 @@ export default abstract class SimpleProm {
this.config = config;
this.selfHostServer = createServer((req, res) => {
res.end("SimpleProm exporter");
});
if (this.config.selfHost) {
this.config.selfHostPort = this.config.selfHostPort ?? 9100;
this.selfHostServer = createServer((req, res) => {
res.end("SimpleProm exporter");
});
this.selfHostServer.listen(this.config.selfHostPort);
}
}
static init(config:IConfig) {
return new SimpleProm(config);
}
public addMetric(metric:IMetric) {
}
public removeMetric(metric:IMetric) {
}

3
interfaces/IMetric.ts Normal file
View File

@ -0,0 +1,3 @@
export default interface IMetric {
}

3400
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "A simple and easy to use module for Prometheus metric exporting.",
"main": "./lib/index.js",
"types": "./lib/index.d.js",
"types": "./lib/index.d.ts",
"scripts": {
"updateCheck": "check-outdated",
"_clean": "tsc --build --clean",

5
test/testServer.ts Normal file
View File

@ -0,0 +1,5 @@
import SimpleProm from "..";
SimpleProm.init({
selfHost: true
});