Skip to content

Instantly share code, notes, and snippets.

@focusaurus
Created September 26, 2016 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save focusaurus/4bda0999a9c864d170412c5df43bf5eb to your computer and use it in GitHub Desktop.
Save focusaurus/4bda0999a9c864d170412c5df43bf5eb to your computer and use it in GitHub Desktop.
function listUsers (req, callback) {
// use req as immutable input
// standard node error-first callback API
// success value of callback is a response-shaped object with properties: statusCode, headers, body
}
// I haven't built one of these, just riffing.
// Look at clojure and other functional languages for examples that might
// have reasonable counterparts in "functional-light" JS
// Thinking more along the lines of react/redux reducer style
// Problems with express:
// - the res object being so stateful, harder to test
// - middleware dependencies are implicit instead of explicit
// - "next" connect middleware API is not just standard error-first callback pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment