Skip to content

ioet/bpm-people-api

Repository files navigation

bpm-people-api

Build Status and Code coverage

Build Status Code Coverage SonarCloud Quality Gate

Run it locally

Make sure you have an AWS account and you have exported your credentials in the environment:

export AWS_ACCESS_KEY_ID="YOUR_ACCESS_KEY"
export AWS_SECRET_ACCESS_KEY="YOUR_SECRET_KEY"
export AWS_REGION="us-east-1"

You should write them into the bashrc-file as well, so that they are loaded each time you open a terminal.

vim ~/.bashrc

To start the app, try running the following gradlew command:

./gradlew bootRun

And you can directly access the people-api and it's swagger here:

http://localhost:8081/people
http://localhost:8081/swagger-ui.html

Postman

There is a Postman Collection included to test the api.

To run it from the command line install Newman in your machine.

npm install -g newman

You can use Newman to run the postman collection.

Running locally

newman run postman/collectionPeopleApi.json -e postman/env.json

Running against AWS

newman run postman/collectionPeopleApi.json -e postman/aws-env.json

Deploying as Lambda

Create a S3 bucket

aws s3 mb s3://cf-template-spring-boot-apps-as-lambda

Generate the bundle

./gradlew buildZip

Package the CouldFormation template

aws cloudformation package --template-file sam-people-api.yml --output-template-file output-sam-people-api.yml --s3-bucket cf-template-spring-boot-apps-as-lambda --s3-prefix people-api

Deploy the code as lambda

  • Deploy the code to AWS
aws cloudformation deploy --template-file output-sam-people-api.yml --stack-name bpm-people-api --capabilities CAPABILITY_IAM
  • Get the URL
aws cloudformation describe-stacks --stack-name bpm-people-api

Playing with the API

Locally

So far you can create, query and delete people using the API.

Query people

curl -X GET http://localhost:8081/people

Create a new person

curl -X POST http://localhost:8081/people -H 'Content-Type: application/json' -d '{ "name":"Your Name", "authenticationIdentity": "youremail@domain.com"}'

In AWS

Query people

curl -X GET  https://8iwffn7kpe.execute-api.us-east-1.amazonaws.com/ioet/people

Create a new person

curl -X POST  https://8iwffn7kpe.execute-api.us-east-1.amazonaws.com/ioet/people -H 'Content-Type: application/json' -d '{ "name":"Your Name", "authenticationIdentity": "youremail@domain.com"}'

Configuring IntelliJ IDE

If you want to run the application from IntelliJ you must configure the required environment variables following the next steps:

Setting the environment variables

1. Go to menu Run and choose Edit Configurations.
2. It will show a configurations window. Go to the tab Configuration.
3. Add the required environment variables AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID, and AWS_REGION with the correspondent values.

Run or Debug

Now, you can run or debug the app from the IntelliJ terminal. You can use JRbel to debug and redeploy the app.

Examining Code Quality locally precommit

Included in this repository is a tool (shell script) for examining the code as is in your current branch without requiring a commit first. To use this tool, you will need to create a GitHub token with which SonarCloud can integrate with GitHub on your behalf. To create said token, navigate to https://sonarcloud.io/account/security (log in as necessary with your GitHub account that is tied to this repository), enter a token name and click on the Generate button. A string will be displayed, which you should copy and store as your token (this string will never be displayed again, so be sure to save it in a safe place). Now you are ready to execute (in a Bash compatible shell):

SONAR_GITHUB_TOKEN=<my personal token created above> ./sonarcloud_analyze.sh

This command will also send the analysis results to sonarcloud.io. For executing an analysis without sending these results, configure your IntelliJ IDEA to use the SonarLint plugin.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6