This repository contains the REST API for the Gigsterous project.
This project uses project lombok. In order to use this project inside some IDE, you need to install lombok in your IDE. Follow the instructions in the project page: https://projectlombok.org/
The API is a Spring boot application.
There are several profiles in the application which can be switched using SPRING_PROFILES_ACTIVE environmental variable.
- main - live environment, database connection needs to be specified
- development - contains development data in an in-memory database
The whole application is secured with OAuth2. Authorization server needs to be running and contacted for the access token:
curl -X POST --user 'gigsterous:secret' -d 'grant_type=password&[email protected]&password=password' http://localhost:9000/gigsterous-auth/oauth/token
Each request to the API must contain the following header:
Authorization: Bearer $TOKEN$
You can also login into the authorization server using a custom login page and specify the redirection url. It is possible to obtain a bearer token that way:
http://localhost:9000/gigsterous-auth/oauth/authorize?response_type=token&client_id=gigsterous&redirect_uri=http://localhost:9000/gigsterous-auth/user
Both servers have Dockerfiles and are ready to be deployed as Docker images. The build process is embedded in Maven and can be manually triggered like this:
mvn package docker:build
After building both projects, two images are created:
- gigsterous/gigsterous-auth
- gigsterous/gigsterous-api
These two images are ready to be deployed anywhere with Docker installed.
There is a configuration file for Docker Compose in the root folder, which deals with linking between the servers and injecting environment variables. Currently the configuration file is set to development mode.
Last but not least - there is a run.sh script, which takes care of the whole workflow:
- Builds gigsterous-auth image
- Builds gigsterous-api image
- Runs Docker Compose and deploys both images