stone

A simple web server for hosting single page applications.

npm install stone
3 downloads in the last month

Work in progress.

Stone

Build Status

Stone is a simple web server for hosting of single page applications. If a requested file does not exist, Static returns the indexDocument (e.g. ‘index.html’ file).

Example

var Server = new Stone({
  indexDocument: 'index.html',
  hostname: '127.0.0.1',
  port: 8000,
  dir: './public/'
});

Server.start();

Features

  • Supports gzip and deflate out of the box
  • Has an in-memory file cache
  • Automatically updates the cache when a file changes
  • JavaScript API
  • Ability to add your custom headers
  • Uses native modules like crypto and zlib
  • AMD compatible, you can load it via RequireJS
  • Understands conditional GET and HEAD requests

*Note: It's very important to understand that this is not a regular web server. Stone serves just static files and supports only GET, HEAD and OPTIONS methods.*

Contents

Download

To install Stone, use NPM.

$ npm install -g stone

Documentation

Methods

Objects

Options

  • indexDocument
  • dir
  • port
  • hostname
  • headers
  • redirects

Example

var options = {
  indexDocument: 'index.html',
  hostname: '127.0.0.1',
  port: 8000,
  dir: './public/',
  headers: {
    'X-Env': 'development'
  },
  redirects: [
    {
      host: /^(.*)\.google.com$/,
      location: 'google.com'
    }
  ]
};

var Server = new Stone(options);

Server.start();

Tests

$ npm test

Versioning

Releases will be numbered with the following format.

<major>.<minor>.<patch>

And constructed with the following guidelines.

  • Breaking backwards compatibility bumps the major
  • New additions without breaking backwards compatibility bumps the minor
  • Bug fixes and misc changes bump the patch

For more information on semantic versioning, please visit http://semver.org/.

Contributors

The following are the major contributors of Stone (in random order).

License

(The MIT License)

Copyright (c) 2011 František Hába <hello@frantisekhaba.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you