Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Make exposed a public api and provide a way of hiding application level exposes from the outputted JavaScript. #16

Open
wants to merge 1 commit into from

1 participant

@ForbesLindesay

This would allow writing plugins which cache the app level output in a separate file, to avoid loading it on every page request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2012
  1. @ForbesLindesay

    Make exposed a public api and provide a way of hiding application lev…

    ForbesLindesay authored
    …el exposes from the outputted JavaScript.
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/express-expose.js
View
10 lib/express-expose.js
@@ -1,4 +1,3 @@
-
/*!
* express-expose
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
@@ -37,6 +36,11 @@ exports.namespace = 'express';
exports.name = 'javascript';
/**
+ * Default to exposing application level exposures as well as request level.
+ */
+exports.exposeAppLevel = true;
+
+/**
* Expose the given `obj` to the client-side, with
* an optional `namespace` defaulting to "express".
*
@@ -68,7 +72,7 @@ HTTPSServer.prototype.expose = function(obj, namespace, name){
var helpers = {};
app._exposed[name] = true;
helpers[name] = function(req, res){
- var appjs = app.exposed(name)
+ var appjs = (exports.exposeAppLevel?app.exposed(name):'')
, resjs = res.exposed(name)
, js = '';
@@ -162,7 +166,7 @@ HTTPSServer.prototype.exposeModule = function(path, namespace, name){
* Render the exposed javascript.
*
* @return {String}
- * @api private
+ * @api public
*/
res.exposed =
Something went wrong with that request. Please try again.