MEAN, NodeJS, System

Node app Deployment and development process Manager

For development , its better to use nodemon

To install

npm install -g nodemon

To run

nodemon server.js

 

For Production , For most cases we can use forever

To Install

[sudo] npm install forever -g

To run

forever start app.js

forever start -a server.js

forever stop server.js

forever list

To see continuous Logs in terminal

forever logs server.js -f

Advertisements
Standard
NodeJS

Upgrade your Server to NodeJS LTS Version from old versions

If you have NodeJS already installed , then first remove the current installation.

sudo apt-get remove --purge nodejs npm

Now lets install NodeJS LTS 4.4.0 Argon –
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

You might need to link to node
sudo ln /usr/bin/nodejs /usr/bin/node

Verify
node -v
node -pe process.release.lts

Standard
C#, Cross Domain, HTML5, JavaScript, NodeJS

Visual Studio Code – A Cross Platform Code Editor built with Chromium

Microsoft has launched VSCode few weeks back for Cross Platform (Linux/Mac,Windows) and 55% download was Non-Windows. Shocking , right ?

HackerNews had a post on this and had really lot of comments/traffic on it.

Lets see the first look of Code.

Code First Look

Code First Look

Its lightweight and simple and has GIT embedded with this.

But I am not here to say that Code has been released by Microsoft. I am here to shock you little bit.

When you are on Code, Just press F12.

And lets see the below image.

Code First Look Shocked

Code First Look Shocked

#%$#@ ???? Is it Chrome Dev Tools ?

YES !!! It is!

In fact VSCode has been built with Web Technologies like HTML,CSS , JavaScript with Chromium and NodeJS . Here , Chromium is the Engine for Chrome browser by Google.

Lets get a little idea about CEF (Chromium Embedded Framework)

Tech

And they used Electron for Cross Platform . Electron helps to Build cross platform desktop apps with web technologies Formerly known as Atom Shell. Made with Love by GitHub.

Initially developed For GitHub’s Atom editor , Electron has since been used to create applications by companies like Microsoft, Facebook, Slack, and Docker.

Slack‘s new Desktop app was also built with this.

In VSCode , what we do Like adding/editing Projects/Folders/Files , all is saved in HTML5’s Client Side DBs like IndexedDB and LocalStorage. To know more about HTML5 Database , you can see my other posts on HTML5 Database here
https://shahjadatalukdar.wordpress.com/2013/09/27/using-html5-localstorage-with-angularjs/

https://shahjadatalukdar.wordpress.com/2014/01/18/websql-welcome-to-client-side-db-part1/

Lets see the below image.

HTML5 Database

HTML5 Database

Okay , lets see Where the World goes to!

Cheers!

//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js

(adsbygoogle = window.adsbygoogle || []).push({});

Standard
AngularJS, ExpressJS, MEAN, MongoDB, NodeJS

MEAN.io – Installing in Windows 8.1 (MEAN Stack)

MEAN.io is becoming a Popular Modern Framework for MEAN Stack(Mongo , Express , Angular , Node). I have recently tried it out and had real fun with it , such an awesome Boilerplate for MEAN Stack.

banner-top-ninja

Most of the Developers around the world work on MAC/LINUX when they are with MEAN. But I thought why not to write a Full Process for Windows Users . Cool , lets do the whole thing to get running an MEAN.io app in Win8.1.

First , We need to install the Core Node And Mongo.

1.Lets install Node first.Go to Node Download Center and Download Windows Installer (.msi) based on your OS Architecture and just Install with few Clicks.

2.Lets Install MongoDB , to see How to Install Click Here

3.Some of Mean.io dependencies uses node-gyp with supported Python version 2.7.3.

3.1.Install Python From here

Python

Python

3.2. Install Microsoft Visual Studio C++ 2012/13 for Windows Desktop (Express version works well)

3.3.Install node-gyp

npm install -g node-gyp

4. Install Gulp and Bower

npm install -g gulp

npm install -g bower

5.Install the MEAN.io CLI

npm install -g mean-cli

6.Now create your own app

mean init myApp

cd myApp
npm install

7.To start you application run –

gulp

Alternatively, when not using gulp (and for production environments)

node server.js

And browse http://localhost:3000

You can see your Site , All done by the amazing Mean.io

Mean

Mean

Standard
ExpressJS, MEAN, NodeJS

Node : Express app with Swig

Today , I will write about a Template Engine for Express App.

And This is Swig – A simple, powerful, and extendable JavaScript Template Engine.

Its Data Binding Syntax is like Angular, And I liked it, its really simple and fun.

This is how we can configure Swig in our Express App-

var cons = require('consolidate');
 
var app = express();
app.engine('html', cons.swig);
app.set('view engine''html');
app.set('views', __dirname + "/views");
 
app.get('/'function (req, res) {
    res.render('index', { name: 'Shahjada' });
});
 
var server = app.listen(8080, function () {
    var host = server.address().address;
    var port = server.address().port;
    console.log('Example app listening at http://%s:%s', host, port);
});

And our html is like below as simple –

<h1>Hello {{name}}</h1>

 
Its easy , right ?

Cheeers

Standard
MEAN, NodeJS

NodeJS : Connect MongoDB and get Data from Collection

In any Web application , its important to connect to Database for data .

In MEAN , as we use MongoDB , so I will write code how a Node app can talk with MongoDB Database.

I have a Database named newDB and I have a collection named myColl in my local MongoDB server.

Like below , we can connect and get data from Mongo Server.

var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost:27017/newDB'function(err , db) {
 
	if(err) {
		console.log(err);
		throw err;
	}
	
	db.collection('myColl').findOne({} , function(err , doc){
	
		if(err) {
			console.log(err);
			throw err;
		}
		console.dir(doc);
		db.close();
		//res.send(doc);
	});
 
	console.dir("Called FindOne");
});

Hope this Helps.

Standard