Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 84 lines (50 sloc) 4.121 kB
cead1dc @olegp first commit
authored
1 # Common Node
2
3 This package implements a number of [CommonJS](http://www.commonjs.org) proposals on top of [Node.js](http://nodejs.org) using [node-fibers](https://github.com/laverdet/node-fibers). Fibers are used to emulate multi-threading within a single process, allowing one to use a synchronous programming style and as a result:
4
5 * write fast CRUD webapps that run on Node.js without callback spaghetti
6 * run webapps, middleware and libraries written for [RingoJS](http://ringojs.org) and [other implementations](http://wiki.commonjs.org/wiki/Implementations)
7 * mix & match synchronous/asynchronous styles and use the best tool for the job by writing maintainable business logic in a synchronous manner
8 * write concise, legible shell scripts
9
10 The following modules are implemented:
11
12 * assert - [Unit Testing/1.0](http://wiki.commonjs.org/wiki/Unit_Testing/1.0) & a suite for running tests
13 * system - [System/1.0](http://wiki.commonjs.org/wiki/System/1.0) & methods for managing threads and child processes
14 * binary - [Binary/B](http://wiki.commonjs.org/wiki/Binary/B)
15 * io - [IO/A](http://wiki.commonjs.org/wiki/IO/A), including a `ByteArray` backed `MemoryStream`
16 * fs - [Filesystem/A](http://wiki.commonjs.org/wiki/Filesystem/A) (partial implementation)
17 * jsgi - [JSGI 0.3](http://wiki.commonjs.org/wiki/JSGI/Level0/A/Draft2)
18 * httpclient - [HTTP Client/A](http://wiki.commonjs.org/wiki/HTTP_Client/A)
19
20 ### Installation
21
22 If you don't already have it, install the [Node Package Manager](http://npmjs.org):
23
24 curl http://npmjs.org/install.sh | sh
25
26 Using `npm` install a global copy of `node-fibers` as root:
27
28 sudo npm install -g fibers
29
30 To install the latest version of `common-node`, clone the repository (an npm package will be made available once we have a stable release):
31
32 git clone git://github.com/olegp/common-node.git
33
34 Change to the package directory and run the "Hello World" example server:
35
36 cd common-node; node-sync examples/hello.js
37
38 To test that it's working as expected, make an HTTP request from another prompt:
39
40 curl http://localhost:8080/
41
42 To install `common-node` as a global package:
43
44 sudo npm -g install .
45
46 ### Examples
47
c17f26e @olegp fixed broken links
authored
48 A number of examples are available in [common-node/examples](https://github.com/olegp/common-node/tree/master/examples):
cead1dc @olegp first commit
authored
49
50 * `hello.js` - Hello World webapp using JSGI to return a simple text response
51 * `static.js` - streams a static file as a response
52 * `http.js` - makes an HTTP request to another server and returns the result in the response
53 * `sleep.js` - sleeps for one second before returning a response
54 * `spawn.js` - spawns a new fiber which prints to stdout ten seconds after processing a request
55
c17f26e @olegp fixed broken links
authored
56 For more usage examples, please refer to the tests in the [common-node/test](https://github.com/olegp/common-node/tree/master/test) directory.
cead1dc @olegp first commit
authored
57
58 ### Documentation
59
60 Documentation is work in progress - for the time being it is recommended that you use the [RingoJS documentation](http://ringojs.org/api/master/) or the proposal wiki pages linked to in the introduction above.
61
62 ### Tests
63
64 To run the unit tests execute the following command:
65
66 node-sync test/all.js
67
68 You can also run individual tests, for example:
69
70 node-sync test/io.js
71
72 ### Benchmarks
73
c17f26e @olegp fixed broken links
authored
74 Although `common-node` is optimized for developer efficiency rather than performance, a number of benchmarks are included in [common-node/benchmarks](https://github.com/olegp/common-node/tree/master/benchmarks). A `common-node` version and an asynchronous version using Connect of each benchmark are provided. Results of these benchmarks will be included below.
cead1dc @olegp first commit
authored
75
76 * hello
77 * static
78
79 ### Acknowledgements
80
81 * Hannes Wallnoefer and others from [RingoJS](http://ringojs.org) - this project uses a number of its tests & the Ringo code was used as a starting point for some modules
82 * Kris Kowal, Tom Robinson, Isaac Schlueter for [Narwhal](http://narwhaljs.org/) - this project used a number of its modules as a starting point and some methods in e.g. Binary have been copied as is
83 * everybody on the [CommonJS](http://groups.google.com/group/commonjs) mailing list
Something went wrong with that request. Please try again.