Created
August 13, 2011 15:18
-
-
Save Raynos/1143943 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Flow-based example of serving web pages | |
noflo = require "noflo" | |
graph = noflo.graph.createGraph "blog" | |
graph.addNode "Web Server", "HTTP/Server" | |
graph.addNode "Profiler", "HTTP/Profiler" | |
graph.addNode "Authentication", "HTTP/BasicAuth" | |
graph.addNode "Read Template", "ReadFile" | |
graph.addNode "Greet User", require("./HelloController").getComponent() | |
graph.addNode "Render", "Template" | |
graph.addNode "Write Response", "HTTP/WriteResponse" | |
graph.addNode "Send", "HTTP/SendResponse" | |
# Main request flow | |
graph.addInitial 8003, "Web Server", "listen" | |
graph.addEdge "Web Server", "request", "Profiler", "in" | |
graph.addEdge "Profiler", "out", "Authentication", "in" | |
graph.addEdge "Authentication", "out", "Greet User", "in" | |
graph.addEdge "Greet User", "out", "Write Response", "in" | |
graph.addEdge "Greet User", "data", "Render", "options" | |
graph.addEdge "Write Response", "out", "Send", "in" | |
# Templating flow | |
graph.addInitial "#{__dirname}/hello.jade", "Read Template", "source" | |
graph.addEdge "Read Template", "out", "Render", "template" | |
graph.addEdge "Render", "out", "Write Response", "string" | |
console.log JSON.stringify graph.toJSON(), null, 2 | |
noflo.createNetwork graph |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment