Skip to content

A starter app for projects on Cloudflare Workers

Notifications You must be signed in to change notification settings

initialcapacity/cloudflare-workers-starter

Repository files navigation

Cloudflare Workers Starter

A starter app that deploys a web application, authentication proxy, and background worker to Cloudflare Workers.

  • Authentication
  • Web app
  • Background worker

Technology stack

This codebase is written Typescript and runs on the Cloudflare Workers runtime, an open source runtime similar to the Web Workers API which differs from what runs on Node or your browser. It uses a lightweight framework called Hono for routing and templating. The codebase is tested with Vitest and builds and deploys with Wrangler. A GitHub action builds a zip artifact and deploys it to Cloudflare Workers. See the starter in action at starterapp.work (login required).

Run tests

  1. Create a .dev.vars file from the example.

    cp .dev.vars.example .dev.vars
  2. Edit the .dev.vars file to match your configuration.

  3. Migrate your local database.

    npm run migrations:apply
  4. Run tests with NPM.

    npm test

Run the apps

  1. Run the scheduled worker.

    npm run worker:start
  2. Trigger the scheduled worker.

    npm run worker:trigger
  3. Run the auth app.

    npm run auth:start
  4. Run the app and visit localhost:8788.

    npm start

Migrations

Create a migration with

npm run migrations:create -- $MIGRATION_NAME