This is a Spring Boot application that exposes an endpoint at api/v1/metadata.
The data that is returned by this application is stored in a DynamoDB that is hosted on AWS.
- The application uses maven to build and is similiar to other Spring Boot applications in the fact that it can be built and run locally using commands like
- mvn clean install
- and running the main class of the project (TvMetaDataApplication.java)
Because we are using application.properties files to hold sensitive data (DynamoDB username and password), we have chosen to encrypt the secret using a library called 'jasypt'.
Below are instructions you can use to encrpyt/decrypt and startup the application.
- Note that there is a file that contains the encrypted value, here - src/main/resources/encrypted.properties
- There is also a DynamoDBConfig class that is responsible for setting up the connection between the application server and the Dynamo DB.
- How to encrypt (this will only be neccessary if the token used in this app has since expired and a new token needs to be created).
- At the root of your project run the following command
mvn jasypt:encrypt-value -Djasypt.encryptor.password={INSERT YOUR "KEY" HERE} -Djasypt.plugin.value="{INSERT PASSWORD/TOKEN HERE}"
- The output of this will create something like the below
ENC(4Zq+DOCo5F0noBmYclLuY+CeJ5byGlC0OqWRkqoAkMRVF0mLDJXcTq5FaysleLOgRz+QS+lr+MnzYavuSH88lY/nnzXxooKlqaa4k+o1988=)
- Paste this value into your encrypted.properties file as the value for amazon.aws.secretkey
- When building your application via mvn you will need to run as follows
mvn clean install -Djasypt.encryptor.password={INSERT YOUR "KEY" HERE}
- To start/run the application, you will also need to add the below to your VM opts
-
-Djasypt.encryptor.password={INSERT YOUR "KEY" HERE}
- If you are not able to get this to work, you can simply paste the password itself into the encrypted.properties file as the value for amazon.aws.secretkey. But remember not to commit to version control.
- Have Docker and Docker compose installed locally. See https://docs.docker.com/compose/install/, for some instructions.
- Have a file at the root of your project called local.env that has a property used for the dynamoDB access token. See instructions in sampleEnv.env.template.
- Use the following command to build the image.
docker-compose build
- Use the following command to run the image.
docker-compose up
- Use the following command to ensure that the image is running.
docker ps
- Use the following command to tail the logs.
docker logs -f {insert_container_id_here}
- There is a postman collection in the resources folder that can be used to test the API locally.
- There is a swagger UI at http://localhost:8080/swagger-ui/#/