A batteries included template for kick starting a Gleam Cloudflare worker project.
This template uses Wrangler, the CloudFlare Workers CLI. If you are not already familiar with the tool then I recommend that you get familiar with it, and configure it to work with your Cloudflare account. Documentation can be found here.
To generate using Wrangler, run this command:
npx wrangler generate my-gleam-project https://github.com/lpil/gleam-cloudflare-workerThis example uses the OpenWeatherMap API, so create a file at .dev.vars with
an API key, and add it to CloudFlare Secrets if you wish to publish to
CloudFlare.
# Local development secret
echo "OPEN_WEATHER_MAP_API_KEY=your api key goes here" >> .dev.vars
# Cloudflare production secret
npx wrangler secret put OPEN_WEATHER_MAP_API_KEY# Run a local development server
npm run dev
# Deploy to Cloudflare
npm run deploy