How to develop Microservices

Building microservices

Required Environment

Node.js

  • Step A

    • Node.js source URL https://nodejs.org/en/

    • Download and install under 'C:\Program Files\nodejs' folder

    • Test the installation

      • Open <Cmd> shell and test if the installation was successful node -v //shows version of nodejs

  • Step B

    • Open <Cmd> shell and change directory to the Node.js folder cd C:\Program Files\nodejs

    • Create a 'project' folder under 'C:\Program Files\nodejs '

    mkdir C:\Program Files\nodejs\project

    • Change directory to 'C:\ Program Files\nodejs\project' cd C:\Program Files\nodejs\project

    • Initialize Nodejs' Node Package Manager (NPM) npm init //initialize the node package manager

    ...continuing to press 'enter' until finished with all the arguments that the installation throws up

    • Install MoteBus using NPM npm install motebus --save //install MoteBus

    • Add Express package which provides for a webserver socket running on the user-defined port npm install express --save //install Express

  • Step C

    • Install MoteBus SDK

      • MoteBusHelloWorld download link

        http://www.ypcloud.com/download/motebushelloworld.zip

      • Unzip to extract the HelloWorld folder & files and copy the same to 'C: \Program Files\

        nodejs\project'

      • Run C:\Program Files\nodejs\project\HelloWorld\bin\MoteBus_win32.exe as an Administrator, ensuring before that TCP port '6788' is open in the system's firewall

    • Run HelloWorld.js

      cd C:\nodejs\project\HelloWorld node index.js //run Helloworld

  • Step D

    • Localhost test (running it in the local machine)

      • Run MoteTest.js

        cd C:\nodejs\project\HelloWorld\test node MoteTest.js

    • Client Server test

      • Use a code editor to open MoteTest.js and modify the third statement in the js file to replace '127.0.0.1' with '192.168.10.185'

P.S.: MoteTest.js is a test program used for testing the Motebus connector, returns the test results for Add(), Echo() & Time() Mote functions