Skip to content

Latest commit

Β 

History

History
230 lines (181 loc) Β· 15.8 KB

README.md

File metadata and controls

230 lines (181 loc) Β· 15.8 KB
layout title permalink
page
archipelago 🐚 🌊 🐬 πŸ„ 🌴 πŸ₯₯ 🩴 πŸ–οΈ πŸ‘™
/

English Arabic Spanish Turkish

Los Roques archipelago John at Roques Beach Images at Roques Beach Random at Roques Beach

Cloudflare Workers provides a serverless execution environment that allows you to create entirely new applications or augment existing ones without configuring or maintaining infrastructure.

Requirements

verify installation: node -v

verify installation: git --version

  • Lerna -> npm install -g lerna

verify installation: lerna -v

First Steps

You can sign up at Cloudflare Workers with your own account for free and experiment with the sample code in the Playground. Using the admin side of your Cloudflare Workers account will be the easiest way to deploy Workers without using the Wrangler CLI.

Getting started

  • npm install -g wrangler

  • wrangler --version

Creating a new worker

cd packages
wrangler generate my-worker
cd my-worker

We are building all the Workers under one account and subdomain roquesbeach.workers.dev.

Then to test the Worker locally run

wrangler dev --local

Output

Debugger attached.
Worker reloaded! (454.77KiB)
Listening on ...
... http://127.0.0.1:8787

Coding

Examples

Tutorials

The starter point of the Worker is index.js but Cloudflare Workers also supports other languages.

For this project we are using JavaScript only since we are managing the project with Lerna.

Deployment

We use Lerna locally to publish all the Workers at once, so you need to update your package.json with entries for build and publish, but these entries are not needed for publishing a single worker.

From the repository root the administrators can run

lerna run publish

Output

√ Images:publish (20s)
√ Random:publish (20s)
√ John:publish (22s)

Administrators can also deploy a single Worker. cd to its directory and run

wrangler publish

We use a GitHub Action to deploy on merge to main branch but each Worker deployment is separate.

So you will also need to update the workflow wrangler.yml and add another entry for your Worker, take the example of packages/john/package.json.

Example .github/workflows/wrangler.yml

my-worker:
  runs-on: ubuntu-latest
  name: 🧘 my-worker
  steps:
    - uses: actions/checkout@v3
    - name: πŸš€ Publish
      uses: cloudflare/[email protected]
      with:
        apiToken: ${{ secrets.CF_API_TOKEN }}
        accountId: ${{ secrets.CF_ACCOUNT_ID }}
        workingDirectory: "packages/my-worker"

Using this example you can change all strings my-worker for your Worker name (you need to add it at jobs: scope).

Workers Platform

Cloudflare Worker Limits

Pseudo Websites with Workers Free 🍬 πŸ’ƒ πŸ•Ί 😎

Running Workers in Lynx Browser

Caribbean Sea 🦭 πŸ¦‘ 🦈 πŸ™

Islands 🐑 🐠 🐟 β™“ β›΅ 🏊 πŸ–οΈ