Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created October 19, 2011 11:38
Show Gist options
  • Save Raynos/1298044 to your computer and use it in GitHub Desktop.
Save Raynos/1298044 to your computer and use it in GitHub Desktop.
// set up pd
var pd = require("pd").extendNatives();
// dependencies and unpacking frame
var arch = require("arch"),
error = arch.error,
fs = require("fs"),
Arch = arch.Arch,
http = require("http"),
path = require("path"),
rest = arch.Rest.new(),
stack = arch.Stack.new(),
trinity = require("trinity");
// set up trinity
trinity.set("path", path.join(__dirname, "public", "trinity"));
trinity.set("clientPath", "trinity");
// create http server
var server = http.createServer(function (req, res) {
stack.handle({
data: [req, res]
});
});
// register router, static & error handler
stack.use(rest.router());
stack.use(Arch.static(path.join(__dirname, "public")));
stack.use(Arch.error());
// load resources
fs.readdir(__dirname + "/resources", error.throw(function (err, files) {
files.forEach(function (file) {
require(__dirname + "/resources/" + file)(rest);
});
}));
// start server
server.listen(8080);
console.log("listen to port 8080");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment