Lecture for CRIA-WT about JavaScript on the server. Explains why we prefer Node.js over PHP and shows the architecture, modules and a small demo application on https://github.com/rodmidde/cria-wt-demo/tree/master/NODE/SimpleMVC.
2. Logical Architecture RIA
Representation of data, Subset of data
interact with user needed for the view
Handles events
and calls services
Interface to the
back-end
Classes, Business or
Application Logic
Something QL-
like
Raw data,
relational or not
8. Modern Setup
HTML5 JSON
browser
JavaScript/jQuery
websockets
http
JavaScript
Mongoose JSON server
MongoDB
9. Advantages Modern Setup
Only one development language: JavaScript
Not only HTTP, WebSockets to the rescue
10. Disadvantages Modern Setup
OO in JavaScript is doable but PHP syntax
resembles Java/C# more
Node hosting is harder to get than PHP hosting
Node’s learning curve is more sheer compared
to PHP
12. Node.js in one slide
Built On Chrome's JavaScript V8 Engine
Node.js is a general-purpose JavaScript runtime
with a host of powerful libraries -- one of which
happens to provide an HTTP/HTTPS server
implementation
Node.js Is Object-Oriented
Evented (Async) I/O
Package Management with npm
21. Node: Write your own module
Use one or more other modules,
external or your own
var Player = require('../model/Player.js');
Simple
constructor
function EntityManager() {
this.saveNewPlayer = function(name, club,
playerNumber, saveReadyFunction) {
// do something cool here
}
} Let other modules know what
we can do for them
module.exports = EntityManager;
23. Mongo in one slide
Stores data as bson (binary JSON)
Console uses JavaScript and json
3rd party GUI tools
Database runs as an exe or Windows service
Memory mapped so really needs 64bit OS
User group on Google Groups [busy]
Sharding for fast access and huge storage
files.meetup.com/2313351/Mongo.pptx
26. Mongoose in one slide
“Mongoose is the 10gen-supported ODM for
Node.js. It has a thriving open source community
and includes advanced schema-based features
such as async validation, casting, object life-
cycle management, pseudo-joins, and rich query
builder support.”