Latest Posts

QAVideos (3) – Extend Model and Using Swagger.io in Node.js

This is part 3 in a series to build a sample application called QAVideos using StrongLoop (now API Connect).

  • In part 1 ‘QAVideos (Part 1), Adding User Management to Node.js’, I added User Management to a Node.js app using StrongLoop.
  • In part 2 ‘QAVideos (Part 2), Add Custom Model and ORM in Node.js‘, I added a custom data model, i.e. a Video model, and used ORM to persist the model to a PostGres database.
  • In part 3 ‘QAVideos (Part 3), Extend Model and Using Swagger.io in Node.js‘, I extend the built-in User model with Member, add a Question and Answer based on a Video model, and add a Sticker, while using Open API Specification or Swagger.io to define and manage the application from a Swagger specification file.
  • In next parts, I will add Object Storage for video support, create an Ionic/Apache Cordova based mobile client, add an automated build, deployment and test script, add a Content Delivery Network (CDN) to the backend, containerize the application, add chat, and more.

Prerequisites

  • Node, npm, StrongLoop and API Connect must be installed,
  • Check if the ‘slc’ tool is installed, by running ‘slc’ from the commandline. If not, follow the installation instructions, here.
  • Check if the ‘apic’ tool is installed, by running ‘apic’ from the commandline. If not, from the commandline run ‘npm install -g apiconnect’.
  • Get the source code from part 2 of this tutorial and follow the installation instructions.
  • Test if QAVideos (part 2) is running correctly by typing ‘node .’ in the root directory and browsing to ‘http://localhost:3000/explorer’ in your browser.

Open API Initiative (based on Swagger)

The OAI is based on the Swagger API specification, which is a description format for defining Restful APIs. The current Swagger API specification can be found on GitHub: https://github.com/OAI/OpenAPI-Specification.
(more…)

Running your own Blockchain

Requirements

Hyperledger and Fabric

The fabric is a ledger of digital events, called transactions. A transaction is a request to the blockchain to execute a function on the ledger. The function is implemented by a chaincode. Chaincode is application code (aka a smart contract) stored on the ledger as part of the transaction. Chaincode runs transactions that can modify state. In a permissioned blockchain, entities register to acquire identity credentials.

Create Blockchain Service

This tutorial is a re-cap of this tutorial: learn chaincode.
First create an application on Bluemix:

  • Login to Bluemix and go to the Bluemix catalog, browse to ‘Runtimes’ and click the ‘Node.js Runtime’. Populate the application configuration fields, name the application ‘<username>-blockchain1’, and click the ‘CREATE’ button.
  • Go to the application ‘OVERVIEW’ page, and click the ‘ADD A SERVICE OR API’ link, in the catalog, browse to the ‘Network’ category or in the left menu under Services select the ‘Network’ filter, and click the ‘Blockchain’ service, accept the default settings and click ‘CREATE’, accept the ‘Restage’ popup window.
  • In the left menu of the application detail page, under ‘SERVICES’, click the new ‘Blockchain’ service, and on the service page, click the ‘LAUNCH’ button,
  • You should not see the Monitor page of the Blockchain cloud service. The web address or URL should look something like this ‘https://obc-service-broker-prod.mybluemix.net/v2/monitor’, make sure you are on ‘v2’ or version two. The Blockchain service has its own pre-configured Blockchain network, including one Certificate Authority, and two validating peers, each has a ‘Discovery’ and an ‘API’ endpoint.
  • Click the ‘APIs’ tab to see the API documentation.

(more…)

Using MQTT to publish data and send commands for IoT

MQTT is a publish-subscribe messaging pattern with a light-weight footprint, ideal for IoT devices. This tutorial will create a basic workflow via an MQTT Broker from device client to application server and back. To avoid any hardware dependencies in this tutorial I will simulate the device client and implement it as a Node.js server. The application server will also be a Node.js server.

  1. Requirements
  2. Setup an MQTT Broker
  3. Register a Device on the MQTT Broker
  4. Create an API Key on the MQTT Broker
  5. Create the IoT Device Client
  6. Create the IoT Application Server
  7. Publish Data from Client to Application via Broker
  8. Send Commands from Application to Client via Broker

Requirements

Setup an MQTT Broker

The publish-subscribe messaging pattern of MQTT requires a message broker. One easy way to create one is to create an MQTT broker from a boilerplate application ‘Internet of Things Platform Starter‘ in Bluemix.
(more…)

Uncanny Love

Through this dark night
Your heart is bright
Like a fair moonlight
My soul you guide

Into your loving bed
To suckle your breast
And clamp your chest
Into your womb my head

So you sooth
me like a boy
To be a man

Thus looted
By a woman coy
love uncanny

Faces (53)

The short stubbles of his scruffy goatee blended like a brightly colored motion of a pointillist painting into the detailed foam of ginger waves and the freckled splashes of his reddish face under an orange sky lit by a spiky haircut. His light blue eyes looked gloomy.

QAVideos (2) – Add Custom Model and ORM to Node.js

This is part 2 in a series to build a sample application called QAVideos using StrongLoop. In part 1 ‘QAVideos (Part 1), Adding User Management to Node.js with StrongLoop’, I showed how to add User Management to a Node.js app using StrongLoop. In this part 2, I will add a custom data model, i.e. a Video, Question and Answer models and extend the built-in User object.

Prerequisites

  • Node, npm and StrongLoop must be installed,
  • Check if the ‘slc’ tool is installed, by running ‘slc’ from the commandline. If not, follow the installation instructions, here.
  • Get the source code for part 1 of this tutorial and follow the installation instructions here.
  • Test if QAVideos (part 1) is running correctly by typing ‘node .’ in the root directory and browsing to ‘http://localhost:3000/explorer’ in your browser.

Create Data Model

First, let’s add a custom model ‘video’ so that users can manage a list of videos. To do this, I create a model for the video, define the relationship between Video and User (a User can have many videos), and specify the access level of users to the video object using an Access Control List (ACL).
(more…)

QAVideos (1) – Adding User Management to Node.js

One of the basic requirements for applications is to manage and authenticate users. I will use StrongLoop and Angular.js to add user management to a Node.js application called QAVideos. The QAVideos app is a Question and Answer application using videos instead of text, think of it as StackOverflow meets Youtube. I will add more functionality to the QAVideos app in following parts: adding an Object Model with an extended User object and using Swagger to generate the Object Model among other.

Steps:

  1. Create the Application
  2. Add Static Pages
  3. Add Angular
  4. Generate the Angular services script
  5. Add Signup
  6. Create an Authentication Service Provider
  7. Add Login
  8. Add Logout

Design of the Application

The initial design of the QAVideos application is very simple. A user can register, login and logout. An authenticated user can create, update and delete videos to the platform and see a list of their videos. Unauthenticated users can see all videos.

About StrongLoop

If you are not familiar with StrongLoop, it is an API platform for Node.js and includes Loopback to quicly compose APIs and graphical tools like the API Explorer to document APIs and Arc to build and manage your application. I will use Loopback to compose the model and the APIs.
(more…)

Using Open Stack Object Storage on Bluemix

If you need to store images, videos, documents or other files and objects, you should save your objects not to a data base or disk, but to an Object Storage.

Documentation:
https://www.ng.bluemix.net/docs/services/ObjectStorage/index.html

Steps:
1. Get Access Token and Public URL
2. Get Account details
3. Create Container
4. Create Object

Get Access Token and Public URL

curl -X POST -H "Content-Type: application/json" -d '{
    "auth": {
        "identity": {
            "methods": [
                "password"
            ],
            "password": {
                "user": {
                    "id": "<userId>",
                    "password": "<password>"
                }
            }
        },
        "scope": {
            "project": {
                "id": "<projectId>"
            }
        }
    }
}' 'https://identity.open.softlayer.com/v3/auth/tokens'

(more…)

How to create a MEAN+ stack application (MongoDB, Express, Angular, Node + Bootstrap, Jade)

Steps

      Create a Node.js with Express.js App
      Create a Git repository and clone to localhost
      Add Angular.js
      Add Bootstrap
      Add MongoDb
      Add Jade
      Add an API for GET /people
      Connect to MongoDb
      Create a sortable table with Angular

Create a Node.js with Express.js App

I will be using Bluemix to host, build and deploy my Node.js application and the MongoDb service. I am developing on my localhost for unit testing before I upload my application to Bluemix, but you can also use the online editor and online Git instead.

1. If you do not have a Bluemix account yet, sign up for a free account at http://ibm.biz/bluemixnyc,
2. Once you have an account, go to your Bluemix console at https://console.ng.bluemix.net/,
3. Go to your Dashboard,
4. In the ‘Cloud Foundry Apps’ box, click ‘CREATE APP’,

5. Choose ‘WEB’

(more…)

%d bloggers like this: