breeze
March 5, 2025 ยท View on GitHub
Breeze is a Go-based api/middleware service that provides a secure, authenticated proxy to the OpenWeatherMap API. It serves as the backend for my gust weather tui app, and also serves a silly widget on my personal site http://joeburgess.dev.
If you need a weather API you're probably better off going straight to the source, this is quite a specific solution, but its been a fun project and works well for my use cases!
Features
- GitHub OAuth Authentication: Secure user authentication via GitHub
- API Key Management: Generates and validates API keys for
gust - Weather Data Proxy: Fetches/transforms data from OpenWeatherMap
API Endpoints
Public Endpoints
GET /api/auth/request- initiates GitHub OAuth flowGET /api/auth/callback- OAuth callback handlerPOST /api/auth/exchange- exchange OAuth code for API keyGET /api/cities/search- returns top 5 matches for a city search
Authenticated Endpoints
API key required for these:
GET /api/user- Get current user informationGET /api/weather/{city}- Get weather data for a specific city (can also specifyunits- metric/imperial)
Getting Started
Prerequisites
- Go 1.24 or higher
- GitHub OAuth application credentials
- OpenWeather API key
Environment Variables
Create a .env file with the following variables:
PORT=8080
DB_PATH=./data/gust.db
OPENWEATHER_API_KEY=your_openweather_api_key
// GH variables - requires setting up a Github application on your account - https://github.com/settings/apps
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GITHUB_REDIRECT_URI=http://localhost:8080/api/auth/callback
JWT_SECRET=secret_string_for_jwts
Running Locally
-
Clone the repository:
git clone https://github.com/josephburgess/breeze.git cd breeze -
Install dependencies:
go mod download -
Run the application:
go run cmd/server/main.go
The server will start on port 8080 (or the port specified in your .env file).
You can also use Air for live reloading.
Using with Gust CLI
breeze was designed to serve gust. When running gust for the first time it will:
- Request authentication from Breeze
- Open a browser for GitHub authentication
- Receive and store the API key for future requests
Authentication Flow
- The client requests an auth URL from
/api/auth/request - The server returns a GitHub OAuth URL
- The user authenticates with GitHub
- GitHub redirects to the callback URL with an auth code
- The server exchanges the auth code for a GitHub access token
- The server creates or updates the user record and generates an API key
- The API key is returned to the client for future requests