A serverless IP geolocation service with real-time weather, air quality, forecasts, and alerts — built on Cloudflare Workers. Check it out!
- 🌍 IP Geolocation - Automatic location detection using Cloudflare's edge network
- 🌤️ Weather Data - Current conditions and forecasts from National Weather Service (NWS)
- 💨 Air Quality - Real-time AQI data from World Air Quality Index and AirNow
- 🚨 Weather Alerts - Active weather warnings and advisories
- 🗺️ Interactive Map - Location visualization with MapLibre GL JS
- 📡 Radar Images - Weather radar with WebP optimization
- 🔒 Security First - CSP headers, TLS 1.2+, and modern security practices
- ⚡ Edge Performance - Global deployment via Cloudflare Workers
- Runtime: Cloudflare Workers
- Language: TypeScript
- Build: Wrangler CLI
- APIs: National Weather Service, WAQI, AirNow
- Map: MapLibre GL JS with Stadia Maps
- Node.js (v18 or later)
- pnpm package manager
- Cloudflare account
- Wrangler CLI
-
Clone the repository:
git clone https://github.com/mdlew/ip.git cd ip -
Install dependencies:
pnpm install
-
Configure API tokens (see API Setup below)
Run the development server locally:
pnpm devThe worker will be available at http://localhost:8787
Compile TypeScript to JavaScript:
pnpm buildDeploy to Cloudflare Workers:
pnpm deployFor automated deployment via GitHub Actions, see CI/CD Setup.
This project requires API keys from the following services:
-
WAQI Token (Air Quality)
- Get your token: https://aqicn.org/data-platform/token/
- API Documentation
-
NWS User Agent (Weather)
- Format:
(YourAppName, your@email.com) - API Documentation
- Format:
-
AirNow API Key (Air Quality)
- Request access: https://docs.airnowapi.org/faq
- API Documentation
Create a .dev.vars file in the project root:
WAQI_TOKEN=your_waqi_token_here
NWS_AGENT=(YourApp, your@email.com)
AIRNOW_KEY=your_airnow_key_hereSet secrets using Wrangler:
wrangler secret put WAQI_TOKEN
wrangler secret put NWS_AGENT
wrangler secret put AIRNOW_KEYFor automated deployment via GitHub Actions, add these secrets to your repository (Settings → Secrets and variables → Actions):
CLOUDFLARE_ACCOUNT_ID- Your Cloudflare account IDCLOUDFLARE_API_TOKEN- API token with Workers edit permissionsWAQI_TOKEN- Air quality API tokenNWS_AGENT- Weather.gov user agent stringAIRNOW_KEY- AirNow API key
ip/
├── src/
│ ├── index.ts # Main entry point and request router
│ ├── ssr.ts # Server-side rendering logic
│ └── utils.ts # Utility functions and helpers
├── public/ # Static assets (fonts, robots.txt)
├── wrangler.toml # Cloudflare Workers configuration
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is open source and available under the MIT License.
Built by Matthew Lew
Adapted from:
- Weather data provided by National Weather Service
- Air quality data from WAQI and AirNow
- Maps powered by MapLibre GL JS and Stadia Maps