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
node_js:
- "10"
- "12"
- "14"
- "18"
notifications:
email: false
before_install:
@@ -10,4 +8,4 @@ before_install:
script:
- npm run lint
- npm test
- npm run dtslint-next
- npm run test-types

View File

@@ -3,6 +3,8 @@
const express = require('express');
const app = express();
const promClient = require('prom-client');
// replace this with require('.') when running from library code
const promBundle = require('express-prom-bundle');
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",
"version": "6.6.0",
"version": "7.0.0",
"description": "express middleware with popular prometheus metrics in one bundle",
"main": "src/index.js",
"keywords": [
@@ -14,26 +14,24 @@
"src",
"types/index.d.ts"
],
"types": "types",
"types": "types/index.d.ts",
"scripts": {
"test": "NODE_ENV=test node_modules/jasme/run.js",
"lint": "eslint src",
"coverage": "make coverage",
"dtslint": "dtslint types",
"dtslint-next": "dtslint --onlyTestTsNext types"
"test-types": "tsd"
},
"author": "Konstantin Pogorelov <or@pluseq.com>",
"license": "MIT",
"dependencies": {
"@types/express": "^4.17.21",
"express": "^4.18.2",
"on-finished": "^2.3.0",
"url-value-parser": "^2.0.0"
},
"devDependencies": {
"@types/express": "^4.16.1",
"coveralls": "^3.0.2",
"dtslint": "^0.7.1",
"dts": "^0.1.1",
"eslint": "^5.11.0",
"express": "^4.16.4",
"istanbul": "^0.4.5",
"jasme": "^6.0.0",
"koa": "^2.6.2",
@@ -41,6 +39,7 @@
"prom-client": "^13.0.0",
"supertest": "^3.3.0",
"supertest-koa-agent": "^0.3.0",
"tsd": "^0.30.3",
"typescript": "^3.4.5"
},
"peerDependencies": {
@@ -51,6 +50,6 @@
"url": "https://github.com/jochen-schweizer/express-prom-bundle.git"
},
"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 promBundle, {
type Middleware
} from '..';
import * as promBundle from 'express-prom-bundle';
// $ExpectType Middleware
const middleware: express.RequestHandler = promBundle({ includeMethod: true });
// $ExpectType: string
middleware.name;
expectType<string>(middleware.name);
promClient.register.clear();
// $ExpectType Middleware
promBundle({
expectType<Middleware>(promBundle({
normalizePath: [
// collect paths like "/customer/johnbobson" as just one "/custom/#name"
['^/customer/.*', '/customer/#name'],
@@ -27,12 +25,11 @@ promBundle({
'ORD[0-9]{5,}' // replace strings like ORD1243423, ORD673562 as #val
]
}
});
}));
promClient.register.clear();
// $ExpectType Middleware
promBundle({
expectType<Middleware>(promBundle({
buckets: [0.1, 0.4, 0.7],
includeMethod: true,
includePath: true,
@@ -60,7 +57,7 @@ promBundle({
],
formatStatusCode: (res: express.Response) => res.statusCode + 100,
metricsApp: express()
});
}));
promClient.register.clear();
@@ -90,8 +87,5 @@ wPromBundle.normalizePath = (req: express.Request, opts: promBundle.Opts) => {
wPromBundle.normalizeStatusCode = (res: express.Response) => res.statusCode.toString();
// $ExpectType RequestHandler
promBundle.clusterMetrics();
expectType<RequestHandler>(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"
}