Skip to content

Commit

Permalink
page.js 1.5 support and browserify support
Browse files Browse the repository at this point in the history
  • Loading branch information
kethinov committed Dec 3, 2014
1 parent c52593d commit 2184dd4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
"name": "page.js-express-mapper.js",
"description": "Plugin for page.js which directly imitates the Express API.",
"author": "Eric Newport <kethinov@gmail.com>",
"version": "1.0.2",
"version": "1.0.3",
"homepage": "https://github.com/kethinov/page.js-express-mapper.js",
"license": "Creative Commons Attribution 4.0 International License",
"main": "page.js-express-mapper.js",
"repository": {
"type": "git",
"url": "git://github.com/kethinov/page.js-express-mapper.js.git"
},
"dependencies": {
"page": "^1.5.0"
},
"keywords": [
"page.js",
"express",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "page.js-express-mapper.js",
"version": "1.0.2",
"version": "1.0.3",
"description": "Plugin for page.js which directly imitates the Express API.",
"main": "page.js-express-mapper.js",
"repository": {
Expand All @@ -15,7 +15,7 @@
"homepage": "https://github.com/kethinov/page.js-express-mapper.js",
"readmeFilename": "README.md",
"dependencies": {
"page": "^1.4.0"
"page": "^1.5.0"
},
"keywords": [
"page.js",
Expand Down
13 changes: 8 additions & 5 deletions page.js-express-mapper.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
;(function() {

function pageExpressMapper(params) {
var app,
res;
var app, res;

// renderMethod param
if (params.renderMethod && typeof params.renderMethod == 'function') {

res = {
render: params.renderMethod, // template, model
redirect: function(route) {
page(route);
page.redirect(route);
}
};

// overload page.js route prototype
page.Route.prototype.middleware = function(fn) {
var self = this;
return function(ctx, next) {
if (self.match(ctx.path, ctx.params)) return fn(ctx, res, next);
if (self.match(ctx.path, ctx.params)) return fn(ctx, res, next); // new
next();
};
};
Expand Down Expand Up @@ -55,7 +54,11 @@
}
}

if ('undefined' != typeof window) {
// expose pageExpressMapper
if ('undefined' == typeof module) {
window.pageExpressMapper = pageExpressMapper;
}
else {
module.exports = pageExpressMapper;
}
})();

0 comments on commit 2184dd4

Please sign in to comment.