-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
32 lines (25 loc) · 1.09 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import http from 'http';
import express from 'express';
interface MaskOptions {
placeholder?: string;
}
interface LogOptions {
maxBodyLen?: number;
mask?: MaskOptions & { fields?: string[] };
}
type RequestKeys = 'ip' | 'ips' | 'hostname' | 'protocol' | 'method' | 'path' | 'fresh' | 'subdomains' | 'xhr' | 'headers' | 'trailers' | 'query' | 'params';
type ResponseKeys = 'locals';
interface Log extends Pick<express.Request, RequestKeys>, Pick<express.Response, ResponseKeys> {
url: string;
referer: string;
userAgent: string;
protocolVersion: typeof express.request.httpVersion;
responseHeaders: http.OutgoingHttpHeaders;
// TODO: annotate properties from third party libraries such as express-session, cookie-parser
}
declare function ExpressLoggingJson(req: express.Request, res: express.Response, options?: LogOptions): Log;
declare namespace ExpressLoggingJson {
function format(req: express.Request, res: express.Response, options?: LogOptions): Log;
function mask(obj: object, fields: string[], options?: MaskOptions): void;
}
export = ExpressLoggingJson;