angularjs with node.js and mongodb

17
AngularJS Angular + Node/Express + MongoDB Brent Goldstein [email protected] Full JS Stack

Upload: brent-goldstein

Post on 31-Aug-2014

13.113 views

Category:

Technology


3 download

DESCRIPTION

how I went about picking a stack for my prototype web app

TRANSCRIPT

Page 1: AngularJS with Node.js and MongoDB

AngularJS

Angular + Node/Express + MongoDB

Brent [email protected]

Full JS Stack

Page 2: AngularJS with Node.js and MongoDB

Back Story

● Build a prototype web app○ Why? -- Learn new technologies, act like a startup

● Focused on SMB enterprise use-cases○ Lots of data to visualize, manage

● What technologies to pick?○ Client○ Server○ Database

Page 3: AngularJS with Node.js and MongoDB

Strategy for picking TechnologiesGo with what works -- for you

You’ll need to learn new stuff, it should be fun

If it seems like it does not fit, you can try something else

If you’re a perfectionist, you’re done for

You’ll know when it ‘feels right enough’ and stuff flows

Caveat -- This works for me, figure out your strategy

Page 4: AngularJS with Node.js and MongoDB

Client? Lots of choices, but only a few

- I’m a software guy, needs to be like software- Must have good data-binding- I’m not really into Java (yes, really)

Ruby/Rails?- I’ve done Ruby (ok, but review options...)

Javascript Client Frameworks?- AngularJS- Ember

Page 5: AngularJS with Node.js and MongoDB

Javascript? Really?

Hey, I’ve never coded Javascript.

Is this a language for ‘real’ software?

The answer is……. (let’s diverge for a moment)

Page 6: AngularJS with Node.js and MongoDB

Pick a server?

I already said I’m not into Java (really)

OK, so what now?

Well, it needs to be - Lightweight, FAST - OpenSource, Manageable

Uhhh yep -- Node.js (more Javascript….)

Page 7: AngularJS with Node.js and MongoDB

Node + Express

So, you’re saying I should write my own server with Node.js?

Yes, definitely. Because Express is frickn’ brilliant

var express = require('express'),http = require('http');var app = express();app.use(express.static(path.join(__dirname, 'public')));http.createServer(app).listen(app.get('port'), function(){ console.log('listening on port ' + app.get('port'));});

Static file server in a few lines...

Page 8: AngularJS with Node.js and MongoDB

Databases, databases

A couple of considerations- Development, iteration effort- SQL schema migration and admin is a pain (to me)

Data pipelining- How will the client model data?- ORM kinda sucks

Should this be the first slide in the deck?

Page 9: AngularJS with Node.js and MongoDB

Crap, another slide on databases

NoSQL pro/con - Align structure with application model → less complex code, probably more performant

- Can’t use relational schema models → Well, I’m totally OK with this

- Must learn ‘collections’ and working w/o joins → I’m OK with this too

- Fast read performance with right ‘schema’ → I’m really OK with this

Page 10: AngularJS with Node.js and MongoDB

Yet another @#(*! slide on databases

NoSQL Choices?- Proven in commercial apps- Good community acceptance/support

- I’m no expert, so just pick one to start with good Node.js support

Let’s go with MongoDB (at least try it)

Page 11: AngularJS with Node.js and MongoDB

Where are we at?

Node.JS and MongoDB for the server side.

These are both Javascript. Well, Mongo is very Javascript compatible, JSON data

Now I’m definitely into a pure JS client framework. Which one?

Uhh, try AngularJS. Why? Gut feel after investigating both, it seems more like software.

Page 12: AngularJS with Node.js and MongoDB

Stack Data PipelineMongoDB - JSON data works great → Modeled for the app needs

Server talks to Mongo - Aggregate / join data - JSON data works great → NO ORM - Return through a pure REST api

AngularJS client - Talks to server only via REST api, never to Mongo - JSON data works great → NO ORM

Page 13: AngularJS with Node.js and MongoDB

Back to that Javascript thing

Javascript is a good core language

Very simple syntax, don’t let this fool you(an aside, complex syntax does not a good language make)

Closures are super powerful in an event based asynchronous environment

And, it’s not just the language, it’s the ecosystem.

Page 14: AngularJS with Node.js and MongoDB

Javascript Client Server Similarities

Browsers operates as - single threaded, event driven, asynchronous

Node.js runs V8 engine Holy crap, it’s the same- single threaded, event driven, asynchronous

Learn asynchronous Javascript programmingwith Angular + Node.js at the same time

Start thinking ‘closure’

Page 15: AngularJS with Node.js and MongoDB

Javascript and Node Packages

Huge capability from the NPM Registry NPM == Node Package Managerhttps://npmjs.org/

Some favorites: - mongodb (mongoDB driver) - express (web server framework) - xml2js (xml parser) - async (synchronizing constructs, serial, parallel) - aws-sdk (integrate with AWS S3, CloudFront, etc)

Page 16: AngularJS with Node.js and MongoDB

Deployment

Again, use what works for your situation

For me, PaaS to start with low admin overhead

- Heroku -- Supports node servers- MongoLab -- Hosted MongoDB

Both have free tiers for development, and scale up for true production

Page 17: AngularJS with Node.js and MongoDB

thanks

contact: [email protected]