From d12aef03dffe37c9bca266bc253250078253e5c7 Mon Sep 17 00:00:00 2001 From: Dylan Scott Date: Tue, 17 Apr 2018 08:37:05 -0700 Subject: [PATCH] express-winston: relax types on meta object (#25036) * express-winston: relax types on meta object * express-winston: change meta object type to --- types/express-winston/express-winston-tests.ts | 4 ++-- types/express-winston/index.d.ts | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/types/express-winston/express-winston-tests.ts b/types/express-winston/express-winston-tests.ts index 7fd41cfd5c..5671160de0 100644 --- a/types/express-winston/express-winston-tests.ts +++ b/types/express-winston/express-winston-tests.ts @@ -6,7 +6,7 @@ const app = express(); // Logger with all options app.use(expressWinston.logger({ - baseMeta: { foo: 'foo' }, + baseMeta: { foo: 'foo', nested: { bar: 'baz' } }, bodyBlacklist: ['foo'], bodyWhitelist: ['bar'], colorize: true, @@ -47,7 +47,7 @@ app.use(expressWinston.logger({ // Error Logger with all options app.use(expressWinston.errorLogger({ - baseMeta: { foo: 'foo' }, + baseMeta: { foo: 'foo', nested: { bar: 'baz' } }, dynamicMeta: (req, res, err) => ({ foo: 'bar' }), level: (req, res) => 'level', metaField: 'metaField', diff --git a/types/express-winston/index.d.ts b/types/express-winston/index.d.ts index 6dac70c1b6..e6184f64b9 100644 --- a/types/express-winston/index.d.ts +++ b/types/express-winston/index.d.ts @@ -7,18 +7,14 @@ import { ErrorRequestHandler, Handler, Request, Response } from 'express'; import { TransportInstance, Winston } from 'winston'; -export interface MetaObject { - [field: string]: string; -} - -export type DynamicMetaFunction = (req: Request, res: Response, err: Error) => MetaObject | undefined; +export type DynamicMetaFunction = (req: Request, res: Response, err: Error) => object; export type DynamicLevelFunction = (req: Request, res: Response, err: Error) => string; export type RequestFilter = (req: Request, propName: string) => boolean; export type ResponseFilter = (res: Response, propName: string) => boolean; export type RouteFilter = (req: Request, res: Response) => boolean; export interface BaseLoggerOptions { - baseMeta?: MetaObject; + baseMeta?: object; bodyBlacklist?: string[]; bodyWhitelist?: string[]; colorize?: boolean; @@ -55,7 +51,7 @@ export type LoggerOptions = LoggerOptionsWithTransports | LoggerOptionsWithWinst export function logger(options: LoggerOptions): Handler; export interface BaseErrorLoggerOptions { - baseMeta?: MetaObject; + baseMeta?: object; dynamicMeta?: DynamicMetaFunction; level?: string | DynamicLevelFunction; metaField?: string;