added types for express-status-monitor (#38977)

This commit is contained in:
Alex
2019-10-08 14:34:06 -07:00
committed by Armando Aguirre
parent 88963b877d
commit af62dd2b9a
4 changed files with 112 additions and 0 deletions
@@ -0,0 +1,43 @@
import express = require('express');
import expressStatusMonitor = require('express-status-monitor');
import socketIO = require('socket.io');
const app = express();
app.use(expressStatusMonitor());
app.use(
expressStatusMonitor({
title: 'Type Test',
theme: 'default.css',
path: '/status',
socketPath: '/socket.io',
websocket: null,
chartVisibility: {
cpu: true,
mem: false,
load: true,
},
ignoreStartsWith: '/admin',
healthChecks: [],
}),
);
app.use(
expressStatusMonitor({
spans: [{ interval: 10000, retention: 60 * 1000 }],
healthChecks: [
{
protocol: 'http',
host: 'localhost',
path: '/healthcheck',
port: '4000',
},
],
}),
);
const io = socketIO.listen(80);
app.use(
expressStatusMonitor({
websocket: io,
}),
);
+45
View File
@@ -0,0 +1,45 @@
// Type definitions for express-status-monitor 1.2
// Project: https://github.com/RafalWilinski/express-status-monitor#readme
// Definitions by: Alex Anderson <https://github.com/me>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="socket.io" />
import express = require('express');
declare namespace e {
interface ExpressStatusMonitorConfig {
title?: string;
theme?: string;
path?: string;
socketPath?: string;
websocket?: SocketIO.Server | null; // References a socket.io instance
spans?: RetentionSpan[];
chartVisibility?: {
cpu?: boolean;
mem?: boolean;
load?: boolean;
responseTime?: boolean;
rps?: boolean;
statusCodes?: boolean;
};
healthChecks?: HealthCheck[];
ignoreStartsWith?: string;
}
interface RetentionSpan {
interval: number;
retention: number;
}
interface HealthCheck {
protocol: string;
host: string;
path: string;
port: string | number;
}
}
declare function e(config?: e.ExpressStatusMonitorConfig): express.RequestHandler;
export = e;
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"express-status-monitor-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }