npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openapi-typescript-aws-handler

v1.0.8

Published

Typescript types for an OpenAPI AWS lambda handler to process requests, using the definitions generated by openapi-typescript

Readme

This library extends upon the awesome openapi-typescript library to create AWS lambda bindings for handling requests that are made to an OpenAPI API. The intention is to make it as easy as possible to create a typescript handler that will accept requests from somewhere else (presumably an (API gateway)) and will execute some type safe(ish) code to process that request. It assumes that all validation has already been performed by an upstream

This library does no code-generation of its own. It depends on openapi-typescript for that. Instead, it just provides some typescript type magic to provide a type-safe way of defining your handlers, and a simple wrapper that will take input and call your function.

🚧 NOTE

This library does not currently vend or return AWS API Gateway proxy objects (as served by API Gateway) - This is because I have another wrapper around these objects, but I will add in another version of the wrapper that does work directly with Proxy request. You could write a trivial wrapper around this to do it yourself in the mean time.

This library also assumes that you are transmitting and receiving JSON only. Some APIs may use different content types. Its unclear to me whether my API adapter should auto-transform, or whether the API desginer should be given control - probably a mixture of both. Transforming between YAML and JSON is trivial, and could easily be handled by the wrapper.

Usage

To use this library there are a couple of steps

  1. Generate bindings for your application using openapi-typescript

  2. Create a lambda handler using the makeOpenApiLambdaHandler call from this package. For example

    import { OperationHandler, makeOpenApiLambdaHandler, Non2xxResult } from "openapi-typescript-aws-handler"
    import { operations, components,  } from "./api"  // This is the file you generated using openapi-typescript
    
    /**
    * Makes it easier to throw the API specific ApiError.
    */
    class ApiError extends Non2xxResult<components['schemas']['ApiError']> {
        constructor(message: string, code: number = 500) {
            super({ message }, code)
        }
    }
    
    /**
    *  Handler for the *echoInput* operation
    */
    const echoInput: OperationHandler<operations["echoInput"]> = async ({ body, params }) => {
    
        // For demo purposes, we execute differently based upon a mock query parameter passed in
        const mockParam = params?.query?.mock;
        if (mockParam) {
            switch (mockParam) {
                case 'fail':
                    throw new ApiError("you told me to fail", 500);
                case 'not_found':
                    throw new ApiError("Not Found", 404);
            }
        }
    
        if (!body) {
            throw new ApiError("No body supplied");
        }
    
        return {
            status: 200,
            content: {
                response: body.input
            }
        };
    }
    
    export const handler = makeOpenApiLambdaHandler<operations>({
        echoInput,
    });
  3. Set up your API gateway to use this lambda to handle requests.

See the example directory for some simple examples