Comparing version 0.0.1 to 0.1.0
@@ -5,6 +5,5 @@ var express = require('express'); | ||
var app = express.createServer(); | ||
app.use(ecstatic(__dirname + '/public')); | ||
app.use(ecstatic.showDir(__dirname + '/public')); | ||
app.use(ecstatic(__dirname + '/public', { showdir : true })); | ||
app.listen(8080); | ||
console.log('Listening on :8080'); |
@@ -6,4 +6,3 @@ var union = require('union'); | ||
before: [ | ||
ecstatic(__dirname + '/public'), | ||
ecstatic.showDir(__dirname + '/public') | ||
ecstatic(__dirname + '/public') | ||
] | ||
@@ -10,0 +9,0 @@ }).listen(8080); |
@@ -10,10 +10,14 @@ var path = require('path'), | ||
status = require('./ecstatic/status-handlers'), | ||
etag = require('./ecstatic/etag'); | ||
etag = require('./ecstatic/etag'), | ||
optsParser = require('./ecstatic/opts'); | ||
var ecstatic = module.exports = function (dir, opts) { | ||
var ecstatic = module.exports = function (dir, options) { | ||
var root = path.resolve(dir) + '/', | ||
cache = (opts && opts.cache) || 3600; // cache-ing time in seconds. | ||
opts = optsParser(options), | ||
cache = opts.cache, | ||
autoIndex = opts.autoIndex; | ||
return function middleware (req, res, next) { | ||
// Figure out the path for the file from the given url | ||
var parsed = url.parse(req.url), | ||
@@ -43,3 +47,6 @@ pathname = decodeURI(parsed.pathname), | ||
else if (stat.isDirectory()) { | ||
var handler = (typeof next === 'function') | ||
// retry for the index.html, if that's not there fall back to the | ||
// directory view (if activated) | ||
var handler = (typeof next === 'function' && !autoIndex) | ||
? next | ||
@@ -46,0 +53,0 @@ : function () { |
@@ -5,3 +5,3 @@ { | ||
"description": "A simple static file server middleware that works with both Express and Flatiron", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/jesusabdullah/node-ecstatic", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -43,6 +43,10 @@ # Ecstatic | ||
## ecstatic(folder); | ||
## ecstatic(folder, opts={}); | ||
Pass ecstatic a folder, and it will return your middleware! | ||
Turn on cache-control with `opts.cache`, in seconds. | ||
Turn on directory listings from `ecstatic.showdir` with `opts.showdir === true`. | ||
### middleware(req, res, next); | ||
@@ -49,0 +53,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
208591
20
338
70
1