tl;dr — what is it anyway and will it help you with next project?
Let’s jump straight into the problem. We have users api with permisions handling. Nothing extraordinary. A bug occurs. You look into database it turns out that user has no permisions of any kind assigned at all. How could it have happened? The api doesn’t allow it. All we have is database state as it is, we have no idea what caused this state o application.
It’s even worse, there is no way to retract database to the moment when it happened without making backups every second…
tl;dr - when should I use CQRS design pattern and stay sane.
When building an API the typical practice is to divide it into parts, simplest would be presentation, service / business logic and data access layers
There is nothing wrong with this approach but questions araise when application becomes bloated and unreadable.I prepared simple user’s microservice with basic functionality to make case-study on it. But first things first.
Must be mentioned before. It stands for Command-query Separation. The simplest explanation would be:
In the previous part I’ve explained how to create api for real-time application. No it’s time for front-end. It was created with Vue cli version 4.1.1.
Similarly to api let’s look on router which binds together all business logic.
Here I’ve created two main components: Outer and Dash. The first one is responsible for non-logged-in part of application. Examples of this are help page or login form. From code perspective it sets language in localization module based on the browser language. Let’s look into it for a moment.
As you can see I’m using I18n plugin…
A couple months ago me and my team faced a challenge of designing a real-time application with REST support for external microservices. The problem was the necessity to choose or develop design pattern for modular and scalable api based mainly on client and server side events implemented by web sockets following model view presenter design pattern. In this article I’m going to present results of this considerations as well as example application, service for online notes, built upon mentioned principles available at https://github.com/Matii96/students-notes.
Application is built with Node.js 12.14.0 LTS using TypeScript and split into following categories:
Full-stack developer with passion towards data science