mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Create typings for honeybadger module (#39152)
* Created typings for honeybadger module * slight improvements to typings, tslint now has no extra rules. * Update index.d.ts * Update index.d.ts
This commit is contained in:
parent
0c600dcb5b
commit
8f94a1423f
38
types/honeybadger/honeybadger-tests.ts
Normal file
38
types/honeybadger/honeybadger-tests.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import Honeybadger = require("honeybadger");
|
||||
|
||||
Honeybadger.configure({
|
||||
apiKey: "abcdef"
|
||||
});
|
||||
|
||||
const err = Error("error");
|
||||
|
||||
Honeybadger.notify(err, function notifyCallback(err: Error, notice: any) {
|
||||
if (err) console.error(err);
|
||||
console.log(notice);
|
||||
});
|
||||
|
||||
Honeybadger.setContext({
|
||||
user_id: 123
|
||||
});
|
||||
|
||||
Honeybadger.resetContext();
|
||||
|
||||
Honeybadger.resetContext({
|
||||
user_id: 123
|
||||
});
|
||||
|
||||
const other_hb = Honeybadger.factory({apiKey: "zxcvbnm"});
|
||||
other_hb.notify("This will go to an alternate project.");
|
||||
|
||||
Honeybadger.onUncaughtException(err => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
function handler(event: any, context: any) {
|
||||
console.log('Event:', event);
|
||||
console.log('Context:', context);
|
||||
throw(new Error('Something went wrong.'));
|
||||
console.log("Shouldn't make it here.");
|
||||
}
|
||||
|
||||
exports.handler = Honeybadger.lambdaHandler(handler);
|
||||
49
types/honeybadger/index.d.ts
vendored
Normal file
49
types/honeybadger/index.d.ts
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
// Type definitions for honeybadger 1.3
|
||||
// Project: https://github.com/honeybadger-io/honeybadger-node
|
||||
// Definitions by: Ryan Skrzypek <https://github.com/rskrz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import { RequestHandler, ErrorRequestHandler } from "express";
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
declare namespace honeybadger {
|
||||
interface ConfigureOptions {
|
||||
apiKey: string;
|
||||
endpoint?: string;
|
||||
hostname?: string;
|
||||
environment?: string;
|
||||
projectRoot?: string;
|
||||
logger?: Console;
|
||||
developmentEnvironment?: ReadonlyArray<string>;
|
||||
filters?: ReadonlyArray<string>;
|
||||
}
|
||||
interface metadata {
|
||||
name?: string;
|
||||
message?: string;
|
||||
context?: object;
|
||||
session?: object;
|
||||
headers?: object;
|
||||
params?: object;
|
||||
cgiData?: object;
|
||||
url?: string;
|
||||
component?: string;
|
||||
action?: string;
|
||||
fingerprint?: string;
|
||||
}
|
||||
type CallbackFunction = (err: Error | null, notice: object | null) => void;
|
||||
type LambdaHandler = (event: object, context: object) => void;
|
||||
interface HoneyBadgerInstance extends EventEmitter {
|
||||
configure: (options: ConfigureOptions) => void;
|
||||
notify: (err?: any, name?: any, extra?: CallbackFunction | metadata, callback?: CallbackFunction) => void;
|
||||
setContext: (context: object) => void;
|
||||
resetContext: (context?: object) => void;
|
||||
factory: (options?: ConfigureOptions) => HoneyBadgerInstance;
|
||||
errorHandler: ErrorRequestHandler;
|
||||
requestHandler: RequestHandler;
|
||||
lambdaHandler: (handler: LambdaHandler) => LambdaHandler;
|
||||
onUncaughtException: (func: (error: Error) => void) => void;
|
||||
}
|
||||
}
|
||||
declare const honeybadger: honeybadger.HoneyBadgerInstance;
|
||||
export = honeybadger;
|
||||
23
types/honeybadger/tsconfig.json
Normal file
23
types/honeybadger/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"honeybadger-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/honeybadger/tslint.json
Normal file
3
types/honeybadger/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user