GithubHelp home page GithubHelp logo

jlengstorf / air-quality-edge-functions Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 64 KB

This is a demo of updating a map to show air quality data for the user’s current location using Next.js Advanced Middleware, powered by Netlify Edge Functions.

Home Page: https://air-quality-edge-functions.netlify.app

TypeScript 24.21% JavaScript 56.12% CSS 19.68%
edge-computing localization netlify-edge-functions nextjs nextjs-middleware personalization

air-quality-edge-functions's Introduction

Show Local Air Quality Based on the User's Location

Use AQI data to show the air quality near the current user. This is built using Next.js Advanced Middleware and powered by Netlify Edge Functions.

See the demo: https://air-quality-edge-functions.netlify.app

Dev Setup

To run this yourself, you need two sets of credentials:

  1. NEXT_PUBLIC_AQICN_API_KEY — this is free and can be requested from the Air Quality Open Data Platform.

    This is used to create a map overlay showing the air quality on a map. (More info in the AQI docs.)

  2. NEXT_PUBLIC_GOOGLE_API_KEY — this has a free tier and is created on the Google Maps Platform credentials page.

    You need to create a project (the credentials page will guide you through this) and enable both the Maps JavaScript API and the Geocoding API.

    Heads up! Make sure to restrict your API key to just the domain you intend to ship it on and to only have access to the APIs you need. Otherwise your key could be misused and you could end up with an unexpected bill!

Create a Netlify site, then add the above credentials as env vars.

Shortcut: Do it all via CLI!

Note: This assumes you have the GitHub CLI installed, which I highly recommend if you work regularly with GitHub.

# fork this repository
gh repo fork jlengstorf/air-quality-edge-functions

# move into the newly forked and cloned repo
cd air-quality-edge-functions/

# install dependencies
npm i

# install the Netlify CLI if you don't already have it
# details: https://docs.netlify.com/cli/get-started/
npm i -g netlify-cli

# create a new Netlify site
ntl init

# add your env vars
ntl env:set NEXT_PUBLIC_AQICN_API_KEY "<your_key_here>"
ntl env:set NEXT_PUBLIC_GOOGLE_API_KEY "<your_key_here>"

# start the dev server
ntl dev

air-quality-edge-functions's People

Contributors

jlengstorf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.