Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Return top level function for JSGI middleware modules

  • Loading branch information...
commit b9e0f97184d91486c374b76ea4e3c2a8feee90ff 1 parent cd82c1b
Kris Zyp kriszyp authored
4 jsgi/auth.js
View
@@ -9,7 +9,7 @@ var AccessError = require("perstore/errors").AccessError,
print = require("promised-io/process").print,
base64 = require("../util/base64");
-exports.Authentication = function(security, nextApp){
+var Authentication = function(security, nextApp){
// initialize the user model
security.getUserModel();
return function(request){
@@ -61,3 +61,5 @@ exports.Authentication = function(security, nextApp){
};
};
+Authentication.Authentication = Authentication;
+module.exports = Authentication;
4 jsgi/cascade.js
View
@@ -4,7 +4,7 @@
*/
var defer = require("promised-io/promise").defer,
when = require("promised-io/promise").when;
-var Cascade = exports.Cascade = function(apps, status) {
+var Cascade = function(apps, status) {
status = status || 404;
return function(env) {
@@ -34,3 +34,5 @@ var Cascade = exports.Cascade = function(apps, status) {
return deferred.promise;
}
}
+Cascade.Cascade = Cascade;
+module.exports = Cascade;
4 jsgi/class-alias.js
View
@@ -1,6 +1,6 @@
var classModel = require('model').classModel;
-exports.Handler = function(nextApp) {
+var Handler = function(nextApp) {
return function(request) {
try {
var modelPath = request.pathInfo.substring(1);
@@ -10,3 +10,5 @@ exports.Handler = function(nextApp) {
return nextApp(request);
};
};
+Handler.Handler = Handler;
+module.exports = Handler;
4 jsgi/compress.js
View
@@ -3,7 +3,7 @@
*/
var when = require("promised-io/promise").when;
-exports.Compress = function(nextApp){
+var Compress = function(nextApp){
return function(request){
var encoding = 'gzip';
if ((request.headers['accept-encoding']||'').indexOf(encoding) >= 0) {
@@ -53,3 +53,5 @@ exports.Compress = function(nextApp){
return nextApp(request);
};
};
+Compress.Compress = Compress;
+module.exports = Compress;
4 jsgi/conditional.js
View
@@ -3,7 +3,7 @@
*/
var DatabaseError = require("perstore/errors").DatabaseError,
when = require("promised-io/promise").when;
-exports.Conditional = function(onlyHandleGet, nextApp){
+var Conditional = function(onlyHandleGet, nextApp){
return function(request){
if(!onlyHandleGet && request.method !== "GET"){
// onlyHandleGet is appropriate when an error really needs to be thrown to
@@ -53,3 +53,5 @@ exports.Conditional = function(onlyHandleGet, nextApp){
});
};
}
+Conditional.Conditional = Conditional;
+module.exports = Conditional;
4 jsgi/context.js
View
@@ -2,7 +2,7 @@
* Provides the request as the context (across async promises)
*/
var promiseModule = require("promised-io/promise");
-exports.SetContext= function(vars, nextApp){
+var SetContext = function(vars, nextApp){
return function(request){
try{
promiseModule.currentContext = request.context = ((typeof vars === 'function') ? vars(request) : vars) || {};
@@ -13,3 +13,5 @@ exports.SetContext= function(vars, nextApp){
}
};
};
+SetContext.SetContext = SetContext;
+module.exports = SetContext;
5 jsgi/csrf.js
View
@@ -2,7 +2,7 @@
* Detects cross-site forgeable requests and warns downstream middleware/apps
* by adding a crossSiteForgeable property to the request
*/
-exports.CSRFDetect = function(customHeader, nextApp){
+var CSRFDetect = function(customHeader, nextApp){
if(typeof customHeader == "function"){
nextApp = customHeader;
}
@@ -17,3 +17,6 @@ exports.CSRFDetect = function(customHeader, nextApp){
return nextApp(request);
};
};
+
+CSRFDetect.CSRFDetect = CSRFDetect;
+module.exports = CSRFDetect;
11 jsgi/xsite.js
View
@@ -5,12 +5,12 @@
var parseQuery = require("./querystring").parseQuery,
when = require("promised-io/promise").when;
-exports.CrossSite = function(nextApp){
+var CrossSite = function(nextApp){
return JsonP(
WindowName(
CrossSiteXhr(nextApp)));
};
-
+CrossSite.CrossSite = CrossSite;
function JsonP(nextApp){
return function(request){
@@ -36,7 +36,7 @@ function JsonP(nextApp){
// TODO: Handle 401 with a dialog to enter credentials
};
};
-exports.JsonP = JsonP;
+CrossSite.JsonP = JsonP;
function WindowName(nextApp){
return function(request){
@@ -62,7 +62,7 @@ function WindowName(nextApp){
return nextApp(request);
};
};
-exports.WindowName = WindowName;
+CrossSite.WindowName = WindowName;
function CrossSiteXhr(nextApp){
return function(request, allowed){
@@ -99,4 +99,5 @@ function CrossSiteXhr(nextApp){
};
};
-exports.CrossSiteXhr = CrossSiteXhr;
+CrossSite.CrossSiteXhr = CrossSiteXhr;
+module.exports = CrossSite;
Please sign in to comment.
Something went wrong with that request. Please try again.