Skip to content

fionatagious/aqi-viewer

Repository files navigation

Air Quality Index (AQI) Viewer

This repository is the codebase for an Air Quality Index (AQI) Viewer, which displays air quality data, collected and measured at monitoring stations around the world. To build the viewer, I used a free and publicly accessible Real-time Air Quality Data Feed, a JSON API provided by the World Air Quality Index project.

Environment Setup

Environment Variables

  1. If you do not already have a private API key, request one here.
  2. Create a .env and pass the token as a string to AQICN_TOKEN.
API_HOST="https://api.waqi.info/feed/"
AQICN_TOKEN="example API key"

Install needed packages and dependencies

  1. If you already have Node installed, check the installed version by running node -v and seeing that it returns v18.18.0. If you need to install it, and if you are using nvm, run:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

    ...or if you are using asdf, run:

    asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
    asdf install nodejs 14.17.6
  2. Install package.json dependencies into the node_modules/ directory

    npm install

Running the application

Run development server:

npm run dev

or

next dev

Running tests with Cypress

Tests are located in a single file: cypress/e2e/app.cy.js

To run tests, run:

npx cypress run --spec cypress/e2e/app.cy.js

Note: Cypress waits until the dev server is accessible before running tests, so be sure to start the dev server with npm run dev before running tests.

Alternatively, you can run tests in Cypress desktop app:

npx cypress open

Click on E2E testing, choose your preferred browser, and click "Start E2E Testing."

About

Air Quality Index (AQI) viewer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published