Skip to content

Commit

Permalink
feat: combine serde package (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase Coalwell authored and trivikr committed Jan 3, 2020
1 parent 26068a4 commit 4009549
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 460 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Command } from "@aws-sdk/smithy-client";
import { serializerPlugin } from "@aws-sdk/middleware-serializer";
import { deserializerPlugin } from "@aws-sdk/middleware-deserializer";
import {
deserializerPlugin,
serializerPlugin
} from "@aws-sdk/middleware-serde";
import * as __aws_sdk_types from "@aws-sdk/types";
import { RDSDataResolvedConfiguration } from "../RDSDataConfiguration";
import { HttpRequest } from "@aws-sdk/protocol-http";
Expand Down
4 changes: 0 additions & 4 deletions packages/middleware-deserializer/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/middleware-serde/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# @aws-sdk/@aws-sdk/middleware-serde

[![NPM version](https://img.shields.io/npm/v/@aws-sdk/@aws-sdk/middleware-serde/preview.svg)](https://www.npmjs.com/package/@aws-sdk/@aws-sdk/middleware-serde)
[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/@aws-sdk/middleware-serde.svg)](https://www.npmjs.com/package/@aws-sdk/@aws-sdk/middleware-serde)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@aws-sdk/middleware-deserializer",
"name": "@aws-sdk/middleware-serde",
"version": "0.1.0-preview.1",
"scripts": {
"prepublishOnly": "tsc",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import {
RequestSerializer,
SerializeHandler,
SerializeHandlerArguments,
SerializeMiddleware,
SerializeHandlerOutput,
ResponseDeserializer,
DeserializeHandler,
DeserializeHandlerArguments,
DeserializeMiddleware,
DeserializeHandlerOutput,
Protocol,
SerializerUtils,
DeserializerUtils,
InjectableMiddleware
} from "@aws-sdk/types";
Expand Down Expand Up @@ -48,3 +54,38 @@ export function deserializerPlugin<OutputType>(
tags: { DESERIALIZER: true }
};
}

export function serializerMiddleware<
Input extends object,
Output extends object
>(
options: SerializerMiddlewareConfig,
serializer: RequestSerializer<any>
): SerializeMiddleware<Input, Output> {
return (
next: SerializeHandler<Input, Output>
): SerializeHandler<Input, Output> => async (
args: SerializeHandlerArguments<Input>
): Promise<SerializeHandlerOutput<Output>> => {
const request = options.protocol.serialize(serializer, args.input, options);
return next({
...args,
request
});
};
}

export interface SerializerMiddlewareConfig extends SerializerUtils {
protocol: Protocol<any, any>;
}

export function serializerPlugin(
config: SerializerMiddlewareConfig,
serializer: RequestSerializer<any>
): InjectableMiddleware {
return {
middleware: serializerMiddleware(config, serializer),
step: "serialize",
tags: { SERIALIZER: true }
};
}
File renamed without changes.
8 changes: 0 additions & 8 deletions packages/middleware-serializer/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions packages/middleware-serializer/.npmignore

This file was deleted.

111 changes: 0 additions & 111 deletions packages/middleware-serializer/CHANGELOG.md

This file was deleted.

Loading

0 comments on commit 4009549

Please sign in to comment.