JSPM

  • Created
  • Published
  • Downloads 284973
  • Score
    100M100P100Q14546F

A simple static file server middleware that works with both Express and Flatiron

Package Exports

  • ecstatic

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ecstatic) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Ecstatic

A simple static file server middleware that works with both Express and Flatiron

  • simple directory listings
  • show index.html files at directory roots when they exist
  • use it with a raw http server, connect/express, or flatiron/union

Examples:

express

var express = require('express');
var ecstatic = require('../')(__dirname + '/public');

var app = express.createServer();
app.use(ecstatic);
app.listen(8080);

console.log('Listening on :8080');

union

var union = require('union');
var ecstatic = require('../')(__dirname + '/public');

union.createServer({
  before: [
    ecstatic
  ]
}).listen(8080);

console.log('Listening on :8080');

API:

ecstatic(folder);

Pass ecstatic a folder, and it will return your middleware!

middleware(req, res, next);

This works more or less as you'd expect.

Tests:

npm test

Contributing:

This project's implementation is pretty much g2g (thanks @substack) but currently does not work in Union. This is because Union's response piping is currently broken.

Once Union is fixed, this will work there as well.

License:

MIT/X11.