This project is built on top of spring boot 2 and can be deployed to AWS Lambda.
solution 1: Cognito (OAuth 2.0) + API Gateway
solution 2: API Key
{
"userName": String,
"userEmail": String,
"age": Integer,
"gender": String,
"isSmoker": Boolean,
"condition": {
"type2Diabetes": Boolean,
"type1Diabetes": Boolean,
"hypertension": Boolean,
"coronaryHeartDiseases": Boolean,
"copd": Boolean,
"cancer": Boolean,
"chronicKidneyDisease": Boolean,
"other": String
},
"selfScreening": {
"testedPositive": Boolean,
"dryCough": Enum,
"fever": Enum,
"soreThroat": Enum,
"fatigue": Enum,
"shortnessOfBreadth": Enum,
"lossOfSmell": Enum,
"lossOfTaste": Enum,
"muscleSoreness": Enum,
"other": String,
"otherLevel": Enum
}
}
* Severity Enum: ['none', 'mild', 'moderate', 'severe']
with maven wrapper, you don't have to install Maven
git clone [email protected]:cv19-mars/cv19-mars.git
./mvnw spring-boot:run
Swagger UI url: http://{baseUrl}/api-docs.html
Open API json: http://{baseUrl}/api-docs
The following endpoints are general form of REST APIs, please refer to the specific API descriptions below for sample input/output. At the time of writing, Mars only supports restdb.io Firestore will be supported soon
- List all cases
[GET] {baseUrl}/cv19/cases/listAll
- Get by properties, e.g. username, email . . . etc
[GET] {baseUrl}/cv19/cases/getBy
- Add a new case
[POST] {baseUrl}/cv19/cases/add
- Update an existing case
[PUT] {baseUrl}/cv19/cases/update/{id}
*Please update your api.key and data.endpoint in restdbprops.properties
- GET all documents from the case-data-model collection
https://cv19mars-9e51.restdb.io/rest/case-data-model
- GET records by query user email
https://cv19mars-9e51.restdb.io/rest/case-data-model?q={"userName":"[email protected]"}
Sample Output:
[
{
"_id": "5e928c3e5053da7500024860",
"userName": "Cantrell Lindsay",
"userEmail": "[email protected]",
"age": 96,
"gender": "male",
"isSmoker": false,
"condition": {
"type2Diabetes": false,
"type1Diabetes": false,
"hypertension": false,
"coronaryHeartDiseases": true,
"copd": false,
"cancer": true,
"chronicKidneyDisease": true,
"other": "ut"
},
"selfScreening": {
"testedPositive": true,
"dryCough": "none",
"fever": "none",
"soreThroat": "mild",
"fatigue": "severe",
"shortnessOfBreadth": "severe",
"lossOfSmell": "mild",
"lossOfTaste": "moderate",
"muscleSoreness": "severe",
"other": "ad",
"otherLevel": "mild"
}
}
]
- POST a new document to the case-data-model collection
https://cv19mars-9e51.restdb.io/rest/case-data-model
Body - JSON
{
"userName": "kevin quinn",
"userEmail": "[email protected]",
"age": 18,
"gender": "male",
"isSmoker": false,
"condition": {
"type2Diabetes": false,
"type1Diabetes": false,
"hypertension": false,
"coronaryHeartDiseases": true,
"copd": false,
"cancer": true,
"chronicKidneyDisease": true,
"other": "sneezing"
},
"selfScreening": {
"testedPositive": false,
"dryCough": "none",
"fever": "none",
"soreThroat": "mild",
"fatigue": "severe",
"shortnessOfBreadth": "severe",
"lossOfSmell": "mild",
"lossOfTaste": "moderate",
"muscleSoreness": "severe",
"other": "ad",
"otherLevel": "mild"
}
}
- PUT an updated record to collection by Object ID
https://cv19mars-9e51.restdb.io/rest/case-data-model/{ObjectID}
e.g. https://cv19mars-9e51.restdb.io/rest/case-data-model/5e928c3e5053da7500024860
Body -JSON
{
"userEmail": "[email protected]",
"gender": "male"
}
The cv19-mars project, created with aws-serverless-java-container
.
The starter project defines a simple /ping
resource that can accept GET
requests with its tests.
The project folder also includes a template.yml
file. You can use this SAM file to deploy the project to AWS Lambda and Amazon API Gateway or test in local with the SAM CLI.
Another deployment way is to use our deploy.sh which uses aws cloudformation commands but remember need to create a s3 bucket for artifact and a stack name for cloudformation stack.
You can use the SAM CLI to quickly build the project
$ mvn archetype:generate -DartifactId=cv19-mars -DarchetypeGroupId=com.amazonaws.serverless.archetypes -DarchetypeArtifactId=aws-serverless-jersey-archetype -DarchetypeVersion=1.5 -DgroupId=jw.io -Dversion=1.0-SNAPSHOT -Dinteractive=false
$ cd cv19-mars
$ sam build
Building resource 'Cv19MarsFunction'
Running JavaGradleWorkflow:GradleBuild
Running JavaGradleWorkflow:CopyArtifacts
Build Succeeded
Built Artifacts : .aws-sam/build
Built Template : .aws-sam/build/template.yaml
Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Deploy: sam deploy --guided
From the project root folder - where the template.yml
file is located - start the API with the SAM CLI.
$ sam local start-api
...
Mounting com.amazonaws.serverless.archetypes.StreamLambdaHandler::handleRequest (java8) at http://127.0.0.1:3000/{proxy+} [OPTIONS GET HEAD POST PUT DELETE PATCH]
...
Using a new shell, you can send a test ping request to your API:
$ curl -s http://127.0.0.1:3000/ping | python -m json.tool
{
"pong": "Hello, World!"
}
To deploy the application in your AWS account, you can use the SAM CLI's guided deployment process and follow the instructions on the screen
$ sam deploy --guided
Once the deployment is completed, the SAM CLI will print out the stack's outputs, including the new application URL. You can use curl
or a web browser to make a call to the URL
...
-------------------------------------------------------------------------------------------------------------
OutputKey-Description OutputValue
-------------------------------------------------------------------------------------------------------------
Cv19MarsApi - URL for application https://xxxxxxxxxx.execute-api.us-west-2.amazonaws.com/Prod/pets
-------------------------------------------------------------------------------------------------------------
Copy the OutputValue
into a browser or use curl to test your first request:
$ curl -s https://xxxxxxx.execute-api.us-west-2.amazonaws.com/Prod/ping | python -m json.tool
{
"pong": "Hello, World!"
}
./deploy.sh