Skip to content

swat121/Weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Desciption


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.

EndPoints:


GET     /api/city?name=Dnipro,ua

Expect result: receive JSON response with cod 200 and info about city by name

GET    /api/city

Expect result: info about your added cities

GET    /api/user

Expect result: info about your added cities

GET    /api/users

Expect result: info about all users

GET    /

Expect result: show "add" city page

GET    /city/delete?counrtyName=${counrtyName}

Expect result: delete the specified city

GET    /user

Expect result: receive JSON response with all cities by your ip

POST   /?counrtyName=${counrtyName}

Expect result: add city in your list

Properties:


Example application.yaml:

service:
  countryName: "Kyiv,ua"
  id: Your API key
  units: metric

Example 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=update

Requirements


  • java 11.0.15
  • maven 3.8.4
  • spring-boot 2.6.0

Installation and running (git)


Clone repository:

git clone https://github.com/swat121/Weather
cd Weather

Build project:

mvn clean compile
mvn clean package [or mvn package -DskipTests] 

Launch jar file:

java -jar weather-0.0.1-SNAPSHOT.jar

Browser check: localhost:8080

Installation and running (docker)


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

Reference


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published