mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add definitions for: "bunyan-config", "express-mung", "node-vitalsigns" and "memwatch-next" (#11285)
* Add definition for "bunnymq".
* Add definition for "strftime".
* Add definitions for: "bunyan-config", "express-mung" and
"node-vitalsigns".
* Add definitions for: "bunyan-config", "express-mung" and
"node-vitalsigns".
* Add definition for "memwatch-next".
* Fix project URL address.
* Rename "node-vitalsigns" to "vitalsigns".
* Update definitions.
* Use {} instead of "Object" type.
Remove unnecessary namespace for "memwatch-next" definition.
Rewrite "bunyan-config" definition.
* Replace "Object" by "{}".
This commit is contained in:
parent
d3c2f19e0b
commit
df625fba9a
41
bunyan-config/bunyan-config-tests.ts
Normal file
41
bunyan-config/bunyan-config-tests.ts
Normal file
@ -0,0 +1,41 @@
|
||||
/// <reference path="bunyan-config.d.ts"/>
|
||||
|
||||
import * as bunyan from "bunyan";
|
||||
import bunyanConfig from "bunyan-config";
|
||||
|
||||
var jsonConfig = {
|
||||
name: "myLogger",
|
||||
streams: [{
|
||||
stream: "stdout"
|
||||
}, {
|
||||
stream: { name: "stderr" }
|
||||
}, {
|
||||
type: "raw",
|
||||
stream: {
|
||||
name: "bunyan-logstash",
|
||||
params: {
|
||||
host: "localhost",
|
||||
port: 5005
|
||||
}
|
||||
}
|
||||
}, {
|
||||
type: "raw",
|
||||
stream: {
|
||||
name: "bunyan-redis",
|
||||
params: {
|
||||
host: "localhost",
|
||||
port: 6379
|
||||
}
|
||||
}
|
||||
}], serializers: {
|
||||
req: "bunyan:stdSerializers.req",
|
||||
fromNodeModules: "someNodeModule",
|
||||
fromNodeModulesWithProps: "someNodeModule:a.b.c",
|
||||
custom: "./lib/customSerializers:custom",
|
||||
another: "./lib/anotherSerializer",
|
||||
absolutePath: "/path/to/serializer:xyz"
|
||||
}
|
||||
};
|
||||
|
||||
var config = bunyanConfig(jsonConfig);
|
||||
var logger = require("bunyan").createLogger(bunyanConfig);
|
||||
31
bunyan-config/bunyan-config.d.ts
vendored
Normal file
31
bunyan-config/bunyan-config.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Type definitions for bunyan-config 0.2.0
|
||||
// Project: https://github.com/LSEducation/bunyan-config
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bunyan/bunyan.d.ts"/>
|
||||
|
||||
declare module "bunyan-config" {
|
||||
import * as bunyan from "bunyan";
|
||||
|
||||
/**
|
||||
* Configuration.
|
||||
* @interface
|
||||
*/
|
||||
interface Configuration {
|
||||
name: string;
|
||||
streams?: bunyan.Stream[];
|
||||
level?: string | number;
|
||||
stream?: NodeJS.WritableStream;
|
||||
serializers?: {};
|
||||
src?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param {Configuration} [jsonConfig] A JSON configuration.
|
||||
* @return {LoggerOptions} A logger options.
|
||||
*/
|
||||
function bunyanConfig(jsonConfig?: Configuration): bunyan.LoggerOptions;
|
||||
export default bunyanConfig;
|
||||
}
|
||||
9
express-mung/express-mung-tests.ts
Normal file
9
express-mung/express-mung-tests.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/// <reference path="express-mung.d.ts"/>
|
||||
|
||||
import { Request, Response } from "express";
|
||||
import * as mung from "express-mung";
|
||||
|
||||
function redact(body: Object, req: Request, res: Response) {
|
||||
return body;
|
||||
}
|
||||
mung.json(redact);
|
||||
43
express-mung/express-mung.d.ts
vendored
Normal file
43
express-mung/express-mung.d.ts
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// Type definitions for express-mung 0.4.2
|
||||
// Project: https://github.com/richardschneider/express-mung
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../express/express.d.ts"/>
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
|
||||
declare module "express-mung" {
|
||||
import { Request, Response } from "express";
|
||||
import * as http from "http";
|
||||
|
||||
type Transform = (body: {}, request: Request, response: Response) => {};
|
||||
type TransformHeader = (body: http.IncomingMessage, request: Request, response: Response) => {};
|
||||
|
||||
/**
|
||||
* Transform the JSON body of the response.
|
||||
* @param {Transform} fn A transformation function.
|
||||
* @return {any} The body.
|
||||
*/
|
||||
export function json(fn: Transform): any;
|
||||
|
||||
/**
|
||||
* Transform the JSON body of the response.
|
||||
* @param {Transform} fn A transformation function.
|
||||
* @return {any} The body.
|
||||
*/
|
||||
export function jsonAsync(fn: Transform): PromiseLike<any>;
|
||||
|
||||
/**
|
||||
* Transform the HTTP headers of the response.
|
||||
* @param {Transform} fn A transformation function.
|
||||
* @return {any} The body.
|
||||
*/
|
||||
export function headers(fn: TransformHeader): any;
|
||||
|
||||
/**
|
||||
* Transform the HTTP headers of the response.
|
||||
* @param {Transform} fn A transformation function.
|
||||
* @return {any} The body.
|
||||
*/
|
||||
export function headersAsync(fn: TransformHeader): PromiseLike<any>;
|
||||
}
|
||||
8
memwatch-next/memwatch-next-tests.ts
Normal file
8
memwatch-next/memwatch-next-tests.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/// <reference path="memwatch-next.d.ts" />
|
||||
|
||||
import * as memwatch from "memwatch-next";
|
||||
|
||||
memwatch.on('leak', function (info) { });
|
||||
|
||||
var hd = new memwatch.HeapDiff();
|
||||
var diff = hd.end();
|
||||
71
memwatch-next/memwatch-next.d.ts
vendored
Normal file
71
memwatch-next/memwatch-next.d.ts
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
// Type definitions for memwatch-next 0.3.0
|
||||
// Project: https://github.com/marcominetti/node-memwatch
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "memwatch-next" {
|
||||
type EventCallback = (data: LeakInformation | StatsInformation | Object) => void;
|
||||
|
||||
/**
|
||||
* Compare the state of your heap between two points in time, telling you what has been allocated, and what has been released.
|
||||
* @class
|
||||
*/
|
||||
export class HeapDiff {
|
||||
/**
|
||||
* Compute the diff.
|
||||
*/
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stats information.
|
||||
* @interface
|
||||
*/
|
||||
export interface StatsInformation {
|
||||
current_base: number;
|
||||
estimated_base: number;
|
||||
heap_compactions: number;
|
||||
max: number;
|
||||
min: number;
|
||||
num_full_gc: number;
|
||||
num_inc_gc: number;
|
||||
usage_trend: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Leak information.
|
||||
* @interface
|
||||
*/
|
||||
export interface LeakInformation {
|
||||
/**
|
||||
* End date.
|
||||
* @type {Date}
|
||||
*/
|
||||
end: Date,
|
||||
|
||||
/**
|
||||
* Growth.
|
||||
* @type {number}
|
||||
*/
|
||||
growth: number;
|
||||
|
||||
/**
|
||||
* Reason leak.
|
||||
* @type {string}
|
||||
*/
|
||||
reason: string;
|
||||
|
||||
/**
|
||||
* Start date.
|
||||
* @type {Date}
|
||||
*/
|
||||
start: Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to a event.
|
||||
* @param {string} eventName A event name.
|
||||
* @param {EventCallback} callback A callback;
|
||||
*/
|
||||
export function on(eventName: string, callback: EventCallback): void;
|
||||
}
|
||||
25
vitalsigns/vitalsigns-tests.ts
Normal file
25
vitalsigns/vitalsigns-tests.ts
Normal file
@ -0,0 +1,25 @@
|
||||
/// <reference path="vitalsigns.d.ts"/>
|
||||
|
||||
import VitalSigns = require("vitalsigns");
|
||||
|
||||
var vitals = new VitalSigns();
|
||||
|
||||
vitals.monitor('cpu');
|
||||
vitals.monitor('mem', {units: 'MB'});
|
||||
vitals.monitor('tick');
|
||||
|
||||
vitals.unhealthyWhen('cpu', 'usage').equals(100);
|
||||
vitals.unhealthyWhen('tick', 'maxMs').greaterThan(500);
|
||||
|
||||
vitals.monitor({
|
||||
connections: () => new Object()
|
||||
}, {name: 'game'});
|
||||
|
||||
var vitals = new VitalSigns({
|
||||
autoCheck: 5000,
|
||||
httpHealthy: 200,
|
||||
httpUnhealthy: 503
|
||||
});
|
||||
|
||||
vitals.monitor('cpu', {name: 'foo'});
|
||||
vitals.unhealthyWhen('foo', 'bar').not.greaterThan(5);
|
||||
192
vitalsigns/vitalsigns.d.ts
vendored
Normal file
192
vitalsigns/vitalsigns.d.ts
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
// Type definitions for vitalsigns 0.4.3
|
||||
// Project: https://github.com/TomFrost/node-vitalsigns
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "vitalsigns" {
|
||||
namespace vitalsigns {
|
||||
/**
|
||||
* Contraint.
|
||||
* @interface
|
||||
*/
|
||||
export interface Constraint {
|
||||
/**
|
||||
* The comparator to use when comparing the field's value with the constraint value.
|
||||
* Valid comparators are: 'equal', 'greater', and 'less'.
|
||||
* @type {string}
|
||||
*/
|
||||
comparator: string;
|
||||
|
||||
/**
|
||||
* The name of the field to be constrained.
|
||||
* @type {string}
|
||||
*/
|
||||
field: string;
|
||||
|
||||
/**
|
||||
* The name of the monitor containing the field to be constrained.
|
||||
* @type {string}
|
||||
*/
|
||||
monitor: string;
|
||||
|
||||
/**
|
||||
* true to negate the outcome of the comparison; false or omitted to use the comparison result.
|
||||
* @type {boolean}
|
||||
*/
|
||||
negate?: boolean;
|
||||
|
||||
/**
|
||||
* The value against which the field should be compared.
|
||||
* @type {any}
|
||||
*/
|
||||
value: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constraint wrapper.
|
||||
* @interface
|
||||
*/
|
||||
export interface ConstraintWrapper {
|
||||
equals?: (num: number) => ConstraintWrapper;
|
||||
|
||||
greaterThan?: (num: number) => ConstraintWrapper;
|
||||
|
||||
lessThan?: (num: number) => ConstraintWrapper;
|
||||
|
||||
not?: ConstraintWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options.
|
||||
* @interface
|
||||
*/
|
||||
export interface Options {
|
||||
/**
|
||||
* Number of milliseconds to wait between automatic health checks.
|
||||
* @type {number|boolean}
|
||||
*/
|
||||
autoCheck?: number | boolean;
|
||||
|
||||
/**
|
||||
* HTTP response code to send back in the VitalSigns.
|
||||
* @type {number}
|
||||
*/
|
||||
httpHealthy?: number;
|
||||
|
||||
/**
|
||||
* HTTP response code to send back in the VitalSigns.
|
||||
* @type {number}
|
||||
*/
|
||||
httpUnhealthy?: number;
|
||||
}
|
||||
|
||||
export interface Monitor {
|
||||
/**
|
||||
* Connections.
|
||||
* @type {any}
|
||||
*/
|
||||
connections: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor field.
|
||||
* @interface
|
||||
*/
|
||||
export interface MonitorField {
|
||||
/**
|
||||
* Name.
|
||||
* @type {string}
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Units.
|
||||
* @type {string}
|
||||
*/
|
||||
units?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report options.
|
||||
* @interface
|
||||
*/
|
||||
interface ReportOptions {
|
||||
/**
|
||||
* true to flatten the report object down to a single level by concatenating nested key names; false to keep the default hierarchical format.
|
||||
* @type {boolean}
|
||||
*/
|
||||
flatten?: boolean;
|
||||
|
||||
/**
|
||||
* If flatten is true, this string will be used to separate key names when they are concatenated together.
|
||||
* @type {boolean}
|
||||
*/
|
||||
separator?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* VitalSigns instance.
|
||||
*/
|
||||
class VitalSigns {
|
||||
/**
|
||||
* Constructor.
|
||||
* @constructors
|
||||
* @param {Options} [options] Options.
|
||||
*/
|
||||
constructor (options?: vitalsigns.Options);
|
||||
|
||||
/**
|
||||
* Pushes a health constraint onto this instance's constraint array.
|
||||
* Health constraints define scenarios in which VitalSigns will consider the application to be in an unhealthy state.
|
||||
* @param {} constraint A constraint.
|
||||
*/
|
||||
addConstraint(): void;
|
||||
|
||||
/**
|
||||
* Destroys this VitalSigns instance.
|
||||
*/
|
||||
destroy(): void;
|
||||
|
||||
/**
|
||||
* Retrieves an array of human-readable messages that define the specific health constraints that failed when running the last health check.
|
||||
* @returns {Array<string>} An array of failure messages.
|
||||
*/
|
||||
getFailed(): Array<string>;
|
||||
|
||||
/**
|
||||
* Gets a report of all monitors, their fields, and the values of those fields, compiled into Javascript object form. Additionally, a 'healthy' field is
|
||||
* attached. This field will be boolean true if all health constraints passed; false otherwise.
|
||||
* @param {ReportOptions} [options] A mapping of options to customize this report.
|
||||
* @return {Object} The full health report.
|
||||
*/
|
||||
getReport(options?: vitalsigns.ReportOptions): Object;
|
||||
|
||||
/**
|
||||
* Generates a health report and checks each health constraint against it. Any constraints that fail will be added to the 'failed' array in the form of
|
||||
* a human-readable failure message, which can be retrieved with {@link #getFailed}.
|
||||
* @param {Object} [report] A report object on which to run the health constraints. If omitted, this function will generate a health report automatically.
|
||||
* @return {boolean} true if all health constraints passed; false otherwise.
|
||||
*/
|
||||
isHealthy(report?: Object): boolean;
|
||||
|
||||
/**
|
||||
* Registers monitor.
|
||||
* @param {string} monitorName A monitor name.
|
||||
* @param {MonitorField} [field] Options.
|
||||
*/
|
||||
monitor(monitor: string | vitalsigns.Monitor | Object, field?: vitalsigns.MonitorField): void;
|
||||
|
||||
/**
|
||||
* Defines a new health constraint in a chainable, more easily readable format.
|
||||
* When called with the monitor name and field name of concern, a wrapper is
|
||||
* returned that allows the constraint to be built out with function calls.
|
||||
* @param {string} monitorName A monitor name.
|
||||
* @param {string} fieldName A field name.
|
||||
* @return {ConstraintWrapper} The constraint wrapper.
|
||||
*/
|
||||
unhealthyWhen: (monitorName: string, fieldName: string) => vitalsigns.ConstraintWrapper;
|
||||
}
|
||||
|
||||
export = VitalSigns;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user