English / 日本語
Provides utilities to configure CORS for Amazon API Gateway (API Gateway) with AWS Cloud Development Kit (CDK).
This library would help you if you feel tiresome of repeating CORS settings for API Gateway with CDK.
When I describe a REST API with API Gateway, I often write a couple of utility functions to deal with CORS. These functions are quite simple though, I no longer want to prepare them everytime I start a new project.
Please add this repository to your Node dependencies.
npm install https://github.com/codemonger-io/cdk-cors-utils.git#v0.4.0
The installed module will be available as @codemonger-io/cdk-cors-utils
like the following,
import { makeIntegrationResponsesAllowCors } from '@codemonger-io/cdk-cors-utils';
This library is designed for CDK v2.x, and does not work with CDK v1.x.
Every time commits are pushed to the main
branch, a developer package is published to the npm registry managed by GitHub Packages.
A developer package bears the next release number but followed by a dash (-
) plus the short commit hash; e.g., 0.4.0-abc1234
where abc1234
is the short commit hash of the commit used to build the package (snapshot).
You can find developer packages here.
To install a developer package, you need to configure a classic GitHub personal access token (PAT) with at least the read:packages
scope.
Below briefly explains how to configure a PAT.
Please refer to the GitHub documentation for more details.
Once you have a PAT, please create a .npmrc
file in your home directory with the following content:
//npm.pkg.github.com/:_authToken=$YOUR_GITHUB_PAT
Please replace $YOUR_GITHUB_PAT
with your PAT.
In the root directory of your project, please create a .npmrc
file with the following content:
@codemonger-io:registry=https://npm.pkg.github.com
Then you can install a developer package with the following command:
npm install @codemonger-io/cdk-cors-utils@0.4.0-abc1234
Please replace abc1234
with the short commit hash of the snapshot you want to install.
Please refer to api-docs/markdown/index.md
.
TBD
build
script transpiles TypeScript files in the src
folder.
pnpm build
You will find transpiled JavaScript (*.js
) and type declaration (*.d.ts
) files created in a folder dist
.
doc
script generates the API documentation.
pnpm doc
You will find markdown files updated in the folder api-docs/markdown
.
Documentation is generated by API Extractor and API Documenter.