Skip to content
Newer
Older
100644 88 lines (55 sloc) 2.57 KB
986371e @jsievert initial import
jsievert authored Jul 18, 2011
1 # Bricks.js
2
24f7dff @jsievert tweaks before going live
jsievert authored Jul 31, 2011
3 An advanced modular Web Framework built on Node.
986371e @jsievert initial import
jsievert authored Jul 19, 2011
4
3c60955 @JerrySievert Update README.md
authored Nov 18, 2011
5 [![Build Status](https://secure.travis-ci.org/JerrySievert/bricks.png)](http://travis-ci.org/JerrySievert/bricks)
6
24f7dff @jsievert tweaks before going live
jsievert authored Aug 1, 2011
7 ## Installing
8
9 $ npm install bricks
986371e @jsievert initial import
jsievert authored Jul 19, 2011
10
11 ## Super Basic Usage
12
a13ceed @jsievert getting ready for release
jsievert authored Jul 25, 2011
13 Change directories into the directory that you wish to server files from:
986371e @jsievert initial import
jsievert authored Jul 19, 2011
14
15 $ bricks
16
17 Usage:
18
19 Usage: bricks [--help] [--port port] [--ipaddr ipaddr] [--path path] [--log log]
20 --port port [default 8080]
21 --ipaddr ipaddr [default 0.0.0.0]
22 --path path [default "."]
23 --log log [default none]
24
25
26 ## Basic Usage
a13ceed @jsievert getting ready for release
jsievert authored Jul 26, 2011
27
986371e @jsievert initial import
jsievert authored Jul 19, 2011
28 var bricks = require('bricks');
29 var appServer = new bricks.appserver();
30
24f7dff @jsievert tweaks before going live
jsievert authored Aug 1, 2011
31 appServer.addRoute("/static/.+", appServer.plugins.filehandler, { basedir: "./static" });
a13ceed @jsievert getting ready for release
jsievert authored Jul 26, 2011
32 appServer.addRoute(".+", appServer.plugins.fourohfour);
986371e @jsievert initial import
jsievert authored Jul 19, 2011
33 var server appServer.createServer();
34
35 server.listen(3000);
36
a13ceed @jsievert getting ready for release
jsievert authored Jul 26, 2011
37 ### Routes
38
39 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.
40
41 The `router` simplified:
42
43 if (typeof(route) === 'function') {
44 var match = route(path);
45 if (match) {
46 return true;
47 }
48 } else {
49 if ((typeof(route) === 'string') && path.match(route)) {
50 return true;
51 }
52 }
53
54 return false;
55
56 ## Built-in Plugins
57
58 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.
59
60 ### plugins.filehandler
61
62 Default static file handler. This file handler is for basic functionality, it does not cache.
63
64 {
65 basedir: '/path/to/files/' // default '.'
66 }
67
68 ### plugins.fourohfour
69
70 Default 404 handler. By design, this handler simply sets the 404 status code and writes `404 Error` to the requesting browser.
71
24f7dff @jsievert tweaks before going live
jsievert authored Aug 1, 2011
72 ### plugins.redirect
a13ceed @jsievert getting ready for release
jsievert authored Jul 26, 2011
73
24f7dff @jsievert tweaks before going live
jsievert authored Aug 1, 2011
74 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).
a13ceed @jsievert getting ready for release
jsievert authored Jul 26, 2011
75
76 {
77 routes: [
24f7dff @jsievert tweaks before going live
jsievert authored Aug 1, 2011
78 { path: "^/foo$", url: "http://foo.com/foo", permanent: true },
a13ceed @jsievert getting ready for release
jsievert authored Jul 26, 2011
79 { path: new RegExp(/\/bar\/.+/), url: "http://bar.com/bar" }
80 ]
81 }
82
83
84 ## Advanced Stuff
85
24f7dff @jsievert tweaks before going live
jsievert authored Aug 1, 2011
86 `Bricks` is a fully baked web application server, but a README can only contain so much information.
36b08a1 @jsievert added error handling and session handling
jsievert authored Jul 23, 2011
87
a13ceed @jsievert getting ready for release
jsievert authored Jul 26, 2011
88 For more information and documentation visit [bricksjs.com](http://bricksjs.com/).
Something went wrong with that request. Please try again.