LoopBack 3 – Simple API with MongoDB Example

Expose your MongoDB NoSQL as a REST service with LoopBack 3 (Node.js Open API Framework)

This post is continuation of previous post https://kenanhancer.com/2019/09/13/loopback-3-simple-api-with-mysql-example/

So if you want to start from beginning, read that one as well.

Follow this link https://kenanhancer.com/2019/09/13/mongodb-docker-container-exercise/ to create a MySQL container 🙂

You can find LoopBack 3 project in the following repository. After clonning switch to mongodb branch 🙂 or run the following command.

git checkout mongodb

https://github.com/kenanhancer/loopback3-simple-api.git

LoopBack 3 – Simple API with MySQL Example

Expose your MySQL Database as a REST service with LoopBack 3 (Node.js Open API Framework)

This post is continuation of previous post https://kenanhancer.com/2019/09/09/loopback-3-simple-api-example/

So if you want to start from beginning, read that one as well.

Follow this link https://kenanhancer.com/2019/09/12/mysql-docker-container-exercise/ to create a MySQL container 🙂

LoopBack MySQL example will not start wihout running the following code in MySQL Database container. So, run the following command in it.

ALTER USER root IDENTIFIED WITH mysql_native_password BY 'password';

You can find LoopBack 3 project in the following repository. After clonning switch to mysql branch 🙂 or run the following command.

git checkout mysql

https://github.com/kenanhancer/loopback3-simple-api.git

MySQL Docker Container Exercise

You can up and run MySQL Docker container in your local machine and later connect from mysql CLI to query your database.

Run the following command in your terminal to up and run a MySQL Database Docker container.

docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

Follow the following link for more details

https://hub.docker.com/_/mysql

There are more practice in this video 🙂

LoopBack 3 – Simple API Example

I am developing APIs with Node.js and LoopBack during last one year. So, it is time to create a post about it. 🙂 I try to build a detailed project. I hope that this post will be a good reference for developers.

Install LoopBack CLI Tools

There are two LoopBack CLI Tools.

You can also use the legacy StrongLoop CLI tool slc

Install LoopBack CLI Tool

$ npm install -g loopback-cli

This installs the lb command-line tool for scaffolding and modifying LoopBack applications.

Install IBM API Connect v5 developer toolkit

$ npm install -g apiconnect

IBM API Connect v5 developer toolkit includes:

  • The graphical API Designer tool that you can use to create and modify LoopBack applications.
  • The apic command-line tool for scaffolding and modifying LoopBack applications.

Create a Simple API

If using loopback-cli

$ lb

If using apic

$ apic loopback

If using slc

$ slc loopback

I have used LoopBack CLI in the following video

Run the application and API Explorer

Run the following command in Terminal to start loopback application.

$ npm start

Open your browser to http://localhost:3000/explorer

LoopBack API with InMemory Datasource Example

You can find LoopBack 3 project in the following repository.

https://github.com/kenanhancer/loopback3-simple-api.git

Kubernetes multi node cluster with One Updated Vagrant File

Actually there is already a Kubernetes multi node cluster post (https://kenanhancer.com/2018/09/26/kubernetes-multi-node-cluster-with-vagrant/) in this blog. But, this one is different. That post was showing 3 empty virtual server up and run later install tools step by step so it was taking too much time. If you run this Vagrantfile, it will create one master node and 2 worker nodes in Virtualbox. This Vagrantfile is also more configurable. If you need more servers, just append new item in “servers” array in Vagrantfile.

This is the expected result 🙂 As I mentioned at the beginning of the post, one master node and two worker nodes are created in Virtualbox.

IBM Cloud – API Connect – Developer Portal Usage

I have already mentioned many details about IBM API Connect service in this post https://kenanhancer.com/2019/06/30/ibm-cloud-api-connect/ But, I tried to emphasize some details more clearly. There is a sequential structure in IBM API Connect. That is Cloud Foundry Organisations => Spaces => Catalogs => Products => APIs. In this case, if we want to find any API, we need to know Cloud Foundry Org, Space, Catalog, Product respectively so that we can find our API.

Cloud Foundry Orgs

Cloud Foundry Orgs can be find under Account and Cloud Foundry orgs menu as shown below screenshot. In my case, I have 4 Cloud Foundry Orgs. As I said preceding, there is spaces under Organisations. So, there is 1 space in APIGateway-dev organisation and 2 spaces in kenanhancer@hotmail.com organisation. APIGateway-dev2 and APIGateway-dev3 don’t have any spaces.

So, let’s see APIGateway-dev org details in the following screenshot.

This screenshot shows APIGateway-dev Users. There is also Space Users.
There is only one user in red space. This means that we nee give access any user organisation level first and later space level. Let say we have dev, test, preprod and prod spaces. We can give access to developers only for dev and test not for preprod and prod so that APIs can be deployed by deployment team.
Continue reading

IBM Cloud – API Connect

Actually, I struggled very very much to understand how API Connect service works. Because, I couldn’t find a good documentation in IBM official site. So, I hope that someone who needs to understand may benefit from this article. I think that writing too much about API Connect UI is not very helpful. That is to say, Pictures sometimes may say many things clearly. So, you will see many screenshots with simple descriptions. 😉

First view of IBM Cloud UI

Continue reading

Kubernetes single node cluster with Minikube and Vagrant

The following Vagrantfile code(syntax is Ruby) is creating single node Kubernetes cluster with Minikube.

Copy above code and follow the following screenshots. Run the following commands in Terminal.

mkdir MinikubeVagrant

cd MinikubeVagrant

nano Vagrantfile

Paste the Vagrantfile content like below.

save Vagrantfile and run the following command to start virtual machine.

vagrant up

Creating Kubernetes Dashboard Proxy

After Vagrant is up, it means that Minikube is ready to use. So, connect with SSH to Vagrant machine and run the following code to start Kubernetes Dashboard Proxy.

kubectl proxy --address 0.0.0.0 --port=8001 --accept-hosts '.*'

Connecting to Kubernetes Dashboard from Host machine

Click one of the following link to connect the Dashboard. Ta taaa 🙂

http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login

or

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login

Rest of the details are already mentioned in this blog link Kubernetes multi node cluster with Vagrant (included Kubernetes Dashboards, Grafana, Prometheus)

read the Kubernetes Dashboard Access Control paragraph.