The first project for NWEN406.
This exists as a node in a relay group, where each node takes a JSON string and alters its value before passing the message on.
Uses libraries:
- request
- express
- crypto (md5)
- fs (sync)
- forever
Listens on port 3000.
##RESTful Interface: GET: /alive check if server is alive
GET: /log prints the current logs (supplied by forever)
GET: /api prints the latest files processed
POST: /api input for the JSON to be manipulated. Returns HTTP 202 Accepted. Accepts JSON of the structure:
{
value: 'string to be altered',
count: 0, /* number of nodes successfully visited */
audit: {}, /* visited nodes */
order: [], /* queue of addresses to be visited */
}
Where audit is an object inserted by each hop, of the form:
{
input: 'string to be altered',
output: 'the altered string',
index: 0, /* this nodes hop count */
time: "Day, ... GMT", /* time of receipt of input */
}
The value string received is first hashed (MD5). This hashed value is then used to determine four positions from within Pride And Prejudice, and reads up to 5 words from that point. The first 50 characters of this output is then sent as the next value.
Other book options are available in text, but must be set in-code.