Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Compatibility with the express 3.0.0alpha4 #19

Merged
merged 2 commits into from

2 participants

@isstaif

I've mainly used express.application instead of express.HTTPServer and replaced the old Dynamic Helpers.

This would solve issue #18 :)

@tj tj merged commit f1967f4 into expressjs:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 30, 2012
  1. @isstaif

    initial replacement

    isstaif authored
  2. @isstaif
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 11 deletions.
  1. +22 −11 lib/express-expose.js
View
33 lib/express-expose.js
@@ -48,8 +48,7 @@ exports.name = 'javascript';
*/
res.expose =
-HTTPServer.prototype.expose =
-HTTPSServer.prototype.expose = function(obj, namespace, name){
+express.application.expose = function(obj, namespace, name){
var app = this.app || this;
app._exposed = app._exposed || {};
@@ -67,6 +66,7 @@ HTTPSServer.prototype.expose = function(obj, namespace, name){
if (!app._exposed[name]) {
var helpers = {};
app._exposed[name] = true;
+ /*
helpers[name] = function(req, res){
var appjs = app.exposed(name)
, resjs = res.exposed(name)
@@ -80,6 +80,20 @@ HTTPSServer.prototype.expose = function(obj, namespace, name){
return js;
};
app.dynamicHelpers(helpers);
+ */
+ app.locals.use(function(req, res) {
+ var appjs = app.exposed(name)
+ , resjs = res.exposed(name)
+ , js = '';
+
+ if (appjs || resjs) {
+ js += '// app: \n' + appjs;
+ js += '// res: \n' + resjs;
+ }
+
+ res.locals[name] = js;
+ });
+
}
// buffer string
@@ -115,8 +129,7 @@ HTTPSServer.prototype.expose = function(obj, namespace, name){
*/
res.exposeRequire =
-HTTPServer.prototype.exposeRequire =
-HTTPSServer.prototype.exposeRequire = function(){
+express.application.exposeRequire = function(){
if (this._require) return this;
this._require = true;
var js = fs.readFileSync(__dirname + '/require.js', 'ascii');
@@ -137,8 +150,7 @@ HTTPSServer.prototype.exposeRequire = function(){
*/
res.exposeModule =
-HTTPServer.prototype.exposeModule =
-HTTPSServer.prototype.exposeModule = function(path, namespace, name){
+express.application.exposeModule = function(path, namespace, name){
var path = require.resolve(path)
, js = fs.readFileSync(path, 'utf8')
, namespace = namespace || basename(path, extname(path));
@@ -164,10 +176,8 @@ HTTPSServer.prototype.exposeModule = function(path, namespace, name){
* @return {String}
* @api private
*/
-
res.exposed =
-HTTPServer.prototype.exposed =
-HTTPSServer.prototype.exposed = function(name){
+express.application.exposed = function(name){
name = name || exports.name;
this.js = this.js || {};
return this.js[name]
@@ -211,7 +221,7 @@ function renderNamespace(str){
var parts = []
, split = str.split('.')
, len = split.length;
-
+
return str.split('.').map(function(part, i){
parts.push(part);
part = parts.join('.');
@@ -257,4 +267,5 @@ function string(obj) {
} else {
return JSON.stringify(obj);
}
-}
+}
+
Something went wrong with that request. Please try again.