Bricks.js is an advanced modular web framework built on Node.js. Bricks.js is very flexible.
It can be used as a standalone static webserver, a basic routing framework,
a multi-level apache-like routing system, as well as being modular enough to have the
capability to completely switch out its routing engine.
$ npm install bricks
https://github.com/JerrySievert/bricks
Change directories into the directory that you wish to server files from:
$ bricks
Usage:
Usage: bricks [--help] [--port port] [--ipaddr ipaddr] [--path path] [--log log]
--port port [default 8080]
--ipaddr ipaddr [default 0.0.0.0]
--path path [default "."]
--log log [default none]
var bricks = require('bricks');
var appServer = new bricks.appserver();
appServer.addRoute("/static/.+", appServer.plugins.filehandler, { basedir: "./static" });
appServer.addRoute(".+", appServer.plugins.fourohfour);
var server = appServer.createServer();
server.listen(3000);
Routing in bricks is based on String matches and truth values. A
regular expression may be passed, as well as a function
that can determine whether or not the route should be executed.
The routersimplified:
if (typeof(route) === 'function') {
var match = route(path);
if (match) {
return true;
}
} else {
if ((typeof(route) === 'string') && path.match(route)) {
return true;
}
}
return false;
Bricks contains four levels of routes. Each of these routing levels
can be executed separately and with different sets of rules. This allows for great flexibility
when dealing with request manipulation, content, final content
manipulation, and accounting.
There are plugins that are built-in to bricks that cover basic usage.
These plugins are light-weight and loaded as part of the application server. The plugins
accept various options for configuration.
Bricks has a robust error handling system based on events. This
allows for errors to be handled in a very flexible manner.