From 7ec5aa6e3f7cac9caafde6f07860baaf51deb375 Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Tue, 21 Jun 2011 09:37:20 -0600 Subject: [PATCH] port browserid server to express. issue #21. --- README.md | 2 +- authority/server/{run.js => app.js} | 4 +++- authority/server/standalone.js | 21 ++++++++++----------- 3 files changed, 14 insertions(+), 13 deletions(-) rename authority/server/{run.js => app.js} (96%) diff --git a/README.md b/README.md index 86a4a8dc6..3ef180207 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is an exploration of the distributed identity system All of the servers here are based on node.js, and some number of 3rd party node modules are required to make them go. ([npm](http://npmjs.org/) is a good way to get these libraries) * node.js (>= 0.4.5): http://nodejs.org/ -* connect (>= 1.3.0): http://senchalabs.github.com/connect/ +* express (>= 2.3.11): http://senchalabs.github.com/express/ * xml2js (>= 0.1.5) * sqlite (>= 1.0.3) * mustache (>= 0.3.1) diff --git a/authority/server/run.js b/authority/server/app.js similarity index 96% rename from authority/server/run.js rename to authority/server/app.js index 1c24d5bfa..c88200b7c 100644 --- a/authority/server/run.js +++ b/authority/server/app.js @@ -11,7 +11,7 @@ const STATIC_DIR = path.join(path.dirname(__dirname), "static"); const COOKIE_SECRET = secrets.hydrateSecret('cookie_secret', __dirname); -exports.handler = function(request, response, next) { +function handler(request, response, next) { // dispatch! var urlpath = url.parse(request.url).pathname; @@ -56,4 +56,6 @@ exports.setup = function(server) { session_key: "browserid_state", path: '/' })); + + server.use(handler); } diff --git a/authority/server/standalone.js b/authority/server/standalone.js index 7563c9086..6623c4ae1 100644 --- a/authority/server/standalone.js +++ b/authority/server/standalone.js @@ -3,24 +3,23 @@ var sys = require("sys"), url = require("url"), path = require("path"), fs = require("fs"), - connect = require("connect"); + express = require("express"); var PRIMARY_HOST = "127.0.0.1"; var PRIMARY_PORT = 62700; -var handler = require("./run.js"); +var handler = require("./app.js"); -var server = connect.createServer().use(connect.favicon()) - .use(connect.logger({ - stream: fs.createWriteStream(path.join(__dirname, "server.log")) - })); +var app = require('express').createServer(); -// let the specific server interact directly with the connect server to register their middleware -if (handler.setup) handler.setup(server); +app.use(express.logger({ + stream: fs.createWriteStream(path.join(__dirname, "server.log")) +})); -server.use(handler.handler); +// let the specific server interact directly with the connect server to register their middleware +if (handler.setup) handler.setup(app); // use the connect 'static' middleware for serving of static files (cache headers, HTTP range, etc) -server.use(connect.static(path.join(path.dirname(__dirname), "static"))); +app.use(express.static(path.join(path.dirname(__dirname), "static"))); -server.listen(PRIMARY_PORT, PRIMARY_HOST); +app.listen(PRIMARY_PORT, PRIMARY_HOST); -- GitLab