Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appserver

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appserver - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

lib/replace_version.js

10

lib/middleware/localfiles.js

@@ -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 @@ };

3

lib/middleware/login.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc