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

Advertisements
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
ExpressJS, MEAN

ExpressJS – Configure Routing for Express App

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

Express is the most popular Web Framework on Node . So, I planned to write on Express and personally I am a MEAN (Mongo, Express , Angular , Node) Stack fan and MEAN stack became much powerful in Modern Web World.

This article shows how we can configure the routing for an Express app.

var express = require('express');
var app = express();
 
app.get('/'function (req, res) {
	res.send("Home");
});
 
app.get('/profile'function (req, res) {
	res.send("Profile");
});
 
app.get('/contact'function (req, res) {
	res.send("Contact");
});
 
app.get('*'function (req, res) {
	res.send("Not Found" , 404);
});
 
var server = app.listen(3001, function() {
	var host = server.address().address;
	var port = server.address().port;
	console.log('Express app listening at http://%s:%s', host, port);
});

The code is itself self explanatory . I have created 3 Routes and if User hits any other route beside these , Express will return “Not Found” with 404 Status which has been maintained by *

Here we can see server is listening to 3001 port , make sure to use that port which is empty

app takes 2 arguments , first is the route path and second is the callback which would be fired when that Route has been hit by User.

Hope this helps.

Cheers

Standard