switch from dtslint to tsd, update required node to >=18, bump version to 7.0.0

This commit is contained in:
Konstantin Pogorelov
2024-01-05 22:04:31 +01:00
parent 0bda9934c1
commit a0eef5d0e2
7 changed files with 3089 additions and 1750 deletions

View File

@@ -1,8 +1,6 @@
language: node_js language: node_js
node_js: node_js:
- "10" - "18"
- "12"
- "14"
notifications: notifications:
email: false email: false
before_install: before_install:
@@ -10,4 +8,4 @@ before_install:
script: script:
- npm run lint - npm run lint
- npm test - npm test
- npm run dtslint-next - npm run test-types

View File

@@ -3,6 +3,8 @@
const express = require('express'); const express = require('express');
const app = express(); const app = express();
const promClient = require('prom-client'); const promClient = require('prom-client');
// replace this with require('.') when running from library code
const promBundle = require('express-prom-bundle'); const promBundle = require('express-prom-bundle');
const bundle = promBundle({ const bundle = promBundle({

4769
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "express-prom-bundle", "name": "express-prom-bundle",
"version": "6.6.0", "version": "7.0.0",
"description": "express middleware with popular prometheus metrics in one bundle", "description": "express middleware with popular prometheus metrics in one bundle",
"main": "src/index.js", "main": "src/index.js",
"keywords": [ "keywords": [
@@ -14,26 +14,24 @@
"src", "src",
"types/index.d.ts" "types/index.d.ts"
], ],
"types": "types", "types": "types/index.d.ts",
"scripts": { "scripts": {
"test": "NODE_ENV=test node_modules/jasme/run.js", "test": "NODE_ENV=test node_modules/jasme/run.js",
"lint": "eslint src", "lint": "eslint src",
"coverage": "make coverage", "coverage": "make coverage",
"dtslint": "dtslint types", "test-types": "tsd"
"dtslint-next": "dtslint --onlyTestTsNext types"
}, },
"author": "Konstantin Pogorelov <or@pluseq.com>", "author": "Konstantin Pogorelov <or@pluseq.com>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/express": "^4.17.21",
"express": "^4.18.2",
"on-finished": "^2.3.0", "on-finished": "^2.3.0",
"url-value-parser": "^2.0.0" "url-value-parser": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^4.16.1", "dts": "^0.1.1",
"coveralls": "^3.0.2",
"dtslint": "^0.7.1",
"eslint": "^5.11.0", "eslint": "^5.11.0",
"express": "^4.16.4",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"jasme": "^6.0.0", "jasme": "^6.0.0",
"koa": "^2.6.2", "koa": "^2.6.2",
@@ -41,6 +39,7 @@
"prom-client": "^13.0.0", "prom-client": "^13.0.0",
"supertest": "^3.3.0", "supertest": "^3.3.0",
"supertest-koa-agent": "^0.3.0", "supertest-koa-agent": "^0.3.0",
"tsd": "^0.30.3",
"typescript": "^3.4.5" "typescript": "^3.4.5"
}, },
"peerDependencies": { "peerDependencies": {
@@ -51,6 +50,6 @@
"url": "https://github.com/jochen-schweizer/express-prom-bundle.git" "url": "https://github.com/jochen-schweizer/express-prom-bundle.git"
}, },
"engines": { "engines": {
"node": ">=10" "node": ">=18"
} }
} }

View File

@@ -1,19 +1,17 @@
import * as express from 'express'; import express, { RequestHandler } from 'express';
import { expectType } from 'tsd'
import * as promClient from 'prom-client'; import * as promClient from 'prom-client';
import promBundle, {
type Middleware
} from '..';
import * as promBundle from 'express-prom-bundle';
// $ExpectType Middleware
const middleware: express.RequestHandler = promBundle({ includeMethod: true }); const middleware: express.RequestHandler = promBundle({ includeMethod: true });
// $ExpectType: string expectType<string>(middleware.name);
middleware.name;
promClient.register.clear(); promClient.register.clear();
// $ExpectType Middleware expectType<Middleware>(promBundle({
promBundle({
normalizePath: [ normalizePath: [
// collect paths like "/customer/johnbobson" as just one "/custom/#name" // collect paths like "/customer/johnbobson" as just one "/custom/#name"
['^/customer/.*', '/customer/#name'], ['^/customer/.*', '/customer/#name'],
@@ -27,12 +25,11 @@ promBundle({
'ORD[0-9]{5,}' // replace strings like ORD1243423, ORD673562 as #val 'ORD[0-9]{5,}' // replace strings like ORD1243423, ORD673562 as #val
] ]
} }
}); }));
promClient.register.clear(); promClient.register.clear();
// $ExpectType Middleware expectType<Middleware>(promBundle({
promBundle({
buckets: [0.1, 0.4, 0.7], buckets: [0.1, 0.4, 0.7],
includeMethod: true, includeMethod: true,
includePath: true, includePath: true,
@@ -60,7 +57,7 @@ promBundle({
], ],
formatStatusCode: (res: express.Response) => res.statusCode + 100, formatStatusCode: (res: express.Response) => res.statusCode + 100,
metricsApp: express() metricsApp: express()
}); }));
promClient.register.clear(); promClient.register.clear();
@@ -90,8 +87,5 @@ wPromBundle.normalizePath = (req: express.Request, opts: promBundle.Opts) => {
wPromBundle.normalizeStatusCode = (res: express.Response) => res.statusCode.toString(); wPromBundle.normalizeStatusCode = (res: express.Response) => res.statusCode.toString();
// $ExpectType RequestHandler expectType<RequestHandler>(promBundle.clusterMetrics());
promBundle.clusterMetrics();
// Missing test
// const stringReturn: string = promBundle.normalizePath({}, {});

View File

@@ -1,14 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": ".",
"paths": { "express-prom-bundle": ["."] },
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}

View File

@@ -1,3 +0,0 @@
{
"extends": "dtslint/dtslint.json"
}