Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Typescript template for cloudflare workers

Notifications You must be signed in to change notification settings

k-yle/cloudflare-workers-ts-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloudflare-workers-ts-template

Build Status Test Coverage Maintainability

⌚ A serverless (FaaS) template utilizing TypeScript on Cloudflare Workers.

Install

npm install --global @cloudflare/wrangler

git clone https://github.com/k-yle/cloudflare-workers-ts-template
cd cloudflare-workers-ts-template

npm install
wrangler config

This will prompt you to login to cloudflare using a "Global API Key". Obtain this from https://dash.cloudflare.com/*/profile/api-tokens

Next up, edit the wrangler.toml file to include your cloudflare account_id and zone_id. Obtain these from https://dash.cloudflare.com

Usage

# start with hot reload (opens browser window)
npm start


# build
npm run build


# run tests
npm test


# deploy to dev
npm run deploy

Deployment

This template uses 3 environments: dev, staging, and production.

Developers can run npm run deploy locally to deploy to a subdomain on *.workers.dev.

You can also run npm run deploy -- --env staging to deploy to the staging domain.

The CI will automatically deploy to production if the tests pass. CF_API_KEY and CF_EMAIL must be set. The token is the "Global API Key" from

This is configured in wrangler.toml

DevOps

GitHub actions runs the CI pipeline. Code Climate is used for coverage & maintainability.

The CI vm must have CF_API_KEY, CF_EMAIL, and CODECLIMATE_REPO_TOKEN set.