@lambda-middleware/json-serializer
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.1 • Public • Published

    @lambda-middleware/json-serializer

    npm version downloads open issues debug build status codecov dependency status devDependency status

    A middleware for AWS http lambda functions to serialize JSON responses, including correct status codes and content-header.

    Please note that this middleware just uses JSON.stringify for serialization and therefore does not strip any serializable content. Please act as if any data your handler returns could end up on the client side and take care of appropriate whitelisting in the handler or a different middleware!

    Lambda middleware

    This middleware is part of the lambda middleware series. It can be used independently.

    Usage

    import { jsonSerializer } from "@lambda-middleware/json-serializer";
    
    interface Response {
      // Undefined values will be stripped out
      name?: string;
    }
    
    // This is your AWS handler
    async function helloWorld(): Promise<Response> {
      return {};
    }
    
    // Wrap the handler with the middleware
    export const handler = jsonSerializer()(helloWorld);

    Install

    npm i @lambda-middleware/json-serializer

    DownloadsWeekly Downloads

    37

    Version

    2.1.1

    License

    MIT

    Unpacked Size

    12 kB

    Total Files

    14

    Last publish

    Collaborators

    • dbartholomae