{"id":18623714,"url":"https://github.com/clifftech123/hng-task-2-net","last_synced_at":"2026-04-19T19:32:36.751Z","repository":{"id":195426626,"uuid":"692884218","full_name":"Clifftech123/HNG-TASK-2-NET","owner":"Clifftech123","description":"CRUD REST API project for managing a person resource.","archived":false,"fork":false,"pushed_at":"2023-09-28T21:54:15.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-17T06:41:05.638Z","etag":null,"topics":["backend","csharp","docker","docker-compose","dotnet"],"latest_commit_sha":null,"homepage":"","language":"C#","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/Clifftech123.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-09-17T21:44:50.000Z","updated_at":"2023-09-22T00:07:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"25de6853-3b46-468c-9d39-be828fa779db","html_url":"https://github.com/Clifftech123/HNG-TASK-2-NET","commit_stats":null,"previous_names":["clifftech123/hng-task-2-net"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Clifftech123/HNG-TASK-2-NET","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clifftech123%2FHNG-TASK-2-NET","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clifftech123%2FHNG-TASK-2-NET/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clifftech123%2FHNG-TASK-2-NET/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clifftech123%2FHNG-TASK-2-NET/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clifftech123","download_url":"https://codeload.github.com/Clifftech123/HNG-TASK-2-NET/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clifftech123%2FHNG-TASK-2-NET/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32020547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["backend","csharp","docker","docker-compose","dotnet"],"created_at":"2024-11-07T04:25:43.608Z","updated_at":"2026-04-19T19:32:36.696Z","avatar_url":"https://github.com/Clifftech123.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# CRUD REST API for \"Person\" Resource\n\nWelcome to the CRUD REST API project for managing a \"person\" resource. This project allows you to perform basic CRUD (Create, Read, Update, Delete) operations on person data. The API is built with C#, .NET, Docker, and PostgreSQL.\n\n## Technologies Used\n\n- C#\n- .NET\n- Docker\n- PostgreSQL\n\n## Overview\n\nThis project aims to create a robust REST API for managing person data. It includes endpoints for creating, reading, updating, and deleting person records. The API is designed to handle dynamic parameters, making it flexible to perform operations based on provided details.\n\n## Features\n\n- Create a new person record.\n- Retrieve person details by name.\n- Update existing person records by name.\n- Delete person records by name.\n- Dynamic parameter handling for flexible queries.\n- Secure interactions with the database to prevent common vulnerabilities.\n\n## Getting Started\n\n1. Clone this repository to your local machine using `git clone` or download the ZIP file and extract it to a folder.\n\n```bash\n  git clone https://github.com/your-username/your-repo.git\n```\n\n2. Install Docker and Docker Compose on your machine.\n\n3. Create a `.env` file and configure your environment variables (e.g., database connection details).\n\n4. Run the API using Docker Compose.\n\n```bash\n  docker-compose up\n```\n\n## API Endpoints and HTTP Methods\n\n### Create a Person\n\n- **Endpoint:** `POST  http://localhost:5000/api/persons`\n\n- **Request Format:**\n\n  ```json\n  {\n    \"name\": \"Clifford Opoku Isaiah\"\n  }\n  ```\n\n- **Response Format (Success):**\n\n```json\n{\n  \"name\": \"Clifford Opoku Isaiah\",\n  \"id\": 1\n}\n```\n\nThis endpoint creates a new person record in the database. The name attribute is required and must be a string. The API returns the newly created person record in the response body.\n\n- **Response Format (Error):**\n  If an invalid input is provided, the API returns an error message in the response body.\n\n```json\n{\n  \"error\": \"Invalid input data\"\n}\n```\n\n### Retrieve a Person\n\n- **Endpoint:** `GET  http://localhost:5000/api/persons/:id`\n\n- **Request Parameters:**\n  - id (integer) - The ID of the person record to retrieve.\n\n- **Response Format (Success):**\n\n```json\n{\n  \"name\": \"Clifford Opoku Isaiah\",\n  \"id\": 1\n}\n```\n\n- **Response Format (Error - Person not found):**\n\n  ```json\n  {\n    \"error\": \"Person not found\"\n  }\n  ```\n\n### Update a Person\n\n- **Endpoint:** `PUT   http://localhost:5000/api/persons/:id`\n\n- **Request Format:**\n\n  ```json\n  {\n    \"name\": \"Updated Name\"\n  }\n  ```\n\n- ## Request Parameters\n\n  - id (integer) The ID of the person record to update.\n- **Response Format (Success):**\n\n```json\n{\n  \"name\": \"Updated Name\",\n  \"id\": 1\n}\n```\n\n- **Response Format (Error - Person not found):**\n\n  ```json\n  {\n    \"error\": \"Person not found\"\n  }\n  ```\n\n### Delete a Person\n\n- **Endpoint:** `DELETE   http://localhost:5000/api/persons/:id`\n\n- **Response Format (Success):** No content (204)\n\n- ## Request Parameters\n\n  - id (integer) The ID of the person record to delete.\n- **Response Format (Error - Person not found):**\n\n```json\n{\n  \"error\": \"Person not found\"\n}\n```\n\n\n### POSTMAN API AUTOMATION TESTING\n\nThis project includes automated tests for each API endpoint using Postman. The tests are located in the `Postman` folder and are organized by endpoint. The tests are designed to run against a local instance of the API. To run the tests, follow the steps below.\n\n## API Points\n\n- **Endpoint:** `POST  http://localhost:5000/api/persons`\n\n- Test code\n\n```js\n - *  `Postman Collection name `: Post-Person-Test\n\npm.test(\"Create a Person - Status Code is 201\", function () {\n    pm.response.to.have.status(201);\n});\n\npm.test(\"Create a Person - Response  Name\", function () {\n    pm.response.to.have.jsonBody(\"name\");\n});\n```\n\n- **Endpoint:** `GET  http://localhost:5000/api/persons/:id`\n\n- Test code\n\n```js\n - *  `Postman Collection name `: Get-Person-by-id\npm.test(\"Response body is valid JSON\", function () {\n    pm.response.to.be.json;\n});\n\n```\n\n- **Endpoint:** `PUT  http://localhost:5000/api/persons/:id`\n\n- Test code\n\n```js\n - *  `Postman Collection name `: update-person-by-id\n\npm.test(\"Update a Person - Status Code is 200\", function () {\n    pm.response.to.have.status(200);\n});\n\n```\n\n- **Endpoint:** `DELETE  http://localhost:5000/api/persons/:id`\n\n- Test code\n\n```js\n - *  `Postman Collection name `: Delete-Person-by-id\n\npm.test(\"Update a Person - Status Code is 404\", function () {\n    pm.response.to.have.status(404);\n});\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclifftech123%2Fhng-task-2-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclifftech123%2Fhng-task-2-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclifftech123%2Fhng-task-2-net/lists"}