{"id":20657926,"url":"https://github.com/tarathep/tarathec-tutorial-backend","last_synced_at":"2025-03-09T23:47:15.965Z","repository":{"id":122466901,"uuid":"570060849","full_name":"tarathep/tarathec-tutorial-backend","owner":"tarathep","description":"Example ASP.NET 6 repository continuous integration (CI) pipeline with GitHub Actions to Code, Unit Test, SAST, Build artifact for prepare to deploy applications to Azure Web app.","archived":false,"fork":false,"pushed_at":"2023-03-04T00:19:06.000Z","size":127,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-01-17T11:33:31.950Z","etag":null,"topics":["asp","aspnet","continuous-integration","example","github-actions","mongodb","webapi"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tarathep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-11-24T08:48:43.000Z","updated_at":"2023-01-04T02:52:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"72a9011f-c6d6-42d4-9249-dec57cca5885","html_url":"https://github.com/tarathep/tarathec-tutorial-backend","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarathep%2Ftarathec-tutorial-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarathep%2Ftarathec-tutorial-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarathep%2Ftarathec-tutorial-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarathep%2Ftarathec-tutorial-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarathep","download_url":"https://codeload.github.com/tarathep/tarathec-tutorial-backend/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242768074,"owners_count":20182098,"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","aspnet","continuous-integration","example","github-actions","mongodb","webapi"],"created_at":"2024-11-16T18:24:02.538Z","updated_at":"2025-03-09T23:47:15.941Z","avatar_url":"https://github.com/tarathep.png","language":"C#","readme":"# Dotnet Tutorial Backend API\n\n## ASP.NET\n\nASP.NET is an open source web framework, created by Microsoft, for building modern web apps and services with .NET. ASP.NET is cross platform and runs on Windows, Linux, macOS, and Docker.\n\nmore : https://dotnet.microsoft.com/en-us/learn/aspnet/what-is-aspnet\n\n\u003cimg src=\"https://dotnet.microsoft.com/static/images/illustrations/swimlane-docker-three-platforms.svg?v=kcvcmmA1iaNdOyvKzlUHIC7FzTy4bQ0cgjM95HVqoaM\"\u003e\n\n## Init Project\n\nCreate solution project\n\n```ps\ndotnet new sln -n Tutorial-Api\n```\n\nCreate ASP.NET Web Api project\n\n```ps\ndotnet new webapi -o Api\n```\n\nCreate XUnit project\n\n```ps\ndotnet new xunit -o Xunit.Tests\n```\n\nAdd projects to solution\n\n```ps\ndotnet sln add .\\Tutorial.Api\\Tutorial.Api.csproj\ndotnet sln add .\\XUnit.Tests\\XUnit.Tests.csproj\n```\n\nAdd reference project into xunit project\n\n```ps\ndotnet add ./XUnit.Tests/XUnit.Tests.csproj reference .\\Tutorial.Api\\Tutorial.Api.csproj\n```\n\n## Init Database(MongoDB)\n\nAdd dependency MongoDB Driver into project\n\n```ps\ndotnet add package MongoDB.Driver --version 2.18.0\n```\n\nMongoshell\n\n```sh\nInstall mongo-shell\nhttps://www.mongodb.com/docs/mongodb-shell/install/\n\n\u003e mongod --dbpath \u003cdata_directory_path\u003e\n\n\u003e show dbs\n\n\u003e use tutorialdb\n\n\u003e db.createCollection('tutorials')\n\n\u003e db.tutorials.insertMany([{ \"title\": \"Design Patterns\", \"description\": \"\", \"published\": false}])\n\n\u003e db.tutorials.find().pretty()\n\n```\n\n## Run\n\n```ps\ndotnet run --project ./Tutorial.Api/\n```\n\nSwagger : https://localhost:7272/swagger\n\n\u003cimg src=\"./img/dotnet-swagger.png\"\u003e\n\nhttps://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run#examples\n\n- GET /api/tutorials\n\n    Response\n\n    ```json\n    [\n        {\n            \"id\": \"63730beabd3cb05f2331be45\",\n            \"title\": \"hello\",\n            \"description\": \"world\",\n            \"published\": null,\n            \"createdAt\": \"0001-01-01T00:00:00Z\",\n            \"updatedAt\": \"0001-01-01T00:00:00Z\"\n        },\n        {\n            \"id\": \"63732124796b18bc753e9157\",\n            \"title\": \"dotnet\",\n            \"description\": \"microsoft\",\n            \"published\": null,\n            \"createdAt\": \"0001-01-01T00:00:00Z\",\n            \"updatedAt\": \"0001-01-01T00:00:00Z\"\n        }\n    ]\n    ```\n\n- GET /api/tutorials/{id}\n\n    Response\n\n    ```json\n    {\n        \"id\": \"63730beabd3cb05f2331be45\",\n        \"title\": \"hello\",\n        \"description\": \"world\",\n        \"published\": null,\n        \"createdAt\": \"0001-01-01T00:00:00Z\",\n        \"updatedAt\": \"0001-01-01T00:00:00Z\"\n    }\n    ```\n\n- POST /api/tutorials\n\n    Request Body\n\n    ```json\n    {\n        \"title\": \"string\",\n        \"description\": \"string\",\n    }\n    ```\n\n    Response Body\n\n    ```json\n    {\n        \"code\": \"200\",\n        \"message\": \"Inserted a single document Success\"\n    }\n    ```\n\n- DELETE /api/tutorials\n\n    Response Body\n\n    ```json\n    {\n        \"code\": \"200\",\n        \"message\": \"All deleted\"\n    }\n    ```\n\n- DELETE /api/tutorials/{id}\n\n    Response Body\n\n    ```json\n    {\n        \"code\": \"200\",\n        \"message\": \"Deleted id 63730beabd3cb05f2331be45\"\n    }\n    ```\n\n- PUT /api/tutorials/{id}\n\n    Request Body\n\n    ```json\n        {\n        \"id\": \"63730beabd3cb05f2331be45\",\n        \"title\": \"hello\",\n        \"description\": \"world\",\n        \"published\": true\n        }\n    ```\n\n    Response Body\n\n    ```json\n    {\n        \"code\": \"200\",\n        \"message\": \"Deleted id 63730beabd3cb05f2331be45\"\n    }\n    ```\n\n## Build\n\n```ps\ndotnet build\n```\n\nRestore as distinct layers\n\n```ps\ndotnet restore\n```\n\nBuild and publish a release\n\n```ps\ndotnet publish -c Release -o out\n```\n\n## Unit Tests\n\nRun Coverage\n\n```ps\ndotnet test --collect:\"XPlat Code Coverage\"\n```\n\nAdd ReportGenerator nuget\n\n```ps\ndotnet add package ReportGenerator --version 5.1.10\n```\n\nSetup tool ReportGenerator\n\n```ps\ndotnet tool install -g dotnet-reportgenerator-globaltool\n```\n\nmore : https://www.nuget.org/packages/ReportGenerator\n\n## Run report HTML\n\n```ps\nreportgenerator -reports:\"XUnit.Tests\\TestResults\\*\\coverage.cobertura.xml\" -targetdir:\"./coveragereport\" -reporttypes:Html\n```\n\n## Configurations\n\nEnvironment variables\n\n|Env Name|Value|\n|---|---|\n|TutorialDatabase__ConnectionString|mongodb://xxxxxxxx|\n|TutorialDatabase__DatabaseName|tutorialdb|\n|TutorialDatabase__TutorialCollectionName|tutorials|\n\n## Logging integrate with Azure Application Insights\n\nhttps://learn.microsoft.com/en-us/azure/azure-monitor/app/ilogger#aspnet-core-applications\n\nAdd package ApplicationInsights\n\n```ps\ndotnet add package Microsoft.ApplicationInsights.AspNetCore --version 2.21.0\n```\n\n...\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarathep%2Ftarathec-tutorial-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarathep%2Ftarathec-tutorial-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarathep%2Ftarathec-tutorial-backend/lists"}