-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add loggerMiddleware initial setup
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./configurations"; | ||
export * from "./loggerMiddleware"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
AbsoluteLocation, | ||
FinalizeHandler, | ||
FinalizeHandlerArguments, | ||
FinalizeHandlerOutput, | ||
FinalizeRequestHandlerOptions, | ||
MetadataBearer, | ||
Pluggable, | ||
} from "@aws-sdk/types"; | ||
|
||
import { LoggerResolvedConfig } from "./configurations"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export const loggerMiddleware = (options: LoggerResolvedConfig) => <Output extends MetadataBearer = MetadataBearer>( | ||
next: FinalizeHandler<any, Output> | ||
): FinalizeHandler<any, Output> => async ( | ||
args: FinalizeHandlerArguments<any> | ||
): Promise<FinalizeHandlerOutput<Output>> => { | ||
// TODO: use and call options.logger once it's available in context | ||
return next(args); | ||
}; | ||
|
||
export const loggerMiddlewareOptions: FinalizeRequestHandlerOptions & AbsoluteLocation = { | ||
name: "loggerMiddleware", | ||
tags: ["LOGGER"], | ||
step: "finalizeRequest", | ||
}; | ||
|
||
export const getLoggerPlugin = (options: LoggerResolvedConfig): Pluggable<any, any> => ({ | ||
applyToStack: (clientStack) => { | ||
clientStack.add(loggerMiddleware(options), loggerMiddlewareOptions); | ||
}, | ||
}); |