Up to this point I have only used AI to generate code snippets, either via Gemini web or the Codeium extension on VS Code/Rider. Recently, I decided to give Trae AI IDE a try and as I was updating my portfolio site at esausilva.dev, a brilliant idea sparked and found a use-case to fully utilize the power of AI. That is when I had my AHA moment, my AI enlightening moment.
Continue readingImplementing Idempotency in .NET Core
Implementing idempotency in .NET Core can be accomplished with a filter, which I will cover at a high level.
Putting it simply, idempotency is the concept of executing an operation multiple times and getting the same result back, given the same input parameters for each request. In our case, we will be setting up idempotency for an API endpoint.
Continue readingUnintended Side Effects with .NET Core Service Lifetimes and Dependency Injection (DI)
We have an API that handles ~45k monthly requests that was, at times, responding strangely. I suspected it was related to the .NET Core service lifetimes.
The symptoms in question were that out of the blue, the API response body had a status code of 409 with a message of invalid user-provided values, however, the actual HTTP response status code was 200.
Continue readingPostman Tips for Better API Testing
Postman is a powerful tool for testing and working with APIs. In this blog post, I will describe some Postman tips for better API testing that I have used for quite some time and have helped tremendously.
Continue readingCalling and Authenticated API from Next.js Server Side
Calling an authenticated API from Next.js server side is a little different than calling it from the client side and concerning authentication cookies.
Continue readingMocking External APIs or services in .NET
Whether calling the external API costs money or mocking desired behavior to code specific business rules. Sometimes external APIs could be mocked during the development of services or APIs. I believe this is an important strategy in every developer’s toolbox.
Continue reading.NET Global Exception Handler to Return Problem Details For Your APIs
This article will focus on handling custom exceptions for flow control on .NET with a global exception handler and return a problem details object.
Having said that. There are, for the most part, two schools of thought. One where it is OK to throw a (custom) exception to control flow. i.e. Throw a UserNotFoundException
when a user is not found. The second is implementing the Result Pattern where you return a Success or an Error to control the flow. i.e. Result.UserNotFound
.
Run Load (Performance) Testing with Postman
I recently found Postman has built-in capability to run load (performance) testing. Some use cases to run load testing are identifying bottlenecks, latency, and failures on your API when calling at near production scale.
Continue readingConfigure CORS in .NET
We need to configure CORS in .NET (or really in any other language) when an application’s front-end and back-end are being served from different domains, aka origins. And more than likely, during development, both the front-end and back-end will be running from different ports on localhost.
Continue reading.NET Core Options Pattern For Live Reload Settings
There are many great posts about implementing the Options Pattern .NET Core with IOptionsMonitor on the interwebs, but many fail to point out one “gotcha” when working with IOtionsMonitor
to live reload settings.