A M.E.A.N Seminar

Shamar Kellman

Computer Science Society

http://shamarkellman.github.io/css-mean-presentation

Who Am I

Shamar Kellman

photo

Post-Graduate Student UWI

All-round developer

Research in Intelligent Virtual Agents (IVAs)

What is MEAN

  • MongoDB
  • Expres JS
  • Angular JS
  • Node JS

A single language across your entire stack increases productivity.

When To Be MEAN

  • Chat client
  • Real-time user updates (like Twitter feed)
  • RSS feed
  • Online shop
  • Polling app

When not to be MEAN

CPU intensive task

Who is being MEAN

  • Walmart - http://www.walmart.com
  • Yahoo - http://www.yahoo.com
  • Linkedin - https://www.linkedin.com
  • Paypal - https://www.paypal.com

For more see - http://nodejs.org/industry/

Node JS

  • The server-side platform in your MEAN application
  • Built on Google Chrome’s V8 JavaScript runtime
  • Single Threaded
  • Asynchronous
  • Event Driven

NPM Package Mananger


var http = require('http');

var server = http.createServer(function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end("Hello World\n");
});

server.listen(8000);

console.log("Server running at http://127.0.0.1:8000/");
						

Express JS

Express is a lightweight platform for building web apps using NodeJS.

a minimal and flexible node.js web application framework


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

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

var server = app.listen(3000, function () {
  var host = server.address().address;
  var port = server.address().port;

  console.log('Example app listening at http://%s:%s', host, port);
});
						

MongoDB

  • Open-source NoSQL database
  • Stores documents in JSON-style format
  • Schemaless
  • Document-oriented database
  • So multiple data-types
MySQL MongoDB
Table Collection
Row Document
Column Field
Joins Embedded documents, linking

{
    id: "1234",
    name: "holly",
    age: "400",
    type: "high-elf",
    address: {
        city: "rivendell",
        state: "middle-earth"
    }
}
                       

db.users.insert({ 
	user_id: "bcd001", 
	age: 45, 
	status: "A"
})
                       

db.users.find()
                       

db.users.update(
	{ age: { $gt: 25 } },
	{ $set: { status: "C" } },
	{ multi: true }
)
                       

Angular JS

  • Front-end framework (MVC)
  • Extends HTML
  • Two-way Data Binding
  • Dependency Injection
  • Directives & Templates
  • Scopes

JavaScript Primer

Variables and Data types


var myVar = 0;
                        

var myInt = 0;
var myFloat = 2.5;
var myBoolean = true;
var myString = "This is a string";
var myArray = [1,2,3];
var myJSONObject = {
    myField : "Some value"
};
// Object instantiation using new
var myDate = new Date();client
                        

Operators


var x = 4;
x = x + 1; // x is 5
y = x % 2; // y is 1
x++; // x is 6
x--; // x is 5
x += 3; // x is 8
var aString = "The value of x is " + x;
                        

Conditions


if (x > 0) {
    // do something
} else {
    // do something else
}
                        

var myString = "I have " + (x == 1 ? x + "thing" : x + "things");
                        

Loops


for (var i = 0; i < myArray.length; i++) {
    console.log(myArray[i]);
}

while (x < 10) {
    console.log(x++);
}
                        

Functions


function myIncrementFunction (x) {
    return x + 1;
}
                        

myIncrementFunction(1000);
                        

Require (Node.js)


var myLib = require("some-other-lib");
                        

Before We Build

https://github.com/ShamarKellman/css-mean-contact-app

Installed Requirements

What we are using

  • express
  • Mongoose
  • Nodemon
  • Angular
  • UI-Router
  • Ng-Resource
  • Angular Material

Scaffolding the App


├── client
│   ├── css
│   ├── js
│   │   ├── controllers
│   │   └── services
│   ├── libs
│   └── views
├── config
├── node_modules
└── server
    └── models

				        

Package.json


npm init
				        

Let's Have Some Lunch

The Backend

The Frontend

Thank You

Sponsors: BrydenStokes

Special Thanks

Ariel

Kelsie