Idempotency in Your API

Introduction Idempotency is a crucial property in the world of APIs, ensuring that operations can be applied multiple times without changing the result. In this post, we’ll explore six effective strategies to achieve idempotency in your API, drawing inspiration from real-world examples and distributed systems principles. Idempotency Explained The light switch analogy is often used to explain idempotence. Consider a light switch in a room. The operation of turning the light switch on or off is idempotent. If the light is initially off and you flip the switch to turn it on, flipping it again won’t turn the light off again—it stays on. ...

November 11, 2023 · 4 min · Denis Nutiu

Tracing Node.js APIs with OpenTelemetry

Hello everyone 👋, In this article, we’ll instrument a simple Node.js API with OpenTelemetry traces. OpenTelemetry is the new standard for distributed tracing and metrics. Trace data is used to monitor and troubleshoot complex distributed systems. At the end of this article, we’ll have a Node.js API that is instrumented with OpenTelemetry and we’ll be able to see the traces in Grafana Tempo: The API Let’s start by setting up our NodeJS project by installing the dependencies: ...

August 7, 2023 · 9 min · Denis Nutiu

From Wordpress To Hugo

Introduction Hello everyone 👋, This is a quick post on how I migrated my blog from WordPress to Hugo. I will not go into details on how to install Hugo or how to use it, but I will share some of the things I learned along the way. I’ve also written a simple tool in Python to aid you in the migration process. You can find it here: https://dnutiu.github.io/jekyll-to-hugo/ Why not WordPress? I’ve been using WordPress for about 5 years now, and I’ve switched from free hosted WordPress to self-hosted and then to premium hosted WordPress. ...

June 5, 2023 · 3 min · Denis Nutiu

FastAPI Uvicorn logging in Production

Hello 🙋‍♂️, Running a ⏩FastAPI ⏩ application in production is very easy and fast, but along the way some Uvicorn logs are lost. In this article I will discuss how to write a custom UvicornWorker and to centralize your logging configuration into a single file. To keep things as simple as possible I’ve put all my code in a single Python file. main.py 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import uvicorn as uvicorn from fastapi import FastAPI, APIRouter router = APIRouter(prefix="") def create_app(): fast_app = FastAPI() fast_app.include_router(router) return fast_app @router.get("/") def read_root(): return {"Hello": "World"} if __name__ == '__main__': app = create_app() uvicorn.run(app=app) Running the code will return a {"Hello": "World"} json when you visit the root endpoint / at http://127.0.0.1:8000. 😁 ...

May 18, 2021 · 3 min · Denis Nuțiu

Kafka Connect GitHub source connector

Hello! In this article we will discuss how to quickly get started with Kafka and Kafka Connect to grab all the commits from a Github repository. This is a practical tutorial which saves you some time browsing the Kafka’s documentation. Environment Kafka is bit difficult to setup, you will need Kafka, Zookeper and Kafka Connect at least. To simplify the setup we’re going to use Docker and docker-compose. Once you have Docker and docker-compose installed on your system, you can run a single command and get a Kafka environment for developing. ...

July 29, 2020 · 5 min · Denis Nuțiu

Firebase REST Authentication

Hello, In this article I will show you how to authenticate to Firebase and secure the databases with some simple security rules. I’m using this setup for my NucuCar project. Authentication The first step is to enable the Email/Password sign in method, by going to the Authentication and clicking the Sign-In Method tab: Next, we can add a manual user by clicking Users tab and Add user. Now, to login with our newly created user, we make a POST request with a json body to the following endpoint: ...

March 14, 2020 · 2 min · Denis Nuțiu

Simple Dark Theme Switch with Vue.JS

Hello, In this post I’m going to show you how quickly you can add a dark theme switch to your Vue.JS application. We’re going to start with a blank application. And then we’re going to create a dark-theme CSS file which we’re going to save in public/css/darktheme.css. This is how the application looks without any CSS. Now, we’re going to put the following code in darktheme.css: 1 2 3 4 5 6 7 body { background-color: #2c3e50; } h1,h2,h3,h4,h5,h6,p { color: #42b983; } We can test our theme by appending the following line in the of public/index.html ...

December 7, 2019 · 2 min · Denis Nuțiu

Adding PostgreSQL support to your ASP.Net Core application via Docker

I’ve been playing recently with ASP.Net Core and I’m developing a small Web API project in order to teach myself the framework. In still article I’ll explain how to use a Postgres database with Docker, in order to make your development experience much more enjoyable. Before moving on, please make sure that you’ve installed: Docker Docker-Compose First, create the docker-compose.yml file in your root directory of the project, the file should contain: ...

May 11, 2019 · 2 min · Denis Nuțiu

My Spring Boot notes

Lately I’ve been busy with university, work and learning something new. I’ve started my programming journey when I was in high school with Python, I didn’t have any informatics classes so I had to study on my own. I confess that I didn’t really understood how Python works, until I’ve tried Java. Python had a dynamic type system and it was very confusing for a newbie like me. After finishing Introduction to Computing with Java course from HKUST on edX I started to get a better grasp on programming. After that I’ve started reading some java books like: Effective Java, Head First Java and some chapters from Intro to Java Programming, Comprehensive Version, which I consider to be the most complete and useful Java book ever made (if you do the exercises). Then I’ve abandoned Java because all I knew to do with it was console programs, I had no ideas about framework and all the possibilities, when I saw someone at Google giving a talk and demonstrating a browser game that ran Java in the backend I was like: “What is this magic?!”, back then I had no knowledge about networking and client-server architecture. ...

October 7, 2018 · 2 min · Denis Nuțiu

Static websites with Angular, lazy mode.

I had to do a project for a friend and because Hugo is a nice tool yet a bit uncomfortable to use, I decided to use Angular. After finishing the website’s routes, css and images I have the project to my friend and he had a bit of a trouble deploying it on his Apache server. His host wouldn’t allow .htaccess. Q.Q The solution? Rename index.html to contact.html, team.html, project.html, objectives.html and voila! A temporary solution until the htaccess problem is solved. ...

September 11, 2018 · 1 min · Denis Nuțiu