mean stack c0nrad. overview day 1: – mean stack – nodejs mini cat fact spammer – mongodb cat...

Post on 26-Dec-2015

218 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

MEAN Stack

c0nrad

Overview

• Day 1:– MEAN Stack– NodeJS

• Mini Cat Fact Spammer

– MongoDB• Cat Profiles

– Express• Catbook API (Facebook for cats)

• Day 2:– AngularJS– CatBook

“Newb’s guide to webscale”

Mom: “Why can’t you read porn like a normal boy?”

Kiss me and you’ll see how important I am

Disclaimer

• I’m not an expert in these stuff, I just write a lot of code and I enjoy MEAN stack.

MEAN Stack

• MongoDB– Daterbaser

• Express– Web framework

• AngularJS– Client Side Framework

• NodeJS– Web server

MEAN

• MongoDB– Daterbaser

• Express– Web framework

• AngularJS– Client Side Framework

• NodeJS– Web server

NodeJS

NodeJS• platform built on Chrome's JavaScript runtime for easily

building fast, scalable network applications• uses an event-driven, non-blocking I/O model

• lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices

• used by Groupon, SAP, LinkedIn, Microsoft, Yahoo!, Walmart, Rakuten and PayPal.

• NPM – node package manager

How does one Asynchronous?

NodeJS

so I herd u liek catfactz

MongoDB

• Stores data in a flexable data document (json)

• WebScale• Craigslist, eBay,

Foursquare, SourceForge, Viacom, and the New York Times, among others.

• MongoDB is the most popular NoSQL database system.

• Ad hoc queries• Indexing (secondary

indexing)• Replication• Load balancing• Aggregation framework• Serverside javascript• Capped collections

MongoDB

• Mongo vs MongoD• DB– Collections

• Documents– Fields

• show dbs• use db• show collections• db.cats.insert()• db.cats.find()• db.cats.remove()• db.cats.update()– $set

CODE TIME

Mongoose

• NodeJS Driver• schema-based solution for modeling data – built-in type casting– validation,– query building– business logic hooks and more.

Mongoose

NodeJS without Express

Missing routing, packages, params, and who wants to set content type?

Express

• Fast, unopinionated, minimalist web framework for Node.js

• Most popular by far– Robust routing– Focus on high performance– Super-high test coverage– HTTP helpers (redirection, caching, etc)– View system supporting 14+ template engines– Content negotiation– Executable for generating applications quickly

Express

• My favorite benefits– HTTP Routing

• Verbs• Params

– Middleware– Configuration/Packages– Sessions– More funner!

API

• Application Programmers Interface• It’s how you interact with the data• RESTful (Representational State Transfer)– GET: Give me the data– PUT: Update the data– POST: Create some new data– DELETE: Delete the data

CatBook API

• Mongoose Model• Cat API:

– GET /api/cats • Get a list of kittens

– GET /api/cat/:id• Get a specific kitten

– POST /api/cat• Add a new kitten

– PUT /api/cat/:id• Update a kitten

– DELETE /api/cat/:id• Delete a kitten

• “You got meow”• Meow API:– POST /api/meow– GET /api/cat/meows

Conclusion

• MEAN (err, MEN)• SPA• RESTful API• MongoDB – Find Update Insert Remove• NodeJS/NPM – Web Server• Express – Minimal Web Framework

Next Week

• We build Catbook– AngularJS– Bootstrap– HTML/CSS/JS

• Deploy to Heroku

top related