node.js microservice

introduction-to-nodejs-and-isomorphic-javascript-9-638

Node.js is the most convenient framework to create a microservice. There are multiple ways to create a node.js microservice two of which are the most popular:

  • Express

clone https://github.com/bhajian/express-togo

Express is …

In order to create an express application you would need to add the following dependency in the package.json:

{
	"name": "JS Playground Hello World",
	"version": "0.0.1",
  	"dependencies": {
		"express": "~2.5.9"
	}
}

 

Then in you app.js you can add the following code:

 

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});

 

  • Loopback

Loopback uses express by wrapping them up in an end to end mvc framework.

npm install -g apiconnect

Then

apic loopback

     _-----_
    |       |    .--------------------------.
    |--(o)--|    |  Let's create a LoopBack |
   `---------´   |       application!       |
    ( _´U`_ )    '--------------------------'
    /___A___
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

[?] What's the name of your application? apic-getting-started
[?] Enter name of the directory to contain the project: apic-getting-started


[?] What kind of application do you have in mind?
empty-server (An empty LoopBack API, without any configured models or datasources)
❯ hello-world

Finally:

cd apic-getting-started
$ apic edit

Express server listening on http://127.0.0.1:9000

 

  • You really make it seem really easy along with your presentation but I find this topic to be really something that I feel I’d by no means understand. It seems too complicated and extremely vast for me. I am looking ahead to your next put up, I’ll try to get the cling of it!|

  • In the event that opportunity is essential to your achieving success, thus difficult to get as well as identify, we have to totally focus really each of our energy on it. So that you can naturally accomplished at it all, acquiring and capitalizing on ability has to be any deliberate emphasis:

  • James Green

    Nice article