A very basic implementation of CRUD API for treatment app, where you have a patient with curtain disease and you can perform 4 basic action: add, create, change and delete.
- Java 8 or later
- Lombok
- Vavr
- Spark
- Jackson
- Junit
- PostgreSQL
- PostgreSQL JDBC Driver
- java-dotenv
- ScriptRunner
-
Clone repository from gitHub:
https://github.com/MasoNord/backend-for-threatment-app.git
-
Import it in Intellij IDE or any IDE/text editor of you flavor
-
Create .env file, you can use the following template:
APP_PORT=<your app's port> DB_URL="jdbc:postgresql://localhost/treatment_app" DB_USER=<your db user> DB_PASSWORD=<your db password>
-
Run the application ;)
-
In case you decided to make some changes don't forget to run
tests
to ensures that all is good
- Request:
GET http://localhost:4000/api/patient
- Response:
200 - OK 500 - Internal Server Error
- Request:
GET http://localhost:4000/api/patient/{patientId}
- Response:
200 - OK 400 - Bad Request (id is not uuid) 404 - Not Found (patient is not found) 500 - Internal Server Error
- Request:
POST http://localhost:4000/api/patient/
- Body:
{ "name": "Denial", "sex": "M", "dob": "12.01.1955", "hp": { "name": "Dementia", "degree": 4 } }
- Response:
200 - OK 400 - Bad Request (id is not uuid, lack of required fields or wrong data type) 404 - Not Found (patient is not found) 500 - Internal Server Error
-
Request:
POST http://localhost:4000/api/patient/{patientId}
-
Body:
Here you can choose which field to change, untouched one will be set by a field's current value
{ "name": "Denial" }
-
Response:
200 - OK 400 - Bad Request (id is not uuid or wrong data type) 404 - Not Found (patient is not found) 500 - Internal Server Error
-
Request:
Delete http://localhost:4000/api/patient/{patientId}
-
Response:
204 - No Content 400 - Bad Request (id is not uuid) 404 - Not Found (patient is not found) 500 - Internal Server Error
If you inspired by project and have an interest to make this better with new ideas, your pull request is very welcomed :)