Giter VIP home page Giter VIP logo

node-ecstatic's Introduction

Ecstatic

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

  • Built-in simple directory listings
  • Shows index.html files at directory roots when they exist
  • Use it with a raw http server, express/connect, or flatiron/union!

Examples:

express

var express = require('express');
var ecstatic = require('ecstatic');

var app = express.createServer();
app.use(ecstatic(__dirname + '/public'));
app.listen(8080);

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

union

var union = require('union');
var ecstatic = require('ecstatic');

union.createServer({
  before: [
    ecstatic(__dirname + '/public'),
  ]
}).listen(8080);

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

flatiron

var union = require('union');
var flatiron = require('flatiron');
var ecstatic = require('ecstatic');

app = new flatiron.App();
app.use(flatiron.plugins.http);

app.http.before = [
  ecstatic(__dirname + '/public')
];

app.start(8080);

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

API:

ecstatic(folder, opts={});

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

Turn on cache-control with opts.cache, in seconds.

Turn off directory listings with opts.autoIndex === false.

middleware(req, res, next);

This works more or less as you'd expect.

ecstatic.showDir(folder);

This returns another middleware which will attempt to show a directory view. Turning on auto-indexing is roughly equivalent to adding this middleware after an ecstatic middleware with autoindexing disabled.

Tests:

npm test

License:

MIT/X11.

node-ecstatic's People

Contributors

jfhbrook avatar colinf avatar coderarity avatar mmalecki avatar amelon avatar

Watchers

Charlie Robbins avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.