This is a service for getting weather data for a specific city and storing the list of cities in a database for reuse. Powered by OpenWeatherMapApi service and PostgreSQL database.
GET /api/city?name=Dnipro,uaExpect result: receive JSON response with cod 200 and info about city by name
GET /api/cityExpect result: info about your added cities
GET /api/userExpect result: info about your added cities
GET /api/usersExpect result: info about all users
GET /Expect result: show "add" city page
GET /city/delete?counrtyName=${counrtyName}Expect result: delete the specified city
GET /userExpect result: receive JSON response with all cities by your ip
POST /?counrtyName=${counrtyName}Expect result: add city in your list
Example application.yaml:
service:
countryName: "Kyiv,ua"
id: Your API key
units: metricExample application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/mydatabase
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=postres
spring.datasource.password=postres
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=updatejava11.0.15maven3.8.4spring-boot2.6.0
Clone repository:
git clone https://github.com/swat121/Weather
cd WeatherBuild project:
mvn clean compile
mvn clean package [or mvn package -DskipTests] Launch jar file:
java -jar weather-0.0.1-SNAPSHOT.jarBrowser check: localhost:8080
Clone image:
docker pull swat121/weather:tagname
Create container, you can use docker-compose or command line for environment variable
command line
docker run -e POSTGRES_DB=mydatabase -e POSTGRES_USER=postres -e POSTGRES_PASSWORD=postgres -d postgres:13.3
docker run -p 8080:8080 -e ID=yourID -e UNITS=yourUnits -e HOST=localhost -e PORT=5432 -e DATABASE=mydatabase -e USER=postres -e PASSWORD=postres -d swat121/weather:tagname
docker-compose
version: "3"
services:
weather:
image: swat121/weather:tagname
container_name: weather-instance
environment:
id: "Your API key"
units: metric
Host: localhost
Port: 5432
Database: mydatabase
User: postres
Password: postres
ports:
- 8080:8080
postres:
image: postgres:13.3
container_name: postgreSQL
environment:
POSTGRES_DB: mydatabase
POSTGRES_USER: postres
POSTGRES_PASSWORD: postres
Browser check: localhost:8080