Comparing version 0.2.1 to 0.3.0
@@ -48,4 +48,11 @@ 'use strict'; | ||
var stream = fs.createReadStream(filename); | ||
if (pathname === '/core' || pathname === '/signin') { | ||
type = 'text/html'; | ||
var replaceVersion = require('../replace_version').createReplaceStream(prefixes); | ||
stream = stream.pipe(replaceVersion); | ||
} else if (pathname === '/boot.js') { | ||
var replaceVersion = require('../replace_version').createPrependStream(prefixes); | ||
stream = stream.pipe(replaceVersion); | ||
type = mime.lookup(filename); | ||
} else { | ||
@@ -58,4 +65,3 @@ type = mime.lookup(filename); | ||
response.setHeader('Expires', '0'); | ||
response.write(fs.readFileSync(filename)); | ||
response.end(); | ||
stream.pipe(response); | ||
return true; | ||
@@ -62,0 +68,0 @@ }; |
@@ -76,3 +76,4 @@ function lock() { | ||
reply = JSON.parse(reply.join('')); | ||
if (reply.error) { | ||
if (reply.error || !reply.rampup) { | ||
if (verbose.local) console.log('Invalid/no rampup data received from backend.'); | ||
response.end(JSON.stringify(reply, null, 4)); | ||
@@ -79,0 +80,0 @@ return; |
@@ -6,2 +6,3 @@ function create(options) { | ||
var verbose = options.verbose; | ||
var prefixes = options.prefixes; | ||
@@ -38,2 +39,11 @@ var server; | ||
var opt = url.parse(URL); | ||
var pathname = opt.pathname; | ||
//remove base directories (only /appsuite/ and /base/) | ||
//TODO: handle custom base directories (?) | ||
pathname = pathname.replace(/^\/appsuite\//, '/'); | ||
pathname = pathname.replace(/^\/base\//, '/'); | ||
pathname = pathname.replace(/^\/v=[^\/]+\//, '/'); | ||
pathname = pathname.replace(/^\/$/, '/core'); | ||
opt.method = request.method; | ||
@@ -51,2 +61,25 @@ opt.headers = request.headers; | ||
response.writeHead(res.statusCode, res.headers); | ||
if (pathname === '/core' || | ||
pathname === '/signin' || | ||
pathname === '/boot.js') | ||
{ | ||
var zlib = require('zlib'); | ||
var replace = require('../replace_version'); | ||
var stream = (pathname === '/boot.js') ? replace.createPrependStream(prefixes) : replace.createReplaceStream(prefixes); | ||
switch (res.headers['content-encoding']) { | ||
case 'gzip': | ||
res = res.pipe(zlib.createGunzip()) | ||
.pipe(stream) | ||
.pipe(zlib.createGzip()); | ||
break; | ||
case 'deflate': | ||
res = res.pipe(zlib.createInflate()) | ||
.pipe(stream) | ||
.pipe(zlib.createDeflate()); | ||
break; | ||
default: | ||
res = res.pipe(stream); | ||
break; | ||
} | ||
} | ||
res.pipe(response); | ||
@@ -53,0 +86,0 @@ })); |
{ | ||
"name": "appserver", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "A connect based middleware to support local development against a remote backend.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/appserver", |
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
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
41144
19
755
5