Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 39 lines (26 sloc) 3.346 kb
f3f424b @hassox Changes to chain and adds a readme
authored
1 h1. Chain Spec
4eb769e @hassox Adds the start of a SPEC file
authored
2
9973894 Updates the documentation with what the next version of chain will be
Daniel Neighman authored
3 Chain is a simple specification and framework for building web applications in the node.js engine. node.js is deliberately simple and does not attempt to over specify how an application must function logically other than the mechanism it should use. Chain links multiple application components, hereafter referred to as "links" together by giving a standard way to pass requests between each other.
4eb769e @hassox Adds the start of a SPEC file
authored
4
9973894 Updates the documentation with what the next version of chain will be
Daniel Neighman authored
5 Chain specifies a default chain structure for links, based on each link containing a reference to the next link, 'nextLink', so that the environment knows where to go next if required. A link in a chain is a single instance of an object or object type.
4eb769e @hassox Adds the start of a SPEC file
authored
6
52ed553 Initial stab at functionality
Daniel Neighman authored
7 h2. Links
4eb769e @hassox Adds the start of a SPEC file
authored
8
0032d2f @lachlanhardy fixing typos and punctuation
lachlanhardy authored
9 A Chain compatible application has the following characteristics
4eb769e @hassox Adds the start of a SPEC file
authored
10
9973894 Updates the documentation with what the next version of chain will be
Daniel Neighman authored
11 * Each link MUST provide an onRequest method that recieves one argument, the chain environment.
12 * The Chain.Environment instance MUST be passed on. An link may not receive one instance of the Chain.Environment and pass a different instance to the next link
13 * Transitions between links must not block. The env.next() method must be non-blocking
14 * If an application is finished but does not respond to the client directly, it should call the done() method on the environment instance before finsihing the method.
52ed553 Initial stab at functionality
Daniel Neighman authored
15 * The context of the onRequest method is the link on which it is called.
4eb769e @hassox Adds the start of a SPEC file
authored
16
f3f424b @hassox Changes to chain and adds a readme
authored
17 h2. Chain.Environment
4eb769e @hassox Adds the start of a SPEC file
authored
18
f3f424b @hassox Changes to chain and adds a readme
authored
19 The Chain.Environment instance is the common thread throughout the request. The Chain.Environment MUST include the following with the following meanings. (Chain.Environment instance is called _env_ in the following list)
4eb769e @hassox Adds the start of a SPEC file
authored
20
21 * env.request - The raw server request object from node.js
0032d2f @lachlanhardy fixing typos and punctuation
lachlanhardy authored
22 * env.response - The raw server response object from node.js
634a152 @hassox Makes some improvements and updates the spec
authored
23 * env.onDone - Add a callback to run after the request is considered "done" by an application. These callbacks _may_ run. See further for more information
c546f0b @hassox Updates with an updated spec. Embraching async
authored
24 * env.response.beforeHeaders - Add a callback to run just before the headers are sent to the client. This can be used to encode the session into the cookie and other such functionality. Optionally return an array with the arguments for response.sendHeader
25 * env.response.beforeSendBody - Add a filter to the send body method. By supplying a function that accepts the same arguments as response.sendBody you can modify the chunck prior to it being sent to the client. These can be queued for multi stage filtering. To change the arguments, return an array of the arguments to pass to sendBody
c44c971 @hassox Quick Spec update
authored
26 * env.done - The trigger to fire the next onDone callback. Each callback, if it has not completed the request, should call env.done() to run the next onDone callback in the queue.
9973894 Updates the documentation with what the next version of chain will be
Daniel Neighman authored
27 * env.next - This function must move to the next link in the chain, or the specified link if one is given. It must be non-blocking
c546f0b @hassox Updates with an updated spec. Embraching async
authored
28 * env.response.headers - A buffer for response headers
29 * env.response.status - A buffer for the response status
30 * env.response.body - A buffer for the response body
4eb769e @hassox Adds the start of a SPEC file
authored
31
f3f424b @hassox Changes to chain and adds a readme
authored
32 h2. Chain Events
4eb769e @hassox Adds the start of a SPEC file
authored
33
f3f424b @hassox Changes to chain and adds a readme
authored
34 Chain is an event emitter and will emit events as a central message dispatch. Chain will emit events on various stages of the build. The event should be a generic event type followed by a specified type. Any link can also have Chain broadcast events
4eb769e @hassox Adds the start of a SPEC file
authored
35
f3f424b @hassox Changes to chain and adds a readme
authored
36 Chain emits the following Events.
4eb769e @hassox Adds the start of a SPEC file
authored
37
38 * "start", "http" - emitted when the http server starts.
Something went wrong with that request. Please try again.