Welcome to the Swarm REST API project. This is a Spring Web application that serves as a backend REST API.
Before you begin, ensure you have met the following requirements:
-
Docker is installed on your machine. Docker will handle the Java and Gradle dependencies for you, so there's no need to install them separately. If you don't have Docker installed, please follow the installation guide for Docker.
-
Windows Users make sure you run the following command to set the line endings to match the *nix style to prevent issues with the Docker build:
git config --global core.autocrlf input
- Clone The Repository Open a terminal and run the following command to clone the source repository:
git clone https://github.com/LittleTechBookClub/swarm-rest-api.git
Navigate to the project directory:
cd swarm-rest-api
- Start the Application with Docker Compose Run the following command to build and start the application along with any necessary services:
docker compose up
Note for Linux users: Depending on your Docker setup, you might need to prepend sudo
to the above command:
sudo docker compose up
- Accessing The Application* You should be able to curl or check this url in browser: http://localhost:8080 and see "Hello Swarm!"
Unit Tests:
OpenAI API Call Example:
IMPORTANT Create an application.yml in the src/main/resources folder(the one with application.properties) AND another application.yml in test/resources. Then get an OpenAI api key from their website and copy it into both of the application.yml files in this format: OPENAI_API_KEY:
ABSOLUTELY DO NOT COPY THIS KEY INTO ANY OTHER FILE, OR COMMIT CODE WITH KEYS IN IT.
To stop and remove the containers, use the following command:
docker compose down
Linux Users If you used sudo
to start the application, make sure to use it here as well.
For Mac users: As with starting the application, there is typically no need to use sudo
.