Moved To Github Star Wars API Kotlin
This api is a simple wrapper for the Star Wars API where you can get information about the characters, planets, starships, vehicles, species, films, and more with a few extra features where you can handle this data however you need.
The api also is documented with OpenAPI Swagger, so if you have any doubt, just open in your browser the follow url: http://domain-you-are-using/api/v0/swagger-ui/index.html
Please, read the content below to know how to use this api and if is there any doubt, please, contact me.
You'll see that once you open a PR some checks will be made, they are all essential to be passed before you merge your branch, so, make sure they are all passing.
One exception is snyk, which sometimes have some problems that can't be solved now, in this case you can just bypass.
- Snyk
- Just click in the link above and search for starwars-api-java, so you will be able to see the security problems.
- SonarCloud
- Clicking the link above you will be redirected to the quality analysis of this project.
- CodeCov
- You can click the link above and see the code coverage details by commit or any type of data or just see the summary in your PR.
Being authenticated:
curl -o token.json --location --request POST 'http://localhost:8080/api/v0/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"username":"another_application_who_consumes_this_api",
"password": "12"
}'
Using Authorization to get planets
curl -o result.json --location --request GET 'http://localhost:8080/api/v0/planets' \
--header 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhbm90aGVyX2FwcGxpY2F0aW9uX3dob19jb25zdW1lc190aGlzX2FwaSJ9.jnSWQTkg6dQ18tAPl8RS2JrdEdmtxBvx40Tq7WqYFighnziLKzUi2BLJ4S__dOlQDuJl0Lw3NYFS5IbGgd-XnQ' \
--header 'Content-Type: application/json' | json_pp
You'll have two options to start the app, the first one you can run the app and environment together in a container.
If you want just run the app in your java environment without setup any IDE or tool, just run the following from the app root.
chmod +x ./scripts/developer-mode.sh
./scripts/developer-mode.sh
Once you need debug and see some application logs, or want to use an IDE like Intellij, we strongly recommend you to up the environment with localstack and mongodb and export the following variables to your IDE or any tool you are using.
Environment Variables
MONGO_HOST=localhost;
MONGO_USER=admin;
MONGO_PASSWORD=password;
MONGO_PORT=27017;
MONGO_DB=starwars;
MONGO_CONTAINER_NAME=mongoservice;
AUTHORIZATION_SECRET=TazvE@QSs7AfWTMfEwXaR#TB7P6&p@JQ5RqCMqZ%cL5MU$2qPZyEDkTZH^#cuUW3nbRrTJy^+Hj5wWdNVg?-QypDRMyfE5pCwR#F%bh%73q#F^m*B?@PS;
AWS_SECRET_KEY=SECRET;
AWS_ACCESS_KEY=ACCESS;
AWS_REGION=us-east-1;
SNS_ENDPOINT=http://localhost:4566;
SQS_PLANET_DELETE_URL=http://localhost:4566/queue/planet-delete.fifo;
SQS_ENDPOINT=http://localhost:4566;
SWAPI_URL=https://swapi.dev/api;
ENV=ENV;
API_PORT=8080;
PROFILE=dev;
MONGO_AUTH_SOURCE=admin
KAFKA_BOOTSTRAP_ADDRESS=http://localhost:9093
Once you set it, just run the following command:
chmod +x ./scripts/cache-docker/mount-environment.sh
./scripts/cache-docker/mount-environment.sh
After this, just start the app in your tool.
Execute the following commands
chmod +x ./scripts/test-mode.sh
./scripts/test-mode.sh
Export the following env vars to your tool:
MONGO_HOST=localhost
MONGO_USER=admin
MONGO_PASSWORD=password
MONGO_PORT=27017
MONGO_DB=starwars
MONGO_CONTAINER_NAME=mongoservice
AUTHORIZATION_SECRET=TazvE@QSs7AfWTMfEwXaR#TB7P6&p@JQ5RqCMqZ%cL5MU$2qPZyEDkTZH^#cuUW3nbRrTJy^+Hj5wWdNVg?-QypDRMyfE5pCwR#F%bh%73q#F^m*B?@PS
AWS_SECRET_KEY=SECRET
AWS_ACCESS_KEY=ACCESS
AWS_REGION=us-east-1
SNS_ENDPOINT=http://localhost:4566
SQS_ENDPOINT=http://localhost:4566
SQS_PLANET_DELETE_URL=http://localhost:4566/queue/planet-delete.fifo
SWAPI_URL=https://swapi.dev/api
ENV=ENV
API_PORT=8080
PROFILE=test
MONGO_AUTH_SOURCE=admin
KAFKA_BOOTSTRAP_ADDRESS=http://localhost:9093
Once you set it, just run the following command:
chmod +x ./scripts/cache-docker/mount-environment.sh
./scripts/cache-docker/mount-environment.sh
After done it to your tool, just run the tests in your tool.