A web application that calculates and displays moon rise and set times for any location on Earth using Google Maps integration.
- Interactive Google Maps interface for location selection
- Automatic geolocation detection
- Smart timezone selector with auto-detection and 50+ timezones
- Real-time moon rise and set calculations
- Full month calendar view with sun and moon times
- Backend: Go 1.21+
- Frontend: Vanilla JavaScript, jQuery 3.7.1
- Maps: Google Maps JavaScript API with AdvancedMarkerElement
- Calculations: riseset library
-
Clone the repository
git clone https://github.com/exploded/moon.git cd moon -
Install dependencies
go mod download
-
Set up environment variables Use .env.example to create your own .env file
GOOGLE_MAPS_API_KEY=your_actual_api_key_here PROD=False PORT=8484
-
Get a Google Maps API Key
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable "Maps JavaScript API"
- Create credentials (API Key)
- IMPORTANT: Restrict the API key (recommended for production):
- Application restrictions: Set HTTP referrers
- Add your domain:
https://yourdomain.com/* - For local development:
http://localhost:8484/*
- Add your domain:
- API restrictions: Restrict key to "Maps JavaScript API" only
- Set usage quotas to prevent abuse
- Application restrictions: Set HTTP referrers
Security Note: Google Maps JavaScript API keys are client-side visible by design. The security comes from properly configuring API key restrictions in Google Cloud Console, not from hiding the key.
build.batOr for quick restart (when already built):
run.batBuild for Debian/Ubuntu (amd64):
set GOOS=linux
set GOARCH=amd64
go build -o moonBuild for Windows (local):
set GOOS=windows
set GOARCH=amd64
go build -o moon.exego test -v
go test -coverSettings → Secrets and variables → Actions → New repository secret
| Secret name | Value |
|---|---|
DEPLOY_HOST |
Your Linode public IP or hostname |
DEPLOY_USER |
deploy |
DEPLOY_SSH_KEY |
The private key printed by the setup script |
DEPLOY_PORT |
Your SSH port (only if not port 22) |
git push origin masterView deployment logs at https://github.com/exploded/moon/actions
| Variable | Required | Default | Description |
|---|---|---|---|
GOOGLE_MAPS_API_KEY |
Yes | — | Your Google Maps API key |
PROD |
No | False |
Set to True for production mode |
PORT |
No | 8484 |
Port the server listens on |
- Port: 8484 (default)
- Read Timeout: 5 seconds
- Write Timeout: 5 seconds
- Idle Timeout: 120 seconds
- Shutdown Grace Period: 5 seconds
- X-Content-Type-Options, X-Frame-Options, X-XSS-Protection headers
- Referrer-Policy: strict-origin-when-cross-origin
- Content-Security-Policy with strict resource restrictions
- Input validation for latitude, longitude, and timezone
- Graceful shutdown on SIGTERM/SIGINT
- API key injected via server-side template rendering (not exposed via endpoint)
Copyright 2020–2026 James McHugh
Licensed under the Apache License, Version 2.0. See LICENSE.
- Moon rise/set algorithm by Keith Burnett
- Background image: NASA/Goddard Space Flight Center Scientific Visualization
- Map integration: Google Maps JavaScript API