Comparing version 0.9.84 to 0.9.85
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.9.84", | ||
"version": "0.9.85", | ||
"bin": { | ||
@@ -12,0 +12,0 @@ "atma": "atma" |
@@ -26,3 +26,4 @@ (function(){ | ||
} | ||
logger.log(config); | ||
include | ||
@@ -29,0 +30,0 @@ .js('/src/server/server.js') |
@@ -267,6 +267,7 @@ include | ||
function build(type, includes) { | ||
var arr = []; | ||
if (!(includes && includes.length)) | ||
return null; | ||
return arr; | ||
var arr = []; | ||
for (var i = 0; i < includes.length; i++) { | ||
@@ -273,0 +274,0 @@ |
@@ -1,2 +0,5 @@ | ||
include.js(['../util.js::AstUtil','../../util/includeMock.js::Include']).done(function(resp) { | ||
include.js( | ||
'../util.js::AstUtil', | ||
'../../util/includeMock.js::Include' | ||
).done(function(resp) { | ||
@@ -72,5 +75,8 @@ var util = resp.AstUtil, | ||
case 'use': | ||
case 'getPending': | ||
case 'apply': | ||
break; | ||
default: | ||
console.log('getIncludes: Unknown expression', node.expression); | ||
logger | ||
.log('getIncludes: Unknown function call', node.expression); | ||
break; | ||
@@ -77,0 +83,0 @@ } |
@@ -21,3 +21,3 @@ | ||
var port = config.port || 5777, | ||
var port = config.port || process.env.PORT || 5777, | ||
proxyPath = config.proxy; | ||
@@ -54,10 +54,13 @@ | ||
var connect = require('connect'), | ||
port = process.env.PORT || 5777; | ||
var connect = require('connect'); | ||
var middleware = new resp.Middleware() | ||
.add(connect.query()) | ||
.add(connect.urlencoded()) | ||
.add(connect.json()) | ||
.add(app.responder()) | ||
.add(app.responder({ | ||
middleware: [ | ||
connect.query(), | ||
connect.urlencoded(), | ||
connect.json() | ||
] | ||
})) | ||
.add(resp.static()) | ||
@@ -64,0 +67,0 @@ .add(resp.proxy(proxyPath)) |
var http = require('http'), | ||
Url = require('url'), | ||
var http_ = require('http'), | ||
https_ = require('https'), | ||
url_ = require('url'), | ||
proxyPath = null, | ||
@@ -11,3 +13,3 @@ matcher = null; | ||
set: function(path){ | ||
proxyPath = Url.parse(path); | ||
proxyPath = path; | ||
}, | ||
@@ -30,24 +32,17 @@ setMatcher: function(mix){ | ||
logger(60).log(' - prox - ', req.url); | ||
var headers = req.headers, | ||
method = req.method, | ||
url = url_.resolve(proxyPath, req.url) | ||
; | ||
var options = { | ||
method: method, | ||
headers: extend({}, headers), | ||
agent: false, | ||
}; | ||
var options = Object.extend({ | ||
headers: req.headers, | ||
method: req.method | ||
}, proxyPath); | ||
Object.extend(options, Url.parse(req.url)); | ||
options.headers.host = proxyPath.host; | ||
var proxy = http.request(options, function(response){ | ||
res.writeHeader(response.statusCode, response.headers); | ||
response.pipe(res, {end: true}); | ||
}); | ||
req.pipe(proxy, {end: true}); | ||
logger(60) | ||
.log('<server:proxy>', url, method); | ||
pipe(req, res, options, url); | ||
return true; | ||
} | ||
@@ -69,2 +64,65 @@ } | ||
} | ||
}; | ||
}; | ||
function pipe(req, res, options_, remoteUrl, redirects) { | ||
if (redirects == null) | ||
redirects = 0; | ||
if (redirects > 10) { | ||
res.writeHead(500, { | ||
'content-type': 'text/plain' | ||
}); | ||
res.end('Too much redirects, last url: ' + remoteUrl); | ||
return; | ||
} | ||
var remote = url_.parse(remoteUrl), | ||
options = {}; | ||
extend(options, options_); | ||
extend(options, remote); | ||
options.headers.host = remote.host; | ||
delete options.headers.connection; | ||
var client = remote.protocol === 'https:' | ||
? https_ | ||
: http_; | ||
var request = client.request(options, function(response) { | ||
var code = response.statusCode; | ||
if (code === 301 || code === 302) { | ||
var location = response.headers.location; | ||
if (location) | ||
pipe(req, res, options_, location, ++redirects); | ||
return; | ||
} | ||
res.statusCode = code; | ||
for(var key in response.headers) | ||
res.setHeader(key, response.headers[key]); | ||
response.pipe(res, { | ||
end: true | ||
}); | ||
}); | ||
// @TODO pipe post body to redirects | ||
req.pipe(request, { | ||
end: true | ||
}); | ||
} | ||
function extend(target, source){ | ||
for (var key in source) | ||
if (source[key] != null) | ||
target[key] = source[key]; | ||
return target; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
853871
12179
9