Skip to content

Instantly share code, notes, and snippets.

@bewest
Last active December 18, 2015 10:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bewest/5767675 to your computer and use it in GitHub Desktop.
Save bewest/5767675 to your computer and use it in GitHub Desktop.
theory of operation

Theory of operation

Which libraries to choose. Reading up and node and especially the stream-handbook has biased my choices quite heavily.

Load Balancing

Hit:

Sessions

This creates a RESTful API inside your network you can use to keep track of active sessions. Just create one cookie to reference the soid.

Auth

Oauth/openid etc.

Everyauth and passport are both reasonable. It's best to use express if you are going to manipulate cookies. If you use restify, you'll have a hard time manipulating cookies with cookie to manage cookie jars. It's ok to have multiple daemons running on multiple ports.

User ORM

Coordination

Views

Use proper HTML, avoid string concat and regexp in browser to create views. Use js to add behavior to re-usable patterns of HTML.

Docpad is node js version of same thing, with all the right features. After trying about a dozen frameworks, I now recommend docpad.

Plays nice with both gh-pages, static-hosting, dynamic hosting, s3, rsync, and with prose.io. Also very easy to share notes/documents etc in private repo dedicated for that purpose.

Templating

Avoid templating, try to transform smart style guides. Easily testable, modular components, which can be composed to create UI. Here's my personal take, using underscore and backbone (see other examples for jquery only): https://github.com/bewest/field_descriptor.js (the trick is to use DOM.clone(true) to clone "semantic POSH", ends up working similar to bootstrap, which requires valid HTML as input.

Here are other takes on the same thing (similar approach mapping selectors to behavior, basically):

Note unlike some data-bindings, these do not inject new control structures into DOM. Control is left to the procedural script (js). This allows for sane code base.

@ianjorgensen
Copy link

I would like to separete schemas from data store. I really like https://github.com/akidee/schema.js for schemas and my favorite mongo lib is one i wrote with a friend a while, its somewhat popular https://github.com/gett/mongojs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment