Posted on Monday, October 20 2014 by Ionică Bizău
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.
The following things were made in the new version:
readFile
method (using file streams)sendRes
methodEventEmitter
). Now we can listening on errors using server.on("serverError", foo)
.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
// 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.