strata
A modular, streaming HTTP server
Last updated 12 years ago by mjackson .
Repository · Original npm · Tarball · package.json
$ gnpm install strata 
SYNC missed versions from official npm registry.

build status

Strata is a streaming HTTP server for node.js that is patterned after time-honored web server design principles pioneered in the Python and Ruby communities, namely WSGI and Rack. Using Strata, developers can build highly performant web servers in a powerful, modular style that is easy to maintain and takes full advantage of the streaming capabilities and excellent I/O handling of node.js.

The core Strata distribution consists of four things:

  • A specification (see SPEC) for building applications and middleware
  • A library (see lib) with many useful utilities and middleware to aid developers in the common tasks of building applications that conform to the specification
  • An executable (see bin/strata) for running Strata applications from the command line
  • A user manual (see doc) that contains detailed documentation and code examples

Installation

Install Strata using npm:

$ npm install strata

You are also free to browse or download the source.

Usage

The simplest possible Strata app looks like this:

function app(env, callback) {
  callback(200, {}, "Hello world!");
}

require("strata").run(app);

As you can see from the example above, a Strata "app" is simply a JavaScript function that accepts two arguments: the server environment and a callback. The environment contains all sorts of information about the current request including headers, POST and session data, and much more. The callback is used to send the response. You can read much more about both the environment and the callback in the SPEC.

A slightly more complex application might look something like the following:

var strata = require('strata');

strata.use(strata.commonLogger); // Log requests to the console
strata.use(strata.file, '/path/to/public'); // Serve static files in /path/to/public
strata.use(strata.contentType, 'text/html'); // Default Content-Type to text/html
strata.use(strata.contentLength); // Set the Content-Length automatically
strata.use(strata.sessionCookie, { // Enable cookie-based sessions
  secret: 'session secret string' // Set a session secret for security
});

strata.get('/', function (env, callback) {
  callback(200, {}, 'Hello anonymous!');
});

strata.get('/:username', function (env, callback) {
  var route = env.route;
  callback(200, {}, 'Hello ' + route.username + '!');
});

// Start the server on port 3000
strata.run({ port: 3000 });

There are many more usage examples in the Strata user manual.

Documentation

The Strata user manual is designed to teach you how to get up and running with the framework as quickly as possible. Each chapter of the manual contains documentation about a certain feature of the framework and a code example.

The manual is written in such a way that the topics and examples discussed in higher numbered chapters build upon previous ones. Thus, it is recommended to start with lower numbered chapters when getting started and work your way up to higher ones.

The user manual refers to the SPEC in various places. This document is the canonical reference for the key building blocks of the framework including applications, callbacks, and the Strata environment.

Tests

The test directory contains a comprehensive suite of unit tests for Strata. Use mocha to run them all:

$ mocha test/*-test.js

Or run the tests for a specific module:

$ mocha test/utils-test.js

License

Copyright 2012 Michael Jackson

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 non-infringement. 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.

Acknowledgements

Strata was inspired by similar efforts in the Python and Ruby communities, namely WSGI and Rack. It borrows many code patterns from these libraries, as well as the JSGI project.

Strata's multipart parser is based on the fast parser in the node-formidable project written by Felix Geisendörfer. It is included in Strata under the terms of the MIT license.

My sincere thanks to the authors of each of these libraries for the excellent work they've done and graciously shared.

Current Tags

  • 0.20.1                                ...           latest (12 years ago)

53 Versions

  • 0.20.1                                ...           12 years ago
  • 0.20.0                                ...           12 years ago
  • 0.19.3                                ...           12 years ago
  • 0.19.2                                ...           12 years ago
  • 0.19.1                                ...           12 years ago
  • 0.19.0                                ...           12 years ago
  • 0.18.1                                ...           12 years ago
  • 0.18.0                                ...           12 years ago
  • 0.17.0                                ...           12 years ago
  • 0.16.1                                ...           12 years ago
  • 0.16.0                                ...           12 years ago
  • 0.15.1                                ...           13 years ago
  • 0.15.0                                ...           13 years ago
  • 0.14.0                                ...           13 years ago
  • 0.13.0                                ...           13 years ago
  • 0.12.5                                ...           13 years ago
  • 0.12.4                                ...           13 years ago
  • 0.12.3                                ...           13 years ago
  • 0.12.2                                ...           13 years ago
  • 0.12.1                                ...           13 years ago
  • 0.12.0                                ...           13 years ago
  • 0.11.0                                ...           13 years ago
  • 0.10.1                                ...           13 years ago
  • 0.10.0                                ...           13 years ago
  • 0.9.1                                ...           13 years ago
  • 0.4.3                                ...           13 years ago
  • 0.4.4                                ...           13 years ago
  • 0.4.5                                ...           13 years ago
  • 0.5.0                                ...           13 years ago
  • 0.5.1                                ...           13 years ago
  • 0.5.2                                ...           13 years ago
  • 0.5.3                                ...           13 years ago
  • 0.5.4                                ...           13 years ago
  • 0.5.5                                ...           13 years ago
  • 0.5.6                                ...           13 years ago
  • 0.5.7                                ...           13 years ago
  • 0.5.8                                ...           13 years ago
  • 0.5.9                                ...           13 years ago
  • 0.5.10                                ...           13 years ago
  • 0.5.12                                ...           13 years ago
  • 0.5.13                                ...           13 years ago
  • 0.5.14                                ...           13 years ago
  • 0.6.0                                ...           13 years ago
  • 0.6.1                                ...           13 years ago
  • 0.0.0                                ...           13 years ago
  • 0.4.1                                ...           13 years ago
  • 0.4.2                                ...           13 years ago
  • 0.4.0                                ...           13 years ago
  • 0.9.0                                ...           13 years ago
  • 0.8.2                                ...           13 years ago
  • 0.8.1                                ...           13 years ago
  • 0.8.0                                ...           13 years ago
  • 0.7.0                                ...           13 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |