{"id":15549253,"url":"https://github.com/adityaoberai/todoapi-techdome","last_synced_at":"2025-11-11T04:30:14.422Z","repository":{"id":114528994,"uuid":"366980353","full_name":"adityaoberai/TodoAPI-Techdome","owner":"adityaoberai","description":"Assignment: Todo API with JWT Token Authentication","archived":false,"fork":false,"pushed_at":"2021-05-13T19:46:13.000Z","size":13833,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-28T12:13:50.223Z","etag":null,"topics":["asp-net-web-api","dotnet5","ef-core","inmemory-db"],"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/adityaoberai.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":"2021-05-13T08:13:58.000Z","updated_at":"2021-05-14T21:31:03.000Z","dependencies_parsed_at":"2023-06-08T18:30:44.374Z","dependency_job_id":null,"html_url":"https://github.com/adityaoberai/TodoAPI-Techdome","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityaoberai%2FTodoAPI-Techdome","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityaoberai%2FTodoAPI-Techdome/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityaoberai%2FTodoAPI-Techdome/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityaoberai%2FTodoAPI-Techdome/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adityaoberai","download_url":"https://codeload.github.com/adityaoberai/TodoAPI-Techdome/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239587243,"owners_count":19663892,"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":["asp-net-web-api","dotnet5","ef-core","inmemory-db"],"created_at":"2024-10-02T13:33:01.664Z","updated_at":"2025-11-11T04:30:14.071Z","avatar_url":"https://github.com/adityaoberai.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TodoAPI - Techdome\r\n\r\n## [Assignment: Todo API with JWT Token Authentication](dot-net-2yrs.pdf)\r\n\r\n## Description\r\n\r\nThe **Todo API** is a **ASP.NET Web API** used to save any tasks to be done in an **InMemory database** using **Entity Framework Core**. It additionally utilizes **JWT Token Authentication** to authorize usage of the API endpoints.\r\n\r\nThe API achieves this using 2 controllers:\r\n\r\n* **TodoController**\r\n    * Contains the CRUD APIs for the list of todos\r\n    * Uses the `TodoItem` Model\r\n\r\n* **AuthController**\r\n    * Contains the registration and login APIs\r\n    * Uses the `User` Model\r\n\r\n## Controllers\r\n\r\nThe 2 controllers used in the API are:\r\n\r\n* TodoController\r\n* AuthController\r\n\r\n### TodoController\r\n\r\nThe `TodoController` contains the CRUD APIs for the todos we are adding to the database.\r\n\r\nHere are all the APIs:\r\n\r\n* GET `/getall`\r\n\r\n    * Get all the todo items from the database\r\n    * Get Http Request Link Example: `https://\u003cYOUR-DOMAIN:PORT\u003e/getall`\r\n    * Response Example:\r\n\r\n        ```json\r\n        [\r\n            {\r\n                \"id\": 1,\r\n                \"task\": \"Task 1\"\r\n            },\r\n            {\r\n                \"id\": 2,\r\n                \"task\": \"Task 2\"\r\n            }\r\n        ]\r\n        ```\r\n\r\n* GET `/get/{id}`\r\n\r\n    * Gets a single todo item from the database using the `id`\r\n    * Get Http Request Link Example: `https://\u003cYOUR-DOMAIN:PORT\u003e/get/1`\r\n    * Response Example:\r\n\r\n        ```json\r\n        {\r\n            \"id\": 1,\r\n            \"task\": \"Task 1\"\r\n        }\r\n        ```\r\n\r\n* POST `/create/{id}`\r\n\r\n    * Creates a new todo item in the database using the `id`\r\n    * Post Http Request Link Example: `https://\u003cYOUR-DOMAIN:PORT\u003e/create/1`\r\n    * Request Body Example:\r\n\r\n        ```json\r\n        {\r\n            \"task\": \"Task To Be Done\"\r\n        }\r\n        ```\r\n\r\n    * Response Example:\r\n\r\n        ```json\r\n        {\r\n            \"id\": 1,\r\n            \"task\": \"Task To Be Done\"\r\n        }\r\n        ```\r\n\r\n* PUT `/put/{id}`\r\n\r\n    * Updates a single todo item in the database using the `id`\r\n    * Put Http Request Link Example: `https://\u003cYOUR-DOMAIN:PORT\u003e/put/1`\r\n    * Request Body Example:\r\n\r\n        ```json\r\n        {\r\n            \"task\": \"Edited Task\"\r\n        }\r\n        ```\r\n\r\n    * Response Example:\r\n\r\n        ```json\r\n        Todo 1 updated successfully!\r\n        ```\r\n\r\n* DELETE `/delete/{id}`\r\n\r\n    * Deletes a single todo item from the database using the `id`\r\n    * Delete Http Request Link Example: `https://\u003cYOUR-DOMAIN:PORT\u003e/delete/1`\r\n    * Response Example:\r\n\r\n        ```json\r\n        Todo 1 deleted successfully!\r\n        ```\r\n\r\n#### Header Information\r\n\r\nMake sure to add the following header information:\r\n\r\n* **Content-Type**: `application/json`\r\n* **Authorization**: `Bearer \u003cTOKEN\u003e`\r\n\r\n### AuthController\r\n\r\nThe `AuthController` contains the registration and login APIs we are using to get the JWT token for authentication\r\n\r\n* POST `/auth/login`\r\n\r\n    * Returns the JWT token along with the user's details from the database after the user enters their email and password\r\n    * Post Http Request Link: `https://\u003cYOUR-DOMAIN:PORT\u003e//auth/login`\r\n    * Request Body Example:\r\n\r\n        ```json\r\n        {\r\n            \"email\": \"adityaoberai1@gmail.com\",\r\n            \"password\": \"pass1234\"\r\n        }\r\n        ```\r\n\r\n    * Response Example:\r\n\r\n        ```json\r\n        {\r\n            \"fname\": \"Aditya\",\r\n            \"lname\": \"Oberai\",\r\n            \"email\": \"adityaoberai1@gmail.com\",\r\n            \"isActive\": true,\r\n            \"role\": \"Admin\",\r\n            \"password\": \"pass1234\",\r\n            \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJnaXZlbl9uYW1lIjoiRm9vIiwidW5pcXVlX25hbWUiOiJCYXIiLCJlbWFpbCI6ImZvb0BiYXIueHl6Iiwicm9sZSI6IlVzZXIiLCJuYmYiOjE2MjA5MTkwNDksImV4cCI6MTYyMDkyMDg0OSwiaWF0IjoxNjIwOTE5MDQ5fQ.1HSVK9svUpH-oLQn8NS1I87KnZpr1RbXT3dorDWcPEU\"\r\n        }\r\n        ```\r\n\r\n* POST `/auth/register`\r\n\r\n    * Adds the user's details to the database and returns the JWT token after the user enters their information\r\n    * Post Http Request Link: `https://\u003cYOUR-DOMAIN:PORT\u003e/auth/register`\r\n    * Request Body Example:\r\n\r\n        ```json\r\n        {\r\n            \"fname\": \"Foo\",\r\n            \"lname\": \"Bar\",\r\n            \"email\": \"foo@bar.xyz\",\r\n            \"role\": \"User\",\r\n            \"password\": \"pass1234\"\r\n        }\r\n        ```\r\n\r\n        *Note:* `role` *can be removed for a registrant with the* `User` *Role. For a user with the* `Admin` *role, it will have to be added.*\r\n    * Response Example:\r\n\r\n        ```json\r\n        {\r\n            \"fname\": \"Foo\",\r\n            \"lname\": \"Bar\",\r\n            \"email\": \"foo@bar.xyz\",\r\n            \"isActive\": true,\r\n            \"role\": \"User\",\r\n            \"password\": \"pass1234\",\r\n            \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJnaXZlbl9uYW1lIjoiRm9vIiwidW5pcXVlX25hbWUiOiJCYXIiLCJlbWFpbCI6ImZvb0BiYXIueHl6Iiwicm9sZSI6IlVzZXIiLCJuYmYiOjE2MjA5MTkwNDksImV4cCI6MTYyMDkyMDg0OSwiaWF0IjoxNjIwOTE5MDQ5fQ.1HSVK9svUpH-oLQn8NS1I87KnZpr1RbXT3dorDWcPEU\"\r\n        }\r\n        ```\r\n\r\n        *Note: Token returned will be different from the example*\r\n\r\n#### Roles\r\n\r\nEach user can have 1 of 2 roles:\r\n\r\n* User\r\n* Admin\r\n\r\nHere is the access each role has to the **TodoController* APIs:\r\n\r\n| Role | APIs Accessible |\r\n| - | - |\r\n| User | `/getall` API only |\r\n| Admin | All TodoController APIs |\r\n\r\nThis information is claimed in the JWT Token. \r\nFailure to add the JWT Token as a Bearer Token in the **Authorization** header will result in a `401 Unauthorized` error\r\n\r\n## Models\r\n\r\nThe 2 models used in the API are:\r\n\r\n* User\r\n* TodoItem\r\n\r\n### User\r\n\r\n#### Example\r\n\r\n* In C#\r\n\r\n```csharp\r\npublic class User\r\n{\r\n    public string FirstName { get; set; }\r\n    public string LastName { get; set; }\r\n    public string Email { get; set; }\r\n    public bool IsActive { get; set; }\r\n    public string Role { get; set; }\r\n    public string Password { get; set; }\r\n    public string Token { get; set; }\r\n}\r\n```\r\n\r\n* In JSON\r\n\r\n```json\r\n{\r\n    \"fname\": \"Aditya\",\r\n    \"lname\": \"Oberai\",\r\n    \"email\": \"adityaoberai1@gmail.com\",\r\n    \"isActive\": false,\r\n    \"role\": \"Admin\",\r\n    \"password\": \"pass123\",\r\n    \"token\": \"\"\r\n}\r\n```\r\n\r\n**Note:** JSON Property Names have been mapped in C# Model in the API\r\n\r\n### TodoItem\r\n\r\n#### Example\r\n\r\n* In C#\r\n\r\n```csharp\r\npublic class TodoItem\r\n{\r\n    public long Id { get; set; }\r\n    public string TaskToDo { get; set; }\r\n}\r\n```\r\n\r\n* In JSON\r\n\r\n```json\r\n{\r\n    \"id\": 1,\r\n    \"task\": \"Test Task\"\r\n}\r\n```\r\n\r\n**Note:** JSON Property Names have been mapped in C# Model in the API","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityaoberai%2Ftodoapi-techdome","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadityaoberai%2Ftodoapi-techdome","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityaoberai%2Ftodoapi-techdome/lists"}