Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #18 from mmalecki/0.6-compatibility

0.6 compatibility
  • Loading branch information...
commit c8d219dce2fb4e691d6bd1e5ceeb0a89df723b95 2 parents 7bf4ede + f2ce258
@indexzero indexzero authored
Showing with 20 additions and 28 deletions.
  1. +11 −10 example/http-server.js
  2. +4 −8 lib/journey.js
  3. +5 −10 test/journey-test.js
View
21 example/http-server.js
@@ -1,16 +1,17 @@
-var path = require('path'),
- sys = require('sys');
+var util = require('util');
-require.paths.unshift(path.join(__dirname, '..', 'lib'));
-
-var journey = require('journey');
+var journey = require('../lib/journey');
//
// Create a Router object with an associated routing table
//
-var router = new(journey.Router)(function (map) {
- map.root.bind(function (res) { res.send("Welcome") }); // GET '/'
- map.get('/version').bind(function (res) {
+var router = new(journey.Router);
+
+router.map(function () {
+ this.root.bind(function (req, res) { // GET '/'
+ res.send(200, {}, "Welcome");
+ });
+ this.get('/version').bind(function (req, res) {
res.send(200, {}, { version: journey.version.join('.') });
});
});
@@ -23,11 +24,11 @@ require('http').createServer(function (request, response) {
//
// Dispatch the request to the router
//
- router.route(request, body, function (result) {
+ router.handle(request, body, function (result) {
response.writeHead(result.status, result.headers);
response.end(result.body);
});
});
}).listen(8080);
-sys.puts('journey listening at http://127.0.0.1:8080');
+util.puts('journey listening at http://127.0.0.1:8080');
View
12 lib/journey.js
@@ -1,16 +1,12 @@
var path = require('path');
-require.paths.unshift(__dirname);
-
-var sys = require("sys"),
- http = require("http"),
- events = require('events'),
- fs = require("fs"),
- url = require('url');
+var http = require("http"),
+ events = require('events'),
+ url = require('url');
var querystring = require('querystring');
-var errors = require('journey/errors');
+var errors = require('./journey/errors');
// Escape RegExp characters in a string
var escapeRe = (function () {
View
15 test/journey-test.js
@@ -1,15 +1,10 @@
-var sys = require('sys'),
- http = require('http'),
- assert = require('assert'),
- path = require('path'),
- events = require('events'),
- url = require('url');
+var http = require('http'),
+ assert = require('assert'),
+ events = require('events');
var vows = require('vows');
-require.paths.unshift(__dirname, path.join(__dirname, '..'));
-
-var journey = require('lib/journey');
+var journey = require('../lib/journey');
var resources = {
"home": {
@@ -111,7 +106,7 @@ router.map(function (map) {
});
});
-var mock = require('lib/journey/mock-request').mock(router);
+var mock = require('../lib/journey/mock-request').mock(router);
var get = mock.get,
del = mock.del,

1 comment on commit c8d219d

@andrewhodel

Any idea when this will get into NPM?

Right now I fail with the expected:

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
at Function. (module.js:376:11)
at Object. (/home/zip/node-collect/node_modules/journey/lib/journey.js:3:8)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object. (/home/zip/node-collect/listener.js:2:15)
at Module._compile (module.js:432:26)

Please sign in to comment.
Something went wrong with that request. Please try again.