- brief overview of what node has built in - overview of how to use Connect is - overview of how to use ExpressJS is - ask questions at any time
- Explain the basics of http module and createServer function. - req is object that has request stuff (url, get params, body, cookies, ..) - res is object that has response stuff (set headers, send data, ..)
- just a very simple http wrapper - gotta code everything up on your own
- connect makes it easier - comes with many useful bundles - typical functionalities that you will need
- similar to node's http module - if put all in same callback, can get messy
- use() is a different way of setting callbacks - we call them Middleware - behind use() is a stack, first in, first out - can use next() to trigger next handler - can have infinite handles
- a better way of setting routes - HTTP verbs - capture url params using colon - can also use regular expressions - next() Error handling - don't need to use next to pass to next() handler. - can organize by module
- stack the middlewares you want - called in order - seperate controllers into modules
- easier than node, but still low level - No view engine, gotta add your own - Configurations, on your own - good for restful since dont need view engine - express is like sinatra - built with connect - all the features of connect, but more
- try it out with CLI tool, its easy - multiple template engines (jade, ejs, mustache, etc...) - css compiler support (less, sass)
- configuration blocks - can be controlled with NODE_ENV environment variable
- Uses Connect.router - Can use HTTP verbs - Can capture params - req.body for POST - req.params for url params
- can sanitize parameters - force type on params - some cases in couchdb that you can nosql injections. this would prevent
- generalize formatters - reuseable
- we want to validate user exists in both situations - we aren't reusing the code - same logic every time
- you could also validate that the userId is an integer using same method. - and call next() if not int
- you can add as many as you need - this example, checking login and checking user exists
- built in ejs and jade - ejs is html with embedded JS - jade is like haml - partials, can render views inside a view
- automatically loads views/user_edit.jade - .render automatically includes layout.jade
- cant go through all of them, just so you know - app.helpers takes an object and exposes in views - app.dynamicHelpers when you want to use request vars - app error,