Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bricks

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bricks

Bricks Application Server

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

Bricks.js

An advanced modular Web Framework built on Node.

Build Status

Installing

$ npm install bricks

Super Basic Usage

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]

Basic Usage

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);

Routes

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 router simplified:

if (typeof(route) === 'function') {
    var match = route(path);
    if (match) {
        return true;
    }
} else {
    if ((typeof(route) === 'string') && path.match(route)) {
        return true;
    }
}

return false;

Built-in Plugins

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. These plugins accept various options for configuration.

plugins.filehandler

Default static file handler. This file handler is for basic functionality, it does not cache.

{
  basedir: '/path/to/files/'  // default '.'
}

plugins.fourohfour

Default 404 handler. By design, this handler simply sets the 404 status code and writes 404 Error to the requesting browser.

plugins.redirect

The default redirect handler deals with both temporary and permanent redirects. As with routes, the path can be a String, a RegExp, or a function. Redirects are sent as temporary redirects (307) unless denoted as permanent (301).

{
  routes: [
    { path: "^/foo$", url: "http://foo.com/foo", permanent: true },
    { path: new RegExp(/\/bar\/.+/), url: "http://bar.com/bar" }
  ]
}

Advanced Stuff

Bricks is a fully baked web application server, but a README can only contain so much information.

For more information and documentation visit bricksjs.com.

Keywords

FAQs

Package last updated on 10 Feb 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc