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

@pattform/api-kit

v2.2.1

Published

Pulumi infra library for building and deploying an API

Readme

pattform-api-kit

This is a Pulumi Component Library built to allow for extremely quick API creation. In particular, this library is designed to provide a fast and simple way to deploy a containerised API to Google Cloud Run, and then expose it to the internet via AWS Api Gateway.

Requirements

Installation

npm install @pattform/infra-api-library

Usage

App Component

Pulumi Config Requirements

  • aws:region - AWS Region
  • cloudflare:apiToken - Cloudflare API Token (not needed when manageDns: false)
  • github:apiToken - GitHub API Token (Must have repo scope)

DNS

By default the component creates the certificate-validation and subdomain CNAMEs in Cloudflare. When the client owns their domain elsewhere (GoDaddy, Squarespace, their IT provider, ...), set manageDns: false: no Cloudflare config is needed, and the records the client must create are exposed on the requiredDnsRecords output ({ name, type, value, purpose }[] - the ACM validation CNAME plus one CNAME per subdomain). Export it from the stack and send it to the client:

export const dnsRecordsForClient = app.requiredDnsRecords;

The Amplify domain association is created with waitForVerification: false, so pulumi up completes before the client adds their records; the domain goes live once the records exist and the certificate validates.

AWS credentials

The component picks AWS credentials in this order:

  1. roleArn arg (or aws:roleArn config) - assume-role into the client account, e.g. the deployRoleArn output of a ClientAccountComponent. Preferred.
  2. aws:accessKey + aws:secretKey config - legacy static keys for shared-account stacks.
  3. Ambient credentials - e.g. a Pulumi ESC environment with aws-login (OIDC).
import { AppComponent } from '@pattform/api-kit';

const app = new AppComponent("app", {
    domain: domain, // domain of the app
    repoUrl: repoUrl, // url of the repo
    subDomains: ["www", ""], // subdomains to create. If not provided, defaults to ["www", ""]
    roleArn: roleArn, // optional: role to assume in the client account
    manageDns: true, // optional: set false when the domain is not in Cloudflare (see DNS section)
    buildSpec: // If not provided, defaults to running `npm run build` and expects an outputed `dist` directory
    `
        version: 0.2
        phases:
            pre_build:
                commands:
                    - npm install
            build:
                commands:
                    - npm run build
        artifacts:
            files:
                - '**/*'
        cache:
            paths:
                - node_modules/**/*
    ` 
})

Client Account Component

Creates an AWS member account for a client under the Pattform organization's Clients OU, plus a monthly cost budget with email alerts inside that account. Run with management-account credentials (e.g. the Pattform/Prod ESC environment).

Pulumi Config Requirements

  • aws:region - AWS Region (unless region arg is given)
import { ClientAccountComponent, AppComponent } from '@pattform/api-kit';

const org = new pulumi.StackReference("Pattform/pattform-infrastructure/prod");

const clientAccount = new ClientAccountComponent("kaloblock", {
    email: "[email protected]", // root email for the new account
    parentId: org.getOutput("clientsOuId"), // Clients OU
    budgetLimitUsd: 10, // optional, defaults to 10
    budgetAlertEmails: ["[email protected]"], // optional
});

// Deploy the client's app into their account:
const app = new AppComponent("app", {
    domain: domain,
    repoUrl: repoUrl,
    roleArn: clientAccount.deployRoleArn,
});

getClientRoleArn

Client website stacks (in separate repos) look up their deploy role by client name instead of referencing the account component directly:

import { AppComponent, getClientRoleArn } from '@pattform/api-kit';

const app = new AppComponent("app", {
    domain: domain,
    repoUrl: repoUrl,
    roleArn: getClientRoleArn("kaloblock"), // name from the pattform-infrastructure clients registry
});

Fails with the list of known clients if the name isn't in the registry. An optional second argument overrides the infrastructure stack (defaults to Pattform/pattform-infrastructure/prod).

Notes:

  • The account resource is protect: true and closeOnDeletion: false - a pulumi destroy will not close a client's AWS account.
  • AWS limits account closures to 10% of the org per 30 days; closed accounts stay suspended for 90 days.
  • deployRoleArn is the account's OrganizationAccountAccessRole, assumable from the management account.

Container Component

Pulumi Config Requirements

  • gcp:project - Google Cloud Project ID
  • gcp:region - Google Cloud Region
  • gcp:credentials - Google Cloud Service Account Credentials (or ambient credentials)
  • imageRef - Image digest (sha256:...) set by CI; defaults to latest tag when not set
import { ContainerComponent } from '@pattform/api-kit';

const container = new ContainerComponent("container", {
    environment: environment, // dev, staging, prod
    imageName: imageName, // name of the image to use
    memory: memory, // memory to allocate
    cpu: cpu, // cpu to allocate
    containerPort: containerPort, // port to expose
    envVars: {
        NODE_ENV: environment, // environment variable to set
        API_URL: apiUrl, // url of the api
    }
});

Cloud Run is configured with one concurrent request per instance and a maximum of two instances.

CI build and Pulumi config

The image must be built and pushed before pulumi up. CI should set imageRef (the digest) into the stack config.

- name: Set image digest for Pulumi
  run: |
    pulumi config set imageRef "${IMAGE_DIGEST}" --stack "${PULUMI_STACK}"

Api Component

Pulumi Config Requirements

  • aws:region - AWS Region
  • aws:accessKey - AWS Access Key
  • aws:secretKey - AWS Secret Key
import { ApiComponent } from '@pattform/api-kit';

const api = new ApiComponent("api", {
    environment: environment, // dev, staging, prod
    imageName: imageName, // name of the image to use
    containerUrl: containerComponent.serviceUrl, // url of the container
    appDomain: appUrl, // domain of the app
    apiDomain: apiDomain, // domain of the api
});

License

See the LICENSE file.

Reference