GetInfra WebApi Abstractions introduction
As havily working on Web API developement I've extracted several accpects in order not to repeat them in each project. In my case, having standard responses among dozens of microservices significally speed up a front-end developement. Maybe can be found useful for your projects as well.
The library includes abstractions for the following:
- Validation - refers to request validation
- Responses - several generic classes that can be used as response for api calls.
Validation is vital part of Web API development, and I as a developer would like to have a flexability to
inject custom validators by just implementing
Front-end developers always complian about the responses, especially when it comes to
DELETE methods, To make it universal I came to following base response class:
isValid - indicates if there are validation errors.
succeeded - indicates if there are runtime errors. by runtime I mean
some try...catch handled exeptions.
errors - array of run time exceptions
validationErrors - array of validation exceptions
Id or newId - depending on implementation, the
id property associated with the record.
There are several variations for the response:
GenericValResponse<T>- to returns struct with associated Id
GenericRefResponse<T>- to returns class as associated Id
Another aspect the libarary is dealing with is list responses, which requires pagination and aggregation.
PagedResponse<T>- paginated response
PagedResponseWithAggs<T>- paginated response with aggregations
In next posts I will talk about how to create a custom validator, how to use custom regular expressions for your validators and how to form detailed response.
Debugging microservices is always tricky and time consuming specially without proper code level logging in place.
Meet Konso. It's developed as a solution for this challenge and can help with saving development effort for your team up to 30%. 🎯🎉
The key functions are:
🔥 Centralized logging for your microservices
🔥 Tracing with metrics and value tracking events
🔥 Ad-Hoc events exploration
🔥 Saving your queries
🔥 Create alerts and get notified
You can start collecting you project's logs in 5 minutes. 🕐💪
To Learn more about logging tool, book a free demo.
To get started for free, Create your free account now