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

superstatic

Package Overview
Dependencies
Maintainers
1
Versions
205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superstatic - npm Package Compare versions

Comparing version 0.4.2 to 0.4.3

test/fixtures/sample_app/superstatic.html

26

bin/superstatic.js

@@ -6,8 +6,9 @@ #!/usr/bin/env node

var path = require('path');
var chokidar = require('chokidar');
var argv = require('optimist').argv;
var Superstatic = require('../lib/server/superstatic_server');
var defaults = require('../lib/defaults');
var server;
// app working directory
var watcherGlob = '**/*';
var port = exports.port = argv.port || argv.p || defaults.PORT;

@@ -19,7 +20,22 @@ var host = exports.host = argv.host || argv.h || defaults.HOST;

var server = createInstance(awd, host, port);
server.start(function () {
preamble(host, port);
startServer();
// Watch config file for changes
process.nextTick(function () {
chokidar.watch(server.settings.getConfigFileName())
.on('change', configFileChanged);
});
function configFileChanged () {
console.log('Configuration file changed. Restarting...');
server.stop(startServer);
}
function startServer () {
server = createInstance(awd, host, port);
server.start(function () {
preamble(host, port);
});
}
function createInstance (awd, host, port) {

@@ -46,4 +62,4 @@ return Superstatic.createServer({

function preamble (host, port) {
console.log('Server started on port ' + port.toString());
console.log('');
console.log('server started on port ' + port.toString().bold.blue);
}

@@ -50,0 +66,0 @@

@@ -34,2 +34,7 @@ var path = require('path');

if (customRoute) {
var fullPath = internals.router._buildFilePath(customRoute);
if (!internals.router.isFile(fullPath)) customRoute = undefined;
}
return customRoute;

@@ -36,0 +41,0 @@ }

2

lib/server/middleware/directory_index.js

@@ -27,3 +27,3 @@ var path = require('path');

var fullPath = internals.router._buildRelativePath(path.join(filePath, 'index.html'));
var isFile = internals.router.isFile(fullPath)
var isFile = internals.router.isFile(fullPath);

@@ -30,0 +30,0 @@ if (isFile) {

@@ -30,3 +30,2 @@ var path = require('path');

}
// TODO: Get rid of those nested if statemens ^^^^

@@ -33,0 +32,0 @@ return file;

@@ -5,2 +5,7 @@ var SuperstaticServer = require('./server/superstatic_server');

exports.Server = SuperstaticServer;
exports.ignore = ignore;
exports.ignore = ignore;
process.on('uncaughtException', function (err) {
console.log(err);
process.exit(1);
});
{
"name": "superstatic",
"version": "0.4.2",
"version": "0.4.3",
"description": "Superstatic: a static file server for fancy apps",

@@ -33,3 +33,4 @@ "main": "lib/superstatic.js",

"hyperquest": "~0.1.8",
"lodash": "~2.2.1"
"lodash": "~2.2.1",
"chokidar": "~0.7.1"
},

@@ -36,0 +37,0 @@ "preferGlobal": "true",

@@ -25,3 +25,4 @@ var path = exports.path = require('path');

'app/test/**': 'superstatic.html',
'app/test**': 'superstatic.html'
'app/test**': 'superstatic.html',
'exists': 'does-not-exists.html'
},

@@ -28,0 +29,0 @@ config: {},

@@ -14,3 +14,3 @@ var setup = require('./_setup');

it('skips middleware if superstatic path is alread set', function () {
it('skips middleware if superstatic path is already set', function () {
this.req.superstatic = { path: '/superstatic.html' };

@@ -24,2 +24,8 @@ customRoute(this.req, this.res, this.next);

});
it('skips the middleware if custom route resolve file does not exist', function () {
this.req.url = '/exists';
this.req.ss.pathname = '/exists';
setup.skipsMiddleware.call(this, customRoute);
});
});

@@ -26,0 +32,0 @@

@@ -14,3 +14,3 @@ var setup = require('./_setup');

it('skips middleware if superstatic path is alread set', function () {
it('skips middleware if superstatic path is already set', function () {
this.req.superstatic = { path: '/superstatic.html' };

@@ -24,2 +24,8 @@ directoryIndex(this.req, this.res, this.next);

});
it('skips the middleware if index.html does not exists', function () {
this.req.url = '/no_index';
this.req.ss.pathname = '/no_index';
setup.skipsMiddleware.call(this, directoryIndex);
});
});

@@ -26,0 +32,0 @@

@@ -26,3 +26,3 @@ var setup = require('./_setup');

it('skips middleware if path is not a static file', function () {
this.req.url = '/superstatic';
this.req.ss.pathname = '/superstatic';
setup.skipsMiddleware.call(this, static);

@@ -33,3 +33,2 @@ });

it('sets the request path if the file is static and clean urls are not turned on', function () {
this.req.url = '/test.html';
this.req.ss.pathname = '/test.html';

@@ -45,3 +44,2 @@ this.req.ss.config.cwd = 'cwd';

it('sets the relative path', function () {
this.req.url = '/test.html';
this.req.ss.pathname = '/test.html';

@@ -48,0 +46,0 @@ this.req.ss.config.cwd = 'cwd';

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