Request validation is the probably the most boring but critical layer of any web framework. Today I will show you how to do it right in gin framework in golang.
How to validate request in Gin with Golang
Golang is an amazing language, and gin is a great backend framework to use. Conceptually, it has no differences than the any backend framework we used in other languages. But its documentation does cause some problems for a accomplish a simple thing like request validation. Here, I will share my findings in terms of how to grab the value and validation in gin.
React state management libraries in 2022
The React state management library is a constant topic in React community, but seems we are pretty settled recently with some obvious winners. This blog will focus all the popular choices and compare them so one can have a quick understanding of the libraries, and when to use them. You can also take it as a super quick crash course to all the libraries that listed here. (If you feel one not listed, let me know, I will check and add :D )
Let’s start.
How to easily setup mongodb for cypress
Tests should be isolated with each other. Today let’s see an easy way to setup and teardown your MongoDB database before each cypress run. The concept should be applicaple to other senario other than cypress, and the code for setup the MongoDB should be able to adapt to other cases as well.
How to debug Typescript in VS Code
Since this waste me a hour. I decided to publish my experience here to save your time.
The missing Typescript wrapper for React native ActionSheet
For menus on React native. I still love ActionSheet, and I use @expo/react-native-action-sheet
, yes, you can use it in non-Expo React native project, pretty good. An universal ActionSheet API for Android, iOS and Web. Great! The interface is 100% match the original RN ActionSheetIOS, with some additional settings for Android and Web.
Everything works perfectly, with a problem, the signature of that function showActionSheetWithOptions()
generates too much boilerplate everytime I use it. It destroyed the simplicity of the ActionSheet.
In this blog, let’s make it simple again, if you just use RN’s ActionSheetIOS, this blog still helps you for cleaner code, if you are using Javascript, it helps too.
How to solve [Xcodeproj] Unknown object version
Today I ran into this issue while installing React native 0.64.1. The pod install
always threw error: [Xcodeproj] Unknown object version
. Even with a basic command react-native init
. Let’s see how to solve it.
The evil pattern of Redux that reduces boilerplate
With the createSlice
of redux toolkit, the actions could generated when writing reducer, which nearly eliminate all boilerplate from Redux to a MobX level.
But still, can we do better? Let me show you the dark side of a Redux usage that you may like or not like. But it will make your Redux life easier in the future. And I will show you how to use Typescript to make it even better.
How to implement Relay node in Graphql
Relay is a great GraphQL client side library made by Facebook. It has a Node
query which allows you to have a universal endpoint for querying all your endpoints in your GraphQL. Let’s check how we do that, we will use Nexus
, you can use the other GraphQL, but I found Nexus
made me really productive.
You can use toGlobalID()
and fromGlobalID
from graphql-relay
package. Then you can stop reading here. But I will use an easier way, which you can adopt for your green field project.
How to use Relay style pagination in TypeGraphql
I am quite into Relay these days, for its opinionated, typesafe and performant approach. Especially for the effortless pagination.
For the backend, I use TypeGraphql, so easy to pick up if you already familiar with Typscript, typesafe, explicit, code-first, and very fast even it uses a js class
approach. Today, I will show you how to define the Relay connection in TypeGraphql
. I am using v1.0.0
here.
It’s not about actual implementation, since it is related to your data access layer. This blog is purely focused on defining the TypeGraphql
class and how to use them.
Let’s cut to chase.