Skip to content

Commit f877995

Browse files
committed
Revamp README with detailed setup and feature info
Expanded the README to include comprehensive sections on features, tech stack, installation, development, deployment, configuration, project structure, contributing, and acknowledgments. This update provides clearer guidance for new users and contributors, and better documents API requirements and setup steps.
1 parent bcc0031 commit f877995

1 file changed

Lines changed: 147 additions & 15 deletions

File tree

README.md

Lines changed: 147 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,159 @@
22

33
![Deploy status](https://github.com/mdlew/ip/actions/workflows/deploy.yml/badge.svg)
44

5-
IP geolocation, current conditions, forecasts, and browser info using Cloudflare workers, with API calls to publicly available services. [Check it out!](https://ip.matthewlew.info)
5+
A serverless IP geolocation service with real-time weather, air quality, forecasts, and alerts — built on Cloudflare Workers. [**Check it out!**](https://ip.matthewlew.info)
66

7-
## Setup
7+
## Features
88

9-
### APIs
9+
- 🌍 **IP Geolocation** - Automatic location detection using Cloudflare's edge network
10+
- 🌤️ **Weather Data** - Current conditions and forecasts from National Weather Service (NWS)
11+
- 💨 **Air Quality** - Real-time AQI data from World Air Quality Index and AirNow
12+
- 🚨 **Weather Alerts** - Active weather warnings and advisories
13+
- 🗺️ **Interactive Map** - Location visualization with MapLibre GL JS
14+
- 📡 **Radar Images** - Weather radar with WebP optimization
15+
- 🔒 **Security First** - CSP headers, TLS 1.2+, and modern security practices
16+
-**Edge Performance** - Global deployment via Cloudflare Workers
1017

11-
- [World Air Quality Index project](https://aqicn.org/json-api/doc/)
12-
- [Weather.gov](https://www.weather.gov/documentation/services-web-api)
13-
- [Air Now.gov](https://docs.airnowapi.org/webservices)
18+
## Tech Stack
1419

15-
To deploy, set up the following secrets in your repository (Settings → Secrets and variables → Actions)
20+
- **Runtime**: Cloudflare Workers
21+
- **Language**: TypeScript
22+
- **Build**: Wrangler CLI
23+
- **APIs**: National Weather Service, WAQI, AirNow
24+
- **Map**: MapLibre GL JS with Stadia Maps
1625

17-
- `CLOUDFLARE_ACCOUNT_ID`
18-
- `CLOUDFLARE_API_TOKEN`
19-
- `WAQI_TOKEN`: [https://aqicn.org/data-platform/token/](https://aqicn.org/data-platform/token/)
20-
- `NWS_AGENT`: [Your app's user agent](https://www.weather.gov/documentation/services-web-api)
21-
- `AIRNOW_KEY`: [https://docs.airnowapi.org/faq](https://docs.airnowapi.org/faq)
26+
## Getting Started
27+
28+
### Prerequisites
29+
30+
- [Node.js](https://nodejs.org/) (v18 or later)
31+
- [pnpm](https://pnpm.io/) package manager
32+
- [Cloudflare account](https://dash.cloudflare.com/sign-up)
33+
- [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/)
34+
35+
### Installation
36+
37+
1. Clone the repository:
38+
```bash
39+
git clone https://github.com/mdlew/ip.git
40+
cd ip
41+
```
42+
43+
2. Install dependencies:
44+
```bash
45+
pnpm install
46+
```
47+
48+
3. Configure API tokens (see [API Setup](#api-setup) below)
49+
50+
### Development
51+
52+
Run the development server locally:
53+
54+
```bash
55+
pnpm dev
56+
```
57+
58+
The worker will be available at `http://localhost:8787`
59+
60+
### Build
61+
62+
Compile TypeScript to JavaScript:
63+
64+
```bash
65+
pnpm build
66+
```
67+
68+
### Deployment
69+
70+
Deploy to Cloudflare Workers:
71+
72+
```bash
73+
pnpm deploy
74+
```
75+
76+
For automated deployment via GitHub Actions, see [CI/CD Setup](#cicd-setup).
77+
78+
## Configuration
79+
80+
### API Setup
81+
82+
This project requires API keys from the following services:
83+
84+
1. **WAQI Token** (Air Quality)
85+
- Get your token: [https://aqicn.org/data-platform/token/](https://aqicn.org/data-platform/token/)
86+
- [API Documentation](https://aqicn.org/json-api/doc/)
87+
88+
2. **NWS User Agent** (Weather)
89+
- Format: `(YourAppName, your@email.com)`
90+
- [API Documentation](https://www.weather.gov/documentation/services-web-api)
91+
92+
3. **AirNow API Key** (Air Quality)
93+
- Request access: [https://docs.airnowapi.org/faq](https://docs.airnowapi.org/faq)
94+
- [API Documentation](https://docs.airnowapi.org/webservices)
95+
96+
### Local Development Setup
97+
98+
Create a `.dev.vars` file in the project root:
99+
100+
```ini
101+
WAQI_TOKEN=your_waqi_token_here
102+
NWS_AGENT=(YourApp, your@email.com)
103+
AIRNOW_KEY=your_airnow_key_here
104+
```
105+
106+
### Production Setup (Cloudflare)
107+
108+
Set secrets using Wrangler:
109+
110+
```bash
111+
wrangler secret put WAQI_TOKEN
112+
wrangler secret put NWS_AGENT
113+
wrangler secret put AIRNOW_KEY
114+
```
115+
116+
### CI/CD Setup
117+
118+
For automated deployment via GitHub Actions, add these secrets to your repository (Settings → Secrets and variables → Actions):
119+
120+
- `CLOUDFLARE_ACCOUNT_ID` - Your Cloudflare account ID
121+
- `CLOUDFLARE_API_TOKEN` - API token with Workers edit permissions
122+
- `WAQI_TOKEN` - Air quality API token
123+
- `NWS_AGENT` - Weather.gov user agent string
124+
- `AIRNOW_KEY` - AirNow API key
125+
126+
## Project Structure
127+
128+
```
129+
ip/
130+
├── src/
131+
│ ├── index.ts # Main entry point and request router
132+
│ ├── ssr.ts # Server-side rendering logic
133+
│ └── utils.ts # Utility functions and helpers
134+
├── public/ # Static assets (fonts, robots.txt)
135+
├── wrangler.toml # Cloudflare Workers configuration
136+
├── package.json # Dependencies and scripts
137+
└── tsconfig.json # TypeScript configuration
138+
```
139+
140+
## Contributing
141+
142+
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.
143+
144+
## License
145+
146+
This project is open source and available under the [MIT License](LICENSE).
22147

23148
## Credits
24149

25-
Script adapted from:
150+
Built by [Matthew Lew](https://github.com/mdlew)
151+
152+
Adapted from:
153+
- [Cloudflare Workers Examples](https://developers.cloudflare.com/workers/examples/)
154+
- [NikSec IP Check Tool](https://niksec.com/creating-a-simple-ip-check-tool-with-cloudflare-workers/)
155+
156+
## Acknowledgments
26157

27-
- [Cloudflare examples](https://developers.cloudflare.com/workers/examples/)
28-
- [NikSec ip check tool](https://niksec.com/creating-a-simple-ip-check-tool-with-cloudflare-workers/)
158+
- Weather data provided by [National Weather Service](https://www.weather.gov/)
159+
- Air quality data from [WAQI](https://aqicn.org/) and [AirNow](https://www.airnow.gov/)
160+
- Maps powered by [MapLibre GL JS](https://maplibre.org/) and [Stadia Maps](https://stadiamaps.com/)

0 commit comments

Comments
 (0)