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

@flipdish/cdk-constructs

v0.88.0

Published

CDK Constructs for Flipdish serverless applications

Readme

@flipdish/cdk-constructs

CDK Constructs for Flipdish serverless applications, with a focus on API constructs that provide automatic OpenAPI documentation generation and deployment.

Installation

npm install @flipdish/cdk-constructs

Requirements

  • Zod 4 (^4.0.0). This package uses @asteasolutions/zod-to-openapi 9.x, which supports Zod 4 only.
  • SST v2.

Breaking changes

Zod 4

This release requires Zod 4. Consumers still on Zod 3 must upgrade before adopting it. The Api route schema types and the OpenAPI generator are built against Zod 4; passing Zod 3 schemas can fail stack synthesis or produce an incorrect OpenAPI document.

Overview

This package provides CDK constructs and utilities for building serverless APIs with strong typing and automatic OpenAPI documentation. It is designed to be used with SST and integrates with Zod for schema validation and OpenAPI generation.

Features

  • Api Construct: Drop-in replacement for SST's Api construct, with built-in OpenAPI documentation generation.
  • Automatic OpenAPI Docs: Generates and deploys OpenAPI JSON, YAML, and HTML documentation for your API routes.
  • Schema Integration: Supports Zod-based schema definitions for routes.
  • TypeScript-first: All constructs and utilities are strictly typed.

Usage

Basic Example

import { Api, SchemaFunction } from '@flipdish/cdk-constructs';
import { z } from 'zod';
import { StackContext } from 'sst/constructs';

export function API({ stack }: StackContext) {
  const api = new Api(stack, 'Api', {
    routes: {
      'GET /hello': {
        function: new SchemaFunction(stack, 'HelloHandler', {
          handler: 'src/hello.handler',
          schema: {
            responses: {
              200: z.object({ message: z.string() }),
            },
          },
        }),
      },
    },
  });

  // The following endpoints are automatically added:
  // - /openapi.json
  // - /openapi.yaml
  // - /openapi.html

  return { api };
}

OpenAPI Utilities

You can also use the following utilities for advanced OpenAPI schema generation:

  • buildSchema(registry, serviceName, url): Generates an OpenAPI schema document from a registry.
  • sstRoutesToOpenApiSchema(routes): Converts SST route definitions to OpenAPI route configs.

Types

The package exports several types to help with strong typing and schema integration:

  • Schema
  • SchemaFunction
  • SchemaFunctionProps
  • SchemaRouteProps
  • SchemaApiProps
  • SchemaApiFunctionRouteProps

Idle-limited agent

A keep-alive https.Agent for Lambda clients. It closes a pooled connection idle for over a minute instead of reusing it, so the first request after a long idle gap no longer fails with socket hang up and gets retried. See ADR 66.

Import it from the subpath @flipdish/cdk-constructs/idle-limited-agent. It loads no CDK code, so it is safe in a Lambda bundle. The main entry is not.

How to use it

Add the package to the package that creates the client:

pnpm --filter <package-name> add @flipdish/cdk-constructs

Create each client once, at module scope, and give it the agent.

AWS SDK v3 (v3.521.0 or later; older clients take new NodeHttpHandler({ httpsAgent })):

import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { idleLimitedHttpsAgentForAwsSdk } from '@flipdish/cdk-constructs/idle-limited-agent';

export const dynamo = new DynamoDBClient({ requestHandler: { httpsAgent: idleLimitedHttpsAgentForAwsSdk() } });

Stripe:

import { idleLimitedHttpsAgent } from '@flipdish/cdk-constructs/idle-limited-agent';
import Stripe from 'stripe';

/** One agent for every Stripe client, so they share connections. */
const stripeAgent = idleLimitedHttpsAgent();

const stripe = new Stripe(apiKey, { httpAgent: stripeAgent });

Pass { maxIdleMs: 30_000 } only if a server drops idle connections sooner than a minute.

Reference

| Export | What it is | | ------------------------------------------ | --------------------------------------------------------------------------------------------- | | new IdleLimitedHttpsAgent(options?) | https.Agent subclass. Keep-alive on by default. Reads maxIdleMs; passes the rest to Node. | | idleLimitedHttpsAgent(options?) | Same as new IdleLimitedHttpsAgent(options). For Stripe or any client that takes an agent. | | idleLimitedHttpsAgentForAwsSdk(options?) | Same, with maxSockets: 50 like the agent the AWS SDK makes for itself. | | IdleLimitedHttpsAgentOptions | https.AgentOptions plus maxIdleMs. |

maxIdleMs: how long, in ms, a pooled connection may sit idle before it is closed instead of reused. Default 60000. Readable as agent.maxIdleMs. 0 closes a connection once it has been idle for a millisecond. A negative or non-finite value throws a RangeError. The limit is checked when a request arrives, so it holds across a Lambda freeze.

Development & Testing

This package is maintained in the serverless-app-template repository.

Testing

You can test the constructs by deploying a stack and verifying that the OpenAPI documentation endpoints are available and accurate. For unit testing, use your preferred test runner (e.g., Vitest or Jest) to check that the constructs behave as expected.

Run the unit tests from the repository root. CI runs them before each publish.

pnpm exec vitest run packages/cdk-constructs

License

MIT

Contributing

This package is maintained in the serverless-app-template repository.