From fece4175a38eade70ae7192f1f1a9d17243b9855 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Mon, 14 Sep 2020 11:01:38 -0700 Subject: [PATCH] fix: add loggerMiddleware in build step (#1520) --- .../src/loggerMiddleware.spec.ts | 10 +++++----- .../middleware-logger/src/loggerMiddleware.ts | 18 ++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/middleware-logger/src/loggerMiddleware.spec.ts b/packages/middleware-logger/src/loggerMiddleware.spec.ts index 30a419a0567f..3e9cfbbefeb6 100644 --- a/packages/middleware-logger/src/loggerMiddleware.spec.ts +++ b/packages/middleware-logger/src/loggerMiddleware.spec.ts @@ -1,4 +1,4 @@ -import { FinalizeHandlerArguments, Logger, MiddlewareStack } from "@aws-sdk/types"; +import { BuildHandlerArguments, Logger, MiddlewareStack } from "@aws-sdk/types"; import { getLoggerPlugin, loggerMiddleware, loggerMiddlewareOptions } from "./loggerMiddleware"; @@ -54,14 +54,14 @@ describe("loggerMiddleware", () => { }); it("returns without logging if context.logger is not defined", async () => { - const response = await loggerMiddleware()(next, {})(args as FinalizeHandlerArguments); + const response = await loggerMiddleware()(next, {})(args as BuildHandlerArguments); expect(next).toHaveBeenCalledTimes(1); expect(response).toStrictEqual(mockResponse); }); it("returns without logging if context.logger doesn't have debug/info functions", async () => { const logger = {} as Logger; - const response = await loggerMiddleware()(next, { logger })(args as FinalizeHandlerArguments); + const response = await loggerMiddleware()(next, { logger })(args as BuildHandlerArguments); expect(next).toHaveBeenCalledTimes(1); expect(response).toStrictEqual(mockResponse); }); @@ -77,7 +77,7 @@ describe("loggerMiddleware", () => { outputFilterSensitiveLog, }; - const response = await loggerMiddleware()(next, context)(args as FinalizeHandlerArguments); + const response = await loggerMiddleware()(next, context)(args as BuildHandlerArguments); expect(next).toHaveBeenCalledTimes(1); expect(response).toStrictEqual(mockResponse); @@ -97,7 +97,7 @@ describe("loggerMiddleware", () => { it("logs httpRequest, httpResponse if context.logger has debug function", async () => { const logger = ({ debug: jest.fn() } as unknown) as Logger; - const response = await loggerMiddleware()(next, { logger })(args as FinalizeHandlerArguments); + const response = await loggerMiddleware()(next, { logger })(args as BuildHandlerArguments); expect(next).toHaveBeenCalledTimes(1); expect(response).toStrictEqual(mockResponse); diff --git a/packages/middleware-logger/src/loggerMiddleware.ts b/packages/middleware-logger/src/loggerMiddleware.ts index d108dac0f6e4..d349e0862961 100644 --- a/packages/middleware-logger/src/loggerMiddleware.ts +++ b/packages/middleware-logger/src/loggerMiddleware.ts @@ -1,20 +1,18 @@ import { AbsoluteLocation, - FinalizeHandler, - FinalizeHandlerArguments, - FinalizeHandlerOutput, - FinalizeRequestHandlerOptions, + BuildHandler, + BuildHandlerArguments, + BuildHandlerOptions, + BuildHandlerOutput, HandlerExecutionContext, MetadataBearer, Pluggable, } from "@aws-sdk/types"; export const loggerMiddleware = () => ( - next: FinalizeHandler, + next: BuildHandler, context: HandlerExecutionContext -): FinalizeHandler => async ( - args: FinalizeHandlerArguments -): Promise> => { +): BuildHandler => async (args: BuildHandlerArguments): Promise> => { const { logger, inputFilterSensitiveLog, outputFilterSensitiveLog } = context; const response = await next(args); @@ -47,10 +45,10 @@ export const loggerMiddleware = () =>