coldter / kuldeep.tech

https://kuldeep.tech
2 stars 0 forks source link

posts/hono-pages-stack-weatherapp/ #2

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Build Cloudflare Pages Stack Weather App - Kuldeep

https://kuldeep.tech/posts/hono-pages-stack-weatherapp/

coldter commented 1 year ago

Oh, right! hosted at: https://weather.p.kuldeep.tech repo: https://github.com/coldter/hono-cloudflare-pages-stack

coldter commented 1 year ago

@mateusloubach

So for local dev most Cloudflare offering uses Wrangler CLI (installed as dev-deps)

since we're working with Cloudflare pages, we'll utilize wrangler pages dev

for starting our dev environment server, there is a script in package.json called dev::

$( cat secrets.json | jq -r 'keys[] as $k | \"export \\($k)=\\(.[$k])\"') && wrangler pages dev --local --compatibility-date=2023-08-01 --binding OPEN_WEATHER_MAP_API=$OPEN_WEATHER_MAP_API OPEN_WEATHER_MAP_SEARCH_API=$OPEN_WEATHER_MAP_SEARCH_API --kv OpenWeatherMapCache -- pnpm vite:dev

If u ever have worked with Cloudflare workers u might be familiar with wrangler.toml which we use for providing many config and customization option for our local development and deployment. Since wrangler pages doesn't support wrangler.toml, yet we have to provide every option as arguments to wrangler pages dev

to summarized::


So basically u only have to set up settings.json file with your openweathermap's api keys and run pnpm run dev, this will start react dev server with pages function on port 5173.

Make sure u have jq installed on ur system, it should be there if u're using linux, for windows u might have to install it or just hardcode the api keys in the script

for more info, refer https://developers.cloudflare.com/pages/