This application is an API for updating and consuming a database with articles about space flight news. It syncs every day with the Space Flight API, but it's possible to add, update and remove articles.
This is a challenge by Coodesh
You can test the API in our online Swagger UI.
I talk a little bit about this application in this video right here: https://www.loom.com/share/aacf4b7e800742cbbd48faa8a08f9177.
Open a terminal session, navigate to the Docker folder in this directory and run the following command:
docker-compose up
That's it. The API is now accessible through the URL localhost:8080/
.
You can download the jar file from one of the releases: https://github.com/crocarneiro/backend-challenge/releases
Or you can build the application yourself.
To build the application just make sure you have a distribution of the JDK 17 and the latest Maven version installed, then open the root folder of the repository in your terminal and run:
mvn package
Once you have a valid build of the the application you can run it with the following command:
java -jar backend_challenge-0.0.1-SNAPSHOT.jar # The .jar name may change
This application works with two profiles: "production" and "dev". The default profile is "production", so before running the application you have to set the environment variable "MONGO_DATABASE_URL" with the URL connection of your MongoDB instance.
Linux:
export MONGO_DATABASE_URL={your_URL_here}
Windows:
set MONGO_DATABASE_URL={your_URL_here}
To run the application in a development environment run the following command:
java -jar -Dspring.profiles.active=dev backend_challenge-0.0.1-SNAPSHOT.jar # The .jar name may change
If you have the env variable MONGO_DATABASE_URL
set, then the application will connect to this database, otherwise it will start a Mongo Container by itself and use it.
So the options are:
- You set up a Mongo DB instance by yourself: You have to set the var
MONGO_DATABASE_URL
. - You don't want to set up a instance by yourself: Do not set the var
MONGO_DATABASE_URL
, but you have to have Docker installed and running in your machine. - In production you do not have options: You have to set the var
MONGO_DATABASE_URL
.