@flipdish/cdk-constructs

中文文档
0.82.0发布于 2026/11/03MITTypeScriptES Module近 30 天下载 2662

CDK Constructs for Flipdish serverless applications

原始使用文档
文档目录11 节
  1. Installation
  2. Overview
  3. Features
  4. Usage
  5. Basic Example
  6. OpenAPI Utilities
  7. Types
  8. Development & Testing
  9. Testing
  10. License
  11. Contributing

@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

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

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.

License

MIT

Contributing

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

版本与发布记录

@flipdish/cdk-constructs 共发布 90 个版本,首次发布于 2025/06/05;过去 12 个月发布了 16 个版本。

版本发布日期距今
0.82.0latest2026/11/0313 天前
0.81.02026/10/071 个月前
0.80.02026/08/272 个月前
0.79.02026/08/113 个月前
0.78.02026/08/063 个月前
0.77.02026/07/213 个月前

关于 @flipdish/cdk-constructs 的常见问题

@flipdish/cdk-constructs 是什么?

CDK Constructs for Flipdish serverless applications

如何安装 @flipdish/cdk-constructs?

在项目目录运行 npm install @flipdish/cdk-constructs,或使用 pnpm add / yarn add / bun add。

@flipdish/cdk-constructs 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@flipdish/cdk-constructs 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@flipdish/cdk-constructs 可以商用吗?

@flipdish/cdk-constructs 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@flipdish/cdk-constructs 的下载量有多少?

根据 npm 官方下载统计,@flipdish/cdk-constructs 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,662 次,日均约 89 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@flipdish/cdk-constructs 还在维护吗?

最新版本 0.82.0 发布于 2026/11/03(13 天前);至今共发布 90 个版本,其中过去 12 个月发布了 16 个;首次发布于 2025/06/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。