{"id":28395035,"url":"https://github.com/asr-experiments/dropwizard-demo","last_synced_at":"2025-09-15T14:18:56.584Z","repository":{"id":245416415,"uuid":"818181512","full_name":"ASR-Experiments/Dropwizard-Demo","owner":"ASR-Experiments","description":"Repository for demoing the usage of Java's Dropwizard framework.","archived":false,"fork":false,"pushed_at":"2024-07-05T10:38:25.000Z","size":1058,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-01T06:32:50.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://asr-experiments.github.io/Dropwizard-Demo/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ASR-Experiments.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-21T09:19:21.000Z","updated_at":"2024-07-05T10:38:27.000Z","dependencies_parsed_at":"2024-06-28T09:52:50.880Z","dependency_job_id":null,"html_url":"https://github.com/ASR-Experiments/Dropwizard-Demo","commit_stats":null,"previous_names":["asr-experiments/dropwizard-demo"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ASR-Experiments/Dropwizard-Demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASR-Experiments%2FDropwizard-Demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASR-Experiments%2FDropwizard-Demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASR-Experiments%2FDropwizard-Demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASR-Experiments%2FDropwizard-Demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ASR-Experiments","download_url":"https://codeload.github.com/ASR-Experiments/Dropwizard-Demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASR-Experiments%2FDropwizard-Demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262172500,"owners_count":23270028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-31T19:10:53.411Z","updated_at":"2025-09-15T14:18:56.572Z","avatar_url":"https://github.com/ASR-Experiments.png","language":"Java","readme":"# DropWizard demo\n\nThis is a simple demo of a DropWizard application. It is a simple RESTful service that allows you to create, read,\nupdate and delete users.\n\n## Running the application\n\n### Via **Intellij**\n\n1. Import run configuration from `./idea/runConfigurations/TrueApplication.xml`\n2. Click on the Run or Debug button to Run the application.\n\n### Via **Maven**\n\n1. Run the following command in the terminal:\n    ```shell\n    mvn clean install\n    ```\n2. Run the following command in the terminal:\n    ```shell\n    java -jar target/First-0.0.1-SNAPSHOT.jar server sample-config.yml\n    ```\n    1. _Need to update the properties first._\n\n## What's Covered\n\n1. **HealthCheck**: A simple health check to check the health of the application.\n2. **HelloWorldEndpoint**: A simple endpoint that returns a message `Hello! \u003cname\u003e`.\n3. **Database Interactions**: It covers the CRUD operations with a Postgres database.\n4. **Downstream API Calls**: It covers the downstream API calls to a sample service.\n5. **Authorization**: It covers the basic authorization for the APIs.\n6. **Idempotency**: It covers the idempotency for the APIs.\n7. **Logging**: It covers the logging for the application.\n\n## Pre-Requisite\n\n### Database setup\n\n1. **Pre-requisite**: Postgres should be installed and running on the local machine.\n    1. Create a database.\n    2. Create a sequence for Id Generation.\n        ```sql\n        CREATE SEQUENCE IF NOT EXISTS user_schema.id_sequence\n        INCREMENT 1\n        START 1\n        MINVALUE 1\n        MAXVALUE 9223372036854775807\n        CACHE 1;\n        ```\n    3. Finally, Create the following table:\n        ```sql\n        CREATE TABLE IF NOT EXISTS tbl_user\n        (\n        name character varying(128) NOT NULL,\n        email character varying(128),\n        password text NOT NULL,\n        id bigint NOT NULL DEFAULT nextval('user_schema.id_sequence'::regclass),\n        CONSTRAINT tbl_user_pkey PRIMARY KEY (id),\n        CONSTRAINT \"user\" UNIQUE NULLS NOT DISTINCT (name)\n        );\n        ```\n    4. Update `config.yml` by replacing the placeholders for database details,\n       like `\u003cDB_USER\u003e`, `\u003cDB_PASSWORD\u003e`, `\u003cDB_NAME\u003e`,\n       `\u003cDB_HOST\u003e`, `\u003cDB_PORT\u003e`.\n    5. Add another column for Authorization (added in Iteration 5 (0.0.5))\n       ```sql\n       ALTER TABLE IF EXISTS user_schema.tbl_user\n          ADD COLUMN role character varying(16) DEFAULT USER;\n       ```\n    6. Add a sample user for testing.\n       ```sql\n         INSERT INTO tbl_user (name, email, password, role)\n            VALUES ('username', 'username@test.com', 'password', 'ADMIN');\n       ```\n\n## APIs\n\n1. A **HealthCheck** that returns the health of the application.\n    * To access the endpoint, hit the following URL in the browser:\n      \u003e [http://localhost:8081/healthcheck](http://localhost:8081/healthcheck)\n    * It will return the health of the application in the browser.\n2. A **HelloWorldEndpoint** that returns a simple message `Hello! Stranger` to user. If a name is provided, it will\n   return `Hello! \u003cname\u003e`.\n    * To access the endpoint, hit the following URL in the browser:\n      \u003e [http://localhost:8080/hello-world](http://localhost:8080/hello-world)\n\n      \u003e It will return Hello! Stranger in the browser.\n    * To get the message with a name, hit the following URL in the browser:\n      \u003e [http://localhost:8080/hello-world?name=John](http://localhost:8080/hello?name=John)\n\n      \u003e It will return `Hello! John` in the browser.\n3. It also covers the Database interactions with a postgres database, check [Pre-requisites](###Database-setup).\n    * To access the endpoint, hit the following URL in the **cURL** or other clients:\n        ```shell\n           curl --location 'localhost:8080/user' \\\n                --header 'X-Idempotency-Token: b415d958-b617-404b-80e9-009202a82395' \\\n                --header 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n        ```\n      \u003e It will return a response similar to following.\n       ```json\n         [{\"id\":1,\"name\":\"username\",\"email\":\"username@test.com\",\"password\":\"password\",\"role\":\"ADMIN\"}]\n       ```\n    * To create a user, hit the following URL in **cURL** or other clients:\n       ```shell\n          curl --location 'localhost:8080/user' \\\n                --header 'X-Idempotency-Token: 918c92d5-0f03-4285-9ce3-2d3fdaa3b708' \\\n                --header 'Content-Type: application/json' \\\n                --header 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\n                --data-raw '{\n                \"name\": \"user\",\n                \"email\": \"user@test.com\",\n                \"password\": \"password\",\n                \"role\": \"USER\"\n                }'\n        ```\n      \u003e It will return the created user in the response.\n        ```json\n          {\"id\":2,\"name\":\"user\",\"email\":\"user@test.com\",\"password\":\"password\",\"role\":\"USER\"}\n        ```\n        * Calling the first api again, will respond with the newly created user.\n        * Rest of the CRUD operations can be performed in a similar way by changing the method and payload.\n            * For more information, check the code in `UserResource` class.\n            * OR, check `/docs` folder.\n4. Additionally, it also covers the downstream API calls to a sample service.\n    * To access the endpoint, hit the following URL in the `cURL` or other clients:\n        ```shell\n           curl --location 'localhost:8080/sample' \\\n               --header 'X-Idempotency-Token: 918c92d5-0f03-4285-9ce3-2d3fdaa3b708' \\\n               --header 'Content-Type: application/json' \\\n               --header 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='\n        ```\n    * It will return a response similar to following.\n      ```json\n      [\n          {\n              \"id\": 1,\n              \"name\": \"Leanne Graham\",\n              \"username\": \"Bret\",\n              \"email\": \"Sincere@april.biz\",\n              \"address\": {\n                  \"street\": \"Kulas Light\",\n                  \"suite\": \"Apt. 556\",\n                  \"city\": \"Gwenborough\",\n                  \"zipcode\": \"92998-3874\",\n                  \"geo\": {\n                      \"lat\": \"-37.3159\",\n                      \"lng\": \"81.1496\"\n                  }\n              },\n              \"phone\": \"1-770-736-8031 x56442\",\n              \"website\": \"hildegard.org\",\n              \"company\": {\n                  \"name\": \"Romaguera-Crona\",\n                  \"catchPhrase\": \"Multi-layered client-server neural-net\",\n                  \"bs\": \"harness real-time e-markets\"\n              }\n          },\n          .\n          .\n          .\n      ]\n      ```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasr-experiments%2Fdropwizard-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasr-experiments%2Fdropwizard-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasr-experiments%2Fdropwizard-demo/lists"}