mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-03-18 21:30:38 +01:00
add unit test, fix dev dependencies, add Makefile
This commit is contained in:
4
Makefile
Normal file
4
Makefile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
test:
|
||||||
|
./node_modules/jasme/run.js
|
||||||
|
lint:
|
||||||
|
node_modules/eslint/bin/eslint.js .
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "express-prom-bundle",
|
"name": "express-prom-bundle",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "express middleware with standard prometheus metrics in one bundle",
|
"description": "express middleware with popular prometheus metrics in one bundle",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
"prom-client": "^3.4.0"
|
"prom-client": "^3.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^2.8.0"
|
"eslint": "^2.8.0",
|
||||||
|
"express": "^4.13.4",
|
||||||
|
"jasme": "^4.1.1",
|
||||||
|
"supertest": "^1.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
24
spec/indexSpec.js
Normal file
24
spec/indexSpec.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
"use strict";
|
||||||
|
/* eslint-env jasmine */
|
||||||
|
|
||||||
|
let express = require("express"),
|
||||||
|
request = require("supertest"),
|
||||||
|
bundle = require("../");
|
||||||
|
|
||||||
|
describe("index", () => {
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
app.use(bundle({
|
||||||
|
prefix: "hello"
|
||||||
|
}));
|
||||||
|
|
||||||
|
it("/metrics returns up=1", done => {
|
||||||
|
request(app)
|
||||||
|
.get("/metrics")
|
||||||
|
.end((err, res) => {
|
||||||
|
expect(res.status).toBe(200);
|
||||||
|
expect(res.text).toMatch(/hello:up\s1/);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const onFinished = require("on-finished");
|
|
||||||
|
|
||||||
module.exports = class {
|
module.exports = class {
|
||||||
constructor(opts, promClient) {
|
constructor(opts) {
|
||||||
this.opts = opts || {};
|
this.opts = opts || {};
|
||||||
this.promClient = this.opts.promClient || require("prom-client");
|
this.promClient = this.opts.promClient || require("prom-client");
|
||||||
this.metrics = {};
|
this.metrics = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user