Posts

Build your own REST API from scratch - Part 2

Image
In the previous article we have created a basic skeleton for our RESTful API.  In this part we are going to crack it up a notch by building an actual useful endpoint, status codes, change the static message to a better mechanism, build our controllers, and see how we can retrieve actual useful data via an API call. Ready? Let's keep coding.
For starters, let's change focus by deciding that we are building an Ice Cream shop API.  WOW, just the thought of that made me hungry...
Oh well, back to work. so the first thing we want to do is to change the static hello message we retrieved to some actual content. For that, we are going to: Create a JSON data file

Our JSON file will contain an array of objects containing our menu items. We will place this file in a sub-directory in our project which we will call menu_data.


Next up, let's create a separate module to handle our Ice cream menu get method. I will call it iceCream.js and place in an additional directory in our project which I w…

Build and publish your own Image with Docker and Artifactory

Image
The true power of docker, having the ability to pack and ship your application, so others could run unlimited amount of containers based on our Image that contains our application code. In this post we are going to build our own docker image from scratch, and publish it to a remote repository.
Define the flowA standard flow of packaging and shipping our app would look something like this:
1. Create a Dockerfile which will contain our set of layers and "instructions" for designing our image.
2. Build the image which will serve as a "Master template" for our application containers.
3. Publish our build to a repository so others could pull and run containers from our Image.  (In our example we are going to uje JFrog Artifactory.)

Let's get to work...1. Create a Dockerfile.A Dokcerfile is basically a text file that contains a set of commands which will assemble our Image. (An Image is much like a base template).
For this example, we will build a simple "Hello world&qu…

Data Structure Interview question - Write an algorithm to check for balanced parentheses in a String

Image
A while back I had a difficult interview. It was during COVID-19, so granted it was via a Zoom call which I had to take from a remote room that had no air conditioning. It was my first software engineering related interview,  so I got so nervous, sweating and shocked, that I didn't manage to answer the question like I hoped to. Anyone who knows me personally, knows that I never had any official programming training, and everything I know I picked up on the job, studied by myself or just spent hours cracking in front of various resources found online. Learning is a huge passion for me, It makes me feel "Armed", and it is my biggest motivation. But excuses aside, I did't do well, and it bothered me, so I decided to spend the next weekend understanding the task deeper. 
In this post, we are going to cover a common data structure algorithm question.
"Write an algorithm that checks for balanced parentheses in a given String".
How do we "Attack" this questio…

Build your own REST API from scratch - Part 1

Image
RESTful API is a key program interface that allows connectivity for endless amount of applications.  I have actually published an article with a brief introduction to REST API which you can find in this blog post
In this article we are going to kick it up a notch and go step by step in building our own REST API from scratch. 
Choose your weapon...
For this task we are going to need the following: nodeJSnpmexpressVisual Studio Code 
Create our project
First of all, I'm going to create my project folder, and open it in vs code.

Next, I will open a new terminal in VS Code and execute $npm init.




For this simple example we can leave everything at default and just hit Enter/return to finish our setup.
Next, I am going to install my dependencies by running $npm install.

Once the setup is finished, I am going to see my project folder populated with package.json, package-lock.json files, and the node_modules folder. which will contain my dependencies. 

Let's start writing our code...
I'm goin…

Executing a Maven job using Jenkins declarative pipeline

Image
In this article we will discuss Jenkins declarative pipeline, and see how we can build our own basic maven execution.
Breaking down the pipes: I always use the following drawing to explain the general concept of a pipeline.

Close your eyes and imagine a pipe construction that represents your companies release/deployment flow.  There is an entrance and exit point, and the entire pipe construction consists of different parts/stages that make the pipe hold and contain the flow. If one of the stages will break, the flow will stop and leak out of that specific part, until it is fixed. Now, open your eyes. That my friends, is a standard delivery pipeline. 

In Jenkins, we have the possibility to build that pipe construction using something that is called the Jenkins Pipeline. At first, it was a script that described the different stages of the build, and later on it has evolved and grew in popularity and feature count. The Declarative pipeline syntax is a relatively new addition in Jenkins. It was …

Containerization Recipe - Create a simple http server with nodeJS and docker

Image
It's been a while since I published my articles about docker, where I talked about the reason for the hype surrounding it, the influence it had on the way we perceive virtualisation and deploy software. I think it's time to move ahead and talk about application containerization.
What are containerized applications?
Application Containerization is a virtualisation method most commonly used to run and deploy distributed software without the need for a full virtual machine and ecosystem. In this article, we are going to touch and feel  virtualisation by creating a basic, very simple http server that is going to run inside a docker container. 
First things first, you can't containerize what doesn't exist. So, without further ado, let's start writing out app. 
My weapon of choice for this task is Javascript that provides a fairly good and intuitive (nodeJS) module for implementing http servers from scratch. I could actually use express, but to keep things simple, let's s…