ASP.NET Core WebAPI should/ (must?) have
I am trying to have an extensive list about what an ASP.NET Core WebAPI project should / must have . After al, can be easy integrated into a VS project – or a wizard. I have put into 3 categories:
- Development – you need at development time.
- Testing – needed at testing time
- Production – needed in production
Note: All three are needed to be developed !
- Development – Visibility – see definition of the API
- Open API / Swagger – read https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle or https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-nswag
- For graphQL you can use https://github.com/graphql-dotnet/server
- You can also see https://github.com/ignatandrei/netcoreblockly ( my pet project for integrating GraphQL + Swagger with Blockly
- Development – Authorization + Authentication
- Windows Identity : https://docs.microsoft.com/en-us/aspnet/core/security/authentication
- ASP.NET Identity – https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identit
- Identity Server ( soon to be retired , paid version available ) – https://identityserver.io/
- OpenIddict – https://github.com/openiddict/openiddict-core
- OAuth, JWT, Cookie, 2FA s: https://docs.microsoft.com/en-us/dotnet/architecture/microservices/secure-net-microservices-web-applications/
- Development-Problem Details – flow the
errors as JSON text , keep status code - https://github.com/khellang/Middleware
and see https://codeopinion.com/http-api-problem-details-in-asp-net-core/ - Testing – test your application in CI mode
- Powershell https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7
- HttpRepl https://docs.microsoft.com/en-us/aspnet/core/web-api/http-repl
- Executing from file: https://github.com/ignatandrei/WebAPI2CLI
- Production – Versioning API endpoints
- See https://github.com/microsoft/aspnet-api-versioning . I do like
- Production – CORS
- Production – WhiteBox Monitoring
- Serilog https://serilog.net/
- NLog https://nlog-project.org/
- Ecosystem for logs – ELK – https://www.elastic.co/what-is/elk-stack ?
- Production –BlackBox Monitoring and Observability – read about RED and USE
- AppMetrics – https://www.app-metrics.io/web-monitoring/aspnet-core/tracking-middleware/
- Ecosystem: Prometheus
- Production –Rate limit – do not allow insane usage
- https://github.com/stefanprodan/AspNetCoreRateLimit
- Started my own project – do not have time to finish : https://github.com/ignatandrei/NetCoreRetarder
- Production –Caching data – to return latest values
- static variable caching
- IMemoryCache – https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory
- Production – Status of the system
https://github.com/microsoft/aspnet-api-versioning/wiki/Versioning-via-the-URL-Path
Nice to have:
- Graph with endpoints: https://andrewlock.net/adding-an-endpoint-graph-to-your-aspnetcore-application/ – read about https://en.wikipedia.org/wiki/DOT_(graph_description_language)
- Versioning end points- see what version is your program: http://msprogrammer.serviciipeweb.ro/2019/02/18/identify-version-for-application-and-components-for-backend-net-core-and-frontendangularpart-2-backend/
- Not yet discovered, but should have endpoints for environment, settings json and others.
- Formatters: BSON, CSV, YAML: https://github.com/WebApiContrib/WebAPIContrib.Core
Leave a Reply