mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Add express-correlation-id and correlation-id packages (#25710)
* feat(correlation-id & express-correlation-id): Add express-correlation-id and correlation-id packages * fix(correlation-id) Update type of bindID function
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { withId, bindId, getId } from "correlation-id";
|
||||
|
||||
withId("my-id", () => {
|
||||
const id: string = getId() || "";
|
||||
});
|
||||
|
||||
withId(() => {
|
||||
const id: string = getId() || "";
|
||||
});
|
||||
|
||||
const x: string = bindId("my-id", (foo: string, bar: number): string => {
|
||||
const id: string = getId() || "";
|
||||
|
||||
return foo + bar + id;
|
||||
})("foo", 12);
|
||||
|
||||
const y: string = bindId((foo: string, bar: number): string => {
|
||||
const id: string = getId() || "";
|
||||
|
||||
return foo + bar + id;
|
||||
})("foo", 12);
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for correlation-id 2.1
|
||||
// Project: https://github.com/toboid/correlation-id#readme
|
||||
// Definitions by: Nate <https://github.com/natemara>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function withId(id: string, work: () => void): void;
|
||||
export function withId(work: () => void): void;
|
||||
|
||||
export function bindId<T extends (...p: any[]) => any>(id: string, work: T): T;
|
||||
export function bindId<T extends (...p: any[]) => any>(work: T): T;
|
||||
|
||||
export function getId(): string | undefined;
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "correlation-id-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import * as express from "express";
|
||||
import correlator from "express-correlation-id";
|
||||
|
||||
const app = express();
|
||||
app.use(correlator());
|
||||
app.use(correlator({}));
|
||||
app.use(correlator({ header: "x-correlation-id" }));
|
||||
|
||||
const x: string = correlator.getId() || "";
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// Type definitions for express-correlation-id 1.2
|
||||
// Project: https://github.com/toboid/express-correlation-id#readme
|
||||
// Definitions by: Nate <https://github.com/natemara>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { RequestHandler } from "express-serve-static-core";
|
||||
|
||||
declare const correlator: {
|
||||
(options?: { header?: string }): RequestHandler;
|
||||
getId(): string | undefined;
|
||||
};
|
||||
|
||||
export default correlator;
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "express-correlation-id-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user