Permalink
Browse files

clean up proto extensions

  • Loading branch information...
1 parent c1c1477 commit e80f7bc0e252405749545abfe6a889eb363352d0 @tj tj committed May 30, 2012
Showing with 9 additions and 25 deletions.
  1. +9 −25 lib/express-expose.js
View
@@ -13,9 +13,8 @@ var express = require('express')
, basename = require('path').basename
, extname = require('path').extname
, http = require('http')
- , res = http.ServerResponse.prototype
- , HTTPSServer = express.HTTPSServer
- , HTTPServer = express.HTTPServer
+ , app = express.application
+ , res = express.response
, fs = require('fs');
/**
@@ -48,7 +47,7 @@ exports.name = 'javascript';
*/
res.expose =
-express.application.expose = function(obj, namespace, name){
+app.expose = function(obj, namespace, name){
var app = this.app || this;
app._exposed = app._exposed || {};
@@ -66,23 +65,9 @@ express.application.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)
- , js = '';
-
- if (appjs || resjs) {
- js += '// app: \n' + appjs;
- js += '// res: \n' + resjs;
- }
- return js;
- };
- app.dynamicHelpers(helpers);
- */
app.locals.use(function(req, res) {
- var appjs = app.exposed(name)
+ var appjs = app.exposed(name)
, resjs = res.exposed(name)
, js = '';
@@ -91,9 +76,8 @@ express.application.expose = function(obj, namespace, name){
js += '// res: \n' + resjs;
}
- res.locals[name] = js;
- });
-
+ res.locals[name] = js;
+ });
}
// buffer string
@@ -129,7 +113,7 @@ express.application.expose = function(obj, namespace, name){
*/
res.exposeRequire =
-express.application.exposeRequire = function(){
+app.exposeRequire = function(){
if (this._require) return this;
this._require = true;
var js = fs.readFileSync(__dirname + '/require.js', 'ascii');
@@ -150,7 +134,7 @@ express.application.exposeRequire = function(){
*/
res.exposeModule =
-express.application.exposeModule = function(path, namespace, name){
+app.exposeModule = function(path, namespace, name){
var path = require.resolve(path)
, js = fs.readFileSync(path, 'utf8')
, namespace = namespace || basename(path, extname(path));
@@ -177,7 +161,7 @@ express.application.exposeModule = function(path, namespace, name){
* @api private
*/
res.exposed =
-express.application.exposed = function(name){
+app.exposed = function(name){
name = name || exports.name;
this.js = this.js || {};
return this.js[name]

0 comments on commit e80f7bc

Please sign in to comment.