Ionică Bizău

[email protected] is released

Statique is a Node.JS static server module that has built-in routing and caching stuff. The new version comes with a lot of fixes and features.

Changelog

The following things were made in the new version:

  • Improved readFile method (using file streams)
  • Buffer support for sendRes method
  • Better crash handling
  • Added tests
  • Send 404 error when requests on directories come
  • Updated docs
  • Simplified mime type setting
  • Fixed stats magic variable (bug)
  • Emit error events (the instance of Statique is an instance of EventEmitter). Now we can listening on errors using server.on("serverError", foo).

Download

You can download the library via git, from GitHub, or via npm:

# From GitHub
$ git clone [email protected]:IonicaBizau/node-statique.git
# From NPM
$ npm install statique

Example

// Dependencies
var Statique = require("statique")
  , Http = require('http')
  ;

// Create *Le Statique* server
var server = new Statique({
    root: __dirname + "/public"
  , cache: 36000
}).setRoutes({
    "/": "/html/index.html"
});

// Create server
Http.createServer(server.serve).listen(8000);

// Output
console.log("Listening on 8000.");

Have feedback on this article? Let @IonicaBizau know on Twitter.

Have any questions? Feel free to ping me on Twitter.