API for DMS2 & SE application project
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Database API used by application for Formula 1 team.
To get a local copy up and running follow these simple steps.
To run API make sure you have Java SE 17 installed. Application requires PostgreSQL Database Management System for data storage for this purpose you can use local DMS installation or Docker service.
- Clone the repo
git clone https://github.com/Mario-659/FormulaOneApi.git && cd FormulaOneApi
- Make sure Docker daemon is up and running
- Set environment variables needed for container set up or modify Intelij configuration options:
set POSTGRES_USER=admin
set POSTGRES_PASSWORD=admin
set POSTGRES_DB=f1api
--------------------------
set WORKING_DIR=<path> # optional parameter used for postgres data storage (without every time initialization)
- Run database on Docker container in detached mode
docker-compose up -d
- Set up environment variables needed for API-Docker connection.
set POSTGRES_URL=jdbc:postgresql://localhost:5432/f1api
set POSTGRES_USERNAME=postgres # has to match with POSTGRES_USER
- Build an run project using Gradle tasks (or use Intelij)
gradlew build && gradlew bootRun
- Application should create connection and initialize database from predefined
import.sql
file - Once app is running without any errors, do not close program. API is running and waiting for requests.
- Test API with simple request like
http://localhost:8080/api/v1/drivers/23
output should looks like this:
// http://localhost:8080/api/v1/drivers/23
{
"number": 23,
"firstName": "Alexander",
"lastName": "Albon",
"nationality": "Thai",
"team": {
"name": "Williams Racing"
},
"dateOfBirth": "1996-03-23"
}
- Clone the repo
git clone https://github.com/Mario-659/FormulaOneApi.git && cd FormulaOneApi
- Make sure Docker daemon is up and running
- Export environment variables needed for container set up or modify Intelij configuration options:
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=admin
export POSTGRES_DB=f1api
--------------------------
export WORKING_DIR # optional parameter used for postgres data storage (without every time initialization)
- Run database on Docker container in detached mode
docker-compose up -d
- Set up environment variables needed for API-Docker connection.
export POSTGRES_URL=jdbc:postgresql://localhost:5432/{POSTGRES_DB}
export POSTGRES_USERNAME=postgres # has to match with POSTGRES_USER
- Build an run project using Gradle tasks (Intelij)
gradlew build && gradlew bootRun
- Application should create connection and initialize database from predefined
import.sql
file - Once app is running without any errors, do not close program. API is running and waiting for requests.
- Test API with simple request like
http://localhost:8080/api/v1/drivers/23
output should looks like this:
// http://localhost:8080/api/v1/drivers/23
{
"number": 23,
"firstName": "Alexander",
"lastName": "Albon",
"nationality": "Thai",
"team": {
"name": "Williams Racing"
},
"dateOfBirth": "1996-03-23"
}
2023-01-15.21-24-51.mp4
To see swagger endpoint documentation run the spring boot application and go to http://localhost:8080/api/v1/swagger-ui/index.html#/