Created
February 16, 2010 10:16
-
-
Save nmerouze/305432 to your computer and use it in GitHub Desktop.
This file contains 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
/* Requirements */ | |
require.paths.unshift("./vendor/ejsgi/lib"); | |
require.paths.unshift("./vendor/node-scylla/lib"); | |
var scylla = require("scylla"), | |
ejsgi = require("ejsgi"); | |
/* Controller */ | |
var HomeController = { | |
index: function(req) { | |
var body = "Hello World!"; | |
var res = { | |
body: new req.jsgi.stream(), | |
status: 200, | |
headers: { | |
"content-type": "text/html", | |
"content-length": body.length | |
} | |
}; | |
res.body.write(body); | |
res.body.close(); | |
return res; | |
} | |
}; | |
/* Router */ | |
function Router() { scylla.Base.call(this); } | |
Router.prototype = Object.create(scylla.Base.prototype); | |
process.mixin(Router.prototype, { "GET /": HomeController.index }); | |
/* Server */ | |
ejsgi.Server(new Router().adapter("ejsgi"), "localhost", 8000).start(); |
This file contains 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
/* Requirements */ | |
require.paths.unshift("./vendor/node-dirty/lib"); | |
var sys = require("sys"), | |
Dirty = require("dirty").Dirty; | |
/* Model */ | |
var posts = new Dirty("posts.dirty", { flushInterval: 10 }); | |
/* Persistence */ | |
var post = { title: "Awesome post" }; | |
posts.add(post); | |
/* Querying */ | |
sys.puts(posts.get(post._id).title); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment