From 845c8163312e58516af44f1c14545addcfbd9011 Mon Sep 17 00:00:00 2001 From: Steve Konves Date: Tue, 15 May 2018 23:29:49 -0700 Subject: [PATCH] chore: add typescript typings (#9) --- index.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..7e84f32 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,18 @@ +import { Request, Response, NextFunction } from "express"; + +/** Express.js middleware that is responsible for initializing the context for each request. */ +export declare function middleware( + req: Request, + res: Response, + next: NextFunction +): void; + +/** + * Gets a value from the context by key. Will return undefined if the context has not yet been initialized for this request or if a value is not found for the specified key. + */ +export declare function get(key: string): any; + +/** + * Adds a value to the context by key. If the key already exists, its value will be overwritten. No value will persist if the context has not yet been initialized. + */ +export declare function set(key: string, value: any): void;