Skip to content

A NestJS application that allows users to subscribe to weather updates for the chosen city. The application integrates with WeatherAPI.com to fetch real-time weather data and sends regular updates to users via email.

Notifications You must be signed in to change notification settings

ksalpern/weather-subscription-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Weather subscription API

demo

Click here to see live demo, or here to see how the whole flow looks on my end 🌦️

📋 Overview

A NestJS application that allows users to subscribe to regular weather updates for their chosen cities. Users can select daily or hourly updates and receive emails with current temperature, humidity, and weather descriptions.

🛠️ Technologies

  • Framework: NestJS, TypeScript

  • Database: PostgreSQL, TypeORM

  • Email: Nodemailer, mailtrap

  • Scheduling: @nestjs/schedule

  • Container: Docker, Docker Compose

  • Weather Data: WeatherAPI

  • Frontend: HTML, CSS, JavaScript

  • Deployment Render

🔍 API Endpoints

Endpoint Method Description Errors
/api/weather?city={city} GET Get current weather for a city 400 - Missing city parameter
404 - City not found
500 - API error
/api/subscribe POST Subscribe to weather updates 400 - Invalid input
409 - Already subscribed
500 - Server error
/api/confirm/{token} GET Confirm subscription 404 - Invalid/expired token
500 - Server error
/api/unsubscribe/{token} GET Unsubscribe from updates 404 - Invalid token
500 - Server error

🚀 Running Locally

  1. Clone the repository
git clone https://github.com/ksalpern/weather-subscription-api.git
cd weather-subscription-api/weather-api
  1. Create .env file and edit it with your values
cp .env.example .env
  1. Start the app using Docker (recommended)
docker compose -f docker-compose.yml up
  1. Start the app without Docker
# Install dependencies first
pnpm install

# Run database migrations
pnpm run migration:run

# Start in development mode
pnpm run start:dev

💡 Ideas for improvement

  • 3D weather visualization: Implement Three.js for interactive 3D weather elements

  • Beautiful email templates: as now emails are quite ugly 😁

  • Custom confirmation pages: Styled confirmation and unsubscribe success pages

  • Weather alerts: Special notifications for extreme weather conditions

  • Real-time updates: WebSocket support for live weather changes

  • Multiple weather providers: Fallback options if primary API fails

  • Analytics: Track subscription patterns and popular cities

About

A NestJS application that allows users to subscribe to weather updates for the chosen city. The application integrates with WeatherAPI.com to fetch real-time weather data and sends regular updates to users via email.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published