Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

changed whitespace indention from 4 to 2 spaces

  • Loading branch information...
commit d1d24a3d09b93e185a7f98e42b9ecc37e84c62f3 1 parent bee7a9a
authored April 27, 2012
73  Readme.md
Source Rendered
@@ -13,51 +13,10 @@
13 13
 
14 14
 ## Installation:
15 15
 
16  
-  To just use the server do:
17  
-
18 16
     $ npm install
19 17
 
20 18
 
21 19
 
22  
-  If you want to create a new app on top of sayndo, create
23  
-  the app doing this:
24  
-
25  
-    $ sh node_modules/sayndo/bin/create-app.sh
26  
-
27  
-
28  
-
29  
-  Finally your app should look something like that:
30  
-
31  
-    your app -
32  
-             |- app -
33  
-             |      |- controller
34  
-             |      |- model
35  
-             |      |- view
36  
-             |
37  
-             |- config -
38  
-             |         |- app_locals.js
39  
-             |         |- config.js
40  
-             |
41  
-             |- node_modules -
42  
-             |               |- sayndo
43  
-             |
44  
-             |- public -
45  
-             |         |- image
46  
-             |         |- javascript
47  
-             |         |- stylesheet
48  
-             |         |- view -
49  
-             |                 | - layout -
50  
-             |                 |          |- default_layout.html
51  
-             |                 |          |- test_layout.html
52  
-             |                 |
53  
-             |                 | - index.html
54  
-             |
55  
-             |- test
56  
-             |- package.json
57  
-             |- server.js
58  
-
59  
-
60  
-
61 20
   For session support the redis server is required. The redis
62 21
   client for node gets installed on "npm install", but you have
63 22
   to install the redis server by yourself on your mashine. Linux
@@ -71,13 +30,29 @@
71 30
 
72 31
 ## Run server:
73 32
 
74  
-  Start the server with default settings on 127.0.0.1:3000.
  33
+  Start the server with default settings on 127.0.0.1:3000
  34
+
  35
+    $ node app.js
75 36
 
76  
-    $ node server.js
  37
+  Start the server with custom settings on <host>:<port>
77 38
 
78  
-  Start the server with custom settings on [host]:[port].
  39
+    $ node app.js <host> <port>
79 40
 
80  
-    $ node server.js [host] [port]
  41
+
  42
+
  43
+## Configuration:
  44
+
  45
+  You have to structure your directories like this:
  46
+
  47
+    app -
  48
+        |- config -
  49
+        |         |- config.js
  50
+        |         |- app_locals.js
  51
+        |
  52
+        |- node_modules
  53
+
  54
+  For detailed information see example/config/config.js.
  55
+  It´s well commented.
81 56
 
82 57
 
83 58
 
@@ -90,7 +65,7 @@
90 65
     var app = require('sayndo');
91 66
 
92 67
     app.guest.GET['/'] = function(req, res) {
93  
-        res.view.render('/index.html', {msg: 'hello world'});
  68
+        res.render('/index.html', {msg: 'hello world'});
94 69
     };
95 70
 
96 71
 
@@ -369,3 +344,9 @@
369 344
     concurrency             546           804      |        207           423
370 345
     longest request       22.05          9.32      |       9.13          9.54
371 346
 
  347
+
  348
+
  349
+## Questions and notices:
  350
+
  351
+  Send me a message on github.
  352
+
26  example/cookie.js
@@ -7,22 +7,22 @@ var app = require('sayndo');
14  example/dummy/config/app_locals.js
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  *
3  
- * Server site app local module.
  3
+ * App locale module.
4 4
  *
5 5
  */
6 6
 
@@ -8,12 +8,12 @@
8 8
  * Module variables.
9 9
  */
10 10
 var appLocals = {
11  
-    /*
12  
-     *
13  
-     */
14  
-    title: function(req, res) {
15  
-        return 'Sayndo';
16  
-    }
  11
+  /*
  12
+   *
  13
+   */
  14
+  title: function(req, res) {
  15
+    return 'Sayndo';
  16
+  }
17 17
 };
18 18
 
19 19
 module.exports = appLocals;
320  example/dummy/config/config.js
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  *
3  
- * Server site condig module.
  3
+ * Config module.
4 4
  *
5 5
  */
6 6
 
@@ -10,168 +10,168 @@
10 10
 var cwd = process.cwd();
11 11
 
12 12
 var config = {
13  
-    /*
14  
-     * Current working directory.
15  
-     */
16  
-    cwd: cwd,
17  
-
18  
-    /*
19  
-     * String of absolute path to all app folder and files.
20  
-     */
21  
-    publicPath: cwd + '/public',
22  
-
23  
-    /*
24  
-     * String of absolute path to all vendors.
25  
-     */
26  
-    testPath: cwd + '/test/client',
27  
-
28  
-    /*
29  
-     * String of absolute path to all views.
30  
-     */
31  
-    viewPath: cwd + '/public/view',
32  
-
33  
-    /*
34  
-     * String of absoulte path to the layout.
35  
-     */
36  
-    layoutPath: {
37  
-        default: cwd + '/public/view/layout/default_layout.html',
38  
-        test: cwd + '/public/view/layout/test_layout.html'
  13
+  /*
  14
+   * Current working directory.
  15
+   */
  16
+  cwd: cwd,
  17
+
  18
+  /*
  19
+   * String of absolute path to all app folder and files.
  20
+   */
  21
+  publicPath: cwd + '/public',
  22
+
  23
+  /*
  24
+   * String of absolute path to all vendors.
  25
+   */
  26
+  testPath: cwd + '/test/client',
  27
+
  28
+  /*
  29
+   * String of absolute path to all views.
  30
+   */
  31
+  viewPath: cwd + '/public/view',
  32
+
  33
+  /*
  34
+   * String of absoulte path to the layout.
  35
+   */
  36
+  layoutPath: {
  37
+    default: cwd + '/public/view/layout/default_layout.html',
  38
+    test: cwd + '/public/view/layout/test_layout.html'
  39
+  },
  40
+
  41
+  /*
  42
+   * Array, containing objects, representing external sources.
  43
+   *
  44
+   * E.g. it is not necessary to cache the socket.io client
  45
+   * script manually, but to use a external source like that
  46
+   * you could include the following object to the depenedencies
  47
+   * array.
  48
+   *
  49
+   *   {
  50
+   *     reqUrl: '/socket.io/socket.io.js',
  51
+   *     sourcePath: cwd + '/node_modules/socket.io/node_modules/socket.io-client/lib/socket.io-client.js'
  52
+   *   }
  53
+   *
  54
+   */
  55
+  dependencies: [],
  56
+
  57
+  /*
  58
+   * Session lifetime in minutes.
  59
+   */
  60
+  ttl: 60 * 24 * 365, // 1 year
  61
+
  62
+  /*
  63
+   * Array of request methods the server have to support.
  64
+   * This request methods are also supported for the view
  65
+   * route functions.
  66
+   */
  67
+  requestMethods: ['GET', 'POST'],
  68
+
  69
+  /*
  70
+   * String of default auth type, to fallback if no other is
  71
+   * supported in the view route functions.
  72
+   */
  73
+  defaultAuthType: 'guest',
  74
+
  75
+  /*
  76
+   * Array of auth types the server have to support. This
  77
+   * auth types are also supported for the view route
  78
+   * functions.
  79
+   */
  80
+  authTypes: ['guest', 'user', 'mod', 'admin'],
  81
+
  82
+  /*
  83
+   * Session cookie name of the app. Just a little piece of suggar.
  84
+   */
  85
+  sessionCookie: 'session',
  86
+
  87
+  /*
  88
+   * String of random character to create save hashes. The
  89
+   * security salt is a dependency for the session support.
  90
+   */
  91
+  securitySalt: 'jsdhh2hi3d237d89JKH78jhHIPP=00JKJnjn',
  92
+
  93
+  /*
  94
+   *
  95
+   */
  96
+  mysql: {
  97
+    user: 'user',
  98
+    password: 'password',
  99
+    database: 'database'
  100
+  },
  101
+
  102
+  /*
  103
+   * Array containing strings to ignore unwanted files and
  104
+   * directories. That prevents caching of unnecessary files.
  105
+   */
  106
+  cacheIgnore: [],
  107
+
  108
+  /*
  109
+   * Object literal of file types the server have to support.
  110
+   * Indexed by the file extension (e.g. 'js' for .js files).
  111
+   *
  112
+   * Containing:
  113
+   *
  114
+   *  - 'encoding' (e.g. 'utf8').
  115
+   *  - 'contentType' (e.g. 'text/javascript').
  116
+   *  - 'httpHeader' (e.g. {"Content-Type": "text/javascript"}).
  117
+   */
  118
+  fileTypes: {
  119
+    'js': {
  120
+      encoding: 'utf8',
  121
+      contentType: 'text/javascript',
  122
+      header: {'Content-Type': 'text/javascript'},
  123
+     },
  124
+    'ico': {
  125
+      encoding: 'binary',
  126
+      contentType: 'image/x-icon',
  127
+      header: {'Content-Type': 'image/x-icon'},
39 128
     },
40  
-
41  
-    /*
42  
-     * Array, containing objects, representing external sources.
43  
-     *
44  
-     * E.g. it is not necessary to cache the socket.io client
45  
-     * script manually, but to use a external source like that
46  
-     * you could include the following object to the depenedencies
47  
-     * array.
48  
-     *
49  
-     *   {
50  
-     *       reqUrl: '/socket.io/socket.io.js',
51  
-     *       sourcePath: cwd + '/node_modules/socket.io/node_modules/socket.io-client/lib/socket.io-client.js'
52  
-     *   }
53  
-     *
54  
-     */
55  
-    dependencies: [],
56  
-
57  
-    /*
58  
-     * Session lifetime in minutes.
59  
-     */
60  
-    ttl: 60 * 24 * 365, // 1 year
61  
-
62  
-    /*
63  
-     * Array of request methods the server have to support.
64  
-     * This request methods are also supported for the view
65  
-     * route functions.
66  
-     */
67  
-    requestMethods: ['GET', 'POST'],
68  
-
69  
-    /*
70  
-     * String of default auth type, to fallback if no other is
71  
-     * supported in the view route functions.
72  
-     */
73  
-    defaultAuthType: 'guest',
74  
-
75  
-    /*
76  
-     * Array of auth types the server have to support. This
77  
-     * auth types are also supported for the view route
78  
-     * functions.
79  
-     */
80  
-    authTypes: ['guest', 'user', 'mod', 'admin'],
81  
-
82  
-    /*
83  
-     * Session cookie name of the app. Just a little piece of suggar.
84  
-     */
85  
-    sessionCookie: 'session',
86  
-
87  
-    /*
88  
-     * String of random character to create save hashes. The
89  
-     * security salt is a dependency for the session support.
90  
-     */
91  
-    securitySalt: 'jsdhh2hi3d237d89JKH78jhHIPP=00JKJnjn',
92  
-
93  
-    /*
94  
-     *
95  
-     */
96  
-    mysql: {
97  
-        user: 'user',
98  
-        password: 'password',
99  
-        database: 'database'
  129
+    'ttf': {
  130
+      encoding: 'binary',
  131
+      contentType: 'application/x-font-ttf',
  132
+      header: {'Content-Type': 'application/x-font-ttf'},
100 133
     },
101  
-
102  
-    /*
103  
-     * Array containing strings to ignore unwanted files and
104  
-     * directories. That prevents caching of unnecessary files.
105  
-     */
106  
-    cacheIgnore: [],
107  
-
108  
-    /*
109  
-     * Object literal of file types the server have to support.
110  
-     * Indexed by the file extension (e.g. 'js' for .js files).
111  
-     *
112  
-     * Containing:
113  
-     *
114  
-     *  - 'encoding' (e.g. 'utf8').
115  
-     *  - 'contentType' (e.g. 'text/javascript').
116  
-     *  - 'httpHeader' (e.g. {"Content-Type": "text/javascript"}).
117  
-     */
118  
-    fileTypes: {
119  
-        'js': {
120  
-            encoding: 'utf8',
121  
-            contentType: 'text/javascript',
122  
-            header: {'Content-Type': 'text/javascript'},
123  
-         },
124  
-        'ico': {
125  
-            encoding: 'binary',
126  
-            contentType: 'image/x-icon',
127  
-            header: {'Content-Type': 'image/x-icon'},
128  
-        },
129  
-        'ttf': {
130  
-            encoding: 'binary',
131  
-            contentType: 'application/x-font-ttf',
132  
-            header: {'Content-Type': 'application/x-font-ttf'},
133  
-        },
134  
-        'woff': {
135  
-            encoding: 'binary',
136  
-            contentType: 'application/x-font-woff',
137  
-            header: {'Content-Type': 'application/x-font-woff'},
138  
-        },
139  
-        'css': {
140  
-            encoding: 'utf8',
141  
-            contentType: 'text/css',
142  
-            header: {'Content-Type': 'text/css'},
143  
-        },
144  
-        'gif': {
145  
-            encoding: 'utf8',
146  
-            contentType: 'image/gif',
147  
-            header: {'Content-Type': 'image/gif'},
148  
-        },
149  
-        'png': {
150  
-            encoding: 'binary',
151  
-            contentType: 'image/png',
152  
-            header: {'Content-Type': 'image/png'},
153  
-        },
154  
-        'jpg': {
155  
-            encoding: 'binary',
156  
-            contentType: 'image/jpeg',
157  
-            header: {'Content-Type': 'image/jpeg'},
158  
-        },
159  
-        'jpe': {
160  
-            encoding: 'binary',
161  
-            contentType: 'image/jpeg',
162  
-            header: {'Content-Type': 'image/jpeg'},
163  
-        },
164  
-        'jpeg': {
165  
-            encoding: 'binary',
166  
-            contentType: 'image/jpeg',
167  
-            header: {'Content-Type': 'image/jpeg'},
168  
-        },
169  
-        'html': {
170  
-            encoding: 'utf8',
171  
-            contentType: 'text/html',
172  
-            header: {'Content-Type': 'text/html'},
173  
-        }
  134
+    'woff': {
  135
+      encoding: 'binary',
  136
+      contentType: 'application/x-font-woff',
  137
+      header: {'Content-Type': 'application/x-font-woff'},
  138
+    },
  139
+    'css': {
  140
+      encoding: 'utf8',
  141
+      contentType: 'text/css',
  142
+      header: {'Content-Type': 'text/css'},
  143
+    },
  144
+    'gif': {
  145
+      encoding: 'utf8',
  146
+      contentType: 'image/gif',
  147
+      header: {'Content-Type': 'image/gif'},
  148
+    },
  149
+    'png': {
  150
+      encoding: 'binary',
  151
+      contentType: 'image/png',
  152
+      header: {'Content-Type': 'image/png'},
  153
+    },
  154
+    'jpg': {
  155
+      encoding: 'binary',
  156
+      contentType: 'image/jpeg',
  157
+      header: {'Content-Type': 'image/jpeg'},
  158
+    },
  159
+    'jpe': {
  160
+      encoding: 'binary',
  161
+      contentType: 'image/jpeg',
  162
+      header: {'Content-Type': 'image/jpeg'},
  163
+    },
  164
+    'jpeg': {
  165
+      encoding: 'binary',
  166
+      contentType: 'image/jpeg',
  167
+      header: {'Content-Type': 'image/jpeg'},
  168
+    },
  169
+    'html': {
  170
+      encoding: 'utf8',
  171
+      contentType: 'text/html',
  172
+      header: {'Content-Type': 'text/html'},
174 173
     }
  174
+  }
175 175
 };
176 176
 
177 177
 module.exports = config;
10  example/dummy/view/layout/default_layout.html
... ...
@@ -1,9 +1,9 @@
1 1
 
2 2
 <html>
3  
-    <head>
4  
-    </head>
5  
-    <body>
6  
-        #{view}
7  
-    </body>
  3
+  <head>
  4
+  </head>
  5
+  <body>
  6
+    #{view}
  7
+  </body>
8 8
 </html>
9 9
 
10  example/dummy/view/layout/test_layout.html
... ...
@@ -1,9 +1,9 @@
1 1
 
2 2
 <html>
3  
-    <head>
4  
-    </head>
5  
-    <body>
6  
-        #{view}
7  
-    </body>
  3
+  <head>
  4
+  </head>
  5
+  <body>
  6
+    #{view}
  7
+  </body>
8 8
 </html>
9 9
 
18  example/redirect.js
@@ -13,19 +13,19 @@ var app = require('sayndo');
13 13
  * this case the session is set for 1 minute.
14 14
  */
15 15
 app.guest.GET['/'] = function(req, res) {
16  
-    var session = {
17  
-        authType: 'user',
18  
-        message: 'that session message you will see just one time, allthough you are redirected'
19  
-    };
  16
+  var session = {
  17
+    authType: 'user',
  18
+    message: 'that session message you will see just one time, allthough you are redirected'
  19
+  };
20 20
 
21  
-    res.session.write(session, 1);
22  
-    res.redirect('/redirect');
  21
+  res.session.write(session, 1);
  22
+  res.redirect('/redirect');
23 23
 };
24 24
 
25 25
 app.user.GET['/redirect'] = function(req, res) {
26  
-    // Just show the session object if one is set.
27  
-    console.log(res.session);
  26
+  // Just show the session object if one is set.
  27
+  console.log(res.session);
28 28
 
29  
-    res.render('/index.html', {local: 'you have the auth type "user"'});
  29
+  res.render('/index.html', {local: 'you have the auth type "user"'});
30 30
 };
31 31
 
18  example/session.js
@@ -14,12 +14,12 @@ var app = require('sayndo');
14 14
  * auth type defined in lib/app/config.js
15 15
  */
16 16
 app.guest.GET['/'] = function(req, res) {
17  
-    // Just show the session object, if there is no one.
18  
-    console.log(res.session);
  17
+  // Just show the session object, if there is no one.
  18
+  console.log(res.session);
19 19
 
20  
-    res.session.write({authType: 'user'}, 1, function(err, sessionId) {
21  
-        res.render('/index.html', {local: 'you have the auth type "user" for 1 minute'});
22  
-    });
  20
+  res.session.write({authType: 'user'}, 1, function(err, sessionId) {
  21
+    res.render('/index.html', {local: 'you have the auth type "user" for 1 minute'});
  22
+  });
23 23
 };
24 24
 
25 25
 /*
@@ -27,10 +27,10 @@ app.guest.GET['/'] = function(req, res) {
27 27
  * works, uncomment the line below.
28 28
  */
29 29
 app.user.GET['/'] = function(req, res) {
30  
-    // Just show the session object if one is set.
31  
-    console.log(res.session);
  30
+  // Just show the session object if one is set.
  31
+  console.log(res.session);
32 32
 
33  
-    // res.session.remove();
  33
+  // res.session.remove();
34 34
 
35  
-    res.render('/index.html', {local: 'you have the auth type "user"'});
  35
+  res.render('/index.html', {local: 'you have the auth type "user"'});
36 36
 };
4  example/socket.io.js
@@ -11,7 +11,7 @@ var app = require('sayndo');
11 11
 var io = require('socket.io').listen(app.node);
12 12
 
13 13
 io.sockets.on('connection', function (socket) {
14  
-    console.log(socket);
  14
+  console.log(socket);
15 15
 });
16 16
 
17 17
 
@@ -20,6 +20,6 @@ io.sockets.on('connection', function (socket) {
20 20
  * Routes
21 21
  */
22 22
 app.guest.GET['/'] = function(req, res) {
23  
-    res.render('/index.html', {local: 'hello world'});
  23
+  res.render('/index.html', {local: 'hello world'});
24 24
 };
25 25
 
1  index.js
@@ -2,3 +2,4 @@
2 2
  * Just require the server.
3 3
  */
4 4
 module.exports = require('./lib/server.js');
  5
+
117  lib/cache.js
@@ -14,73 +14,74 @@ var fs = require('fs')
14 14
  * Cache module.
15 15
  */
16 16
 var cache = {
17  
-    /*
18  
-     * Cache necessary files that are not placed in the app
19  
-     * folder. E.g. static files of /node_modules like the
20  
-     * socket.io client script.
21  
-     */
22  
-    dependencies: function() {
23  
-        config.dependencies.forEach(function(obj) {
24  
-            var filePath = obj.sourcePath
25  
-              , encoding = config.fileTypes[file.ext(filePath)];
  17
+  /*
  18
+   * Cache necessary files that are not placed in the app
  19
+   * folder. E.g. static files of /node_modules like the
  20
+   * socket.io client script.
  21
+   */
  22
+  dependencies: function() {
  23
+    config.dependencies.forEach(function(obj) {
  24
+      var filePath = obj.sourcePath
  25
+        , encoding = config.fileTypes[file.ext(filePath)];
26 26
 
27  
-            fs.readFile(filePath, encoding, function(err, data) {
28  
-                file.cache[obj.reqUrl] = data;
29  
-            });
30  
-        });
31  
-    },
  27
+      fs.readFile(filePath, encoding, function(err, data) {
  28
+        file.cache[obj.reqUrl] = data;
  29
+      });
  30
+    });
  31
+  },
32 32
 
33  
-    /*
34  
-     * Cache all static files inside the app folder.
35  
-     */
36  
-    public: function() {
37  
-        file.get(config.publicPath, function(filePath, data) {
38  
-            file.cache[filePath.replace(config.cwd, '')] = data;
39  
-        });
40  
-    },
  33
+  /*
  34
+   * Cache all static files inside the app folder.
  35
+   */
  36
+  public: function() {
  37
+    file.get(config.publicPath, function(filePath, data) {
  38
+      file.cache[filePath.replace(config.cwd, '')] = data;
  39
+    });
  40
+  },
41 41
 
42  
-    /*
43  
-     * Cache all static files inside the test folder.
44  
-     */
45  
-    test: function() {
46  
-        file.get(config.testPath, function(filePath, data) {
47  
-            file.cache[filePath.replace(config.cwd, '')] = data;
48  
-        });
49  
-    },
  42
+  /*
  43
+   * Cache all static files inside the test folder.
  44
+   */
  45
+  test: function() {
  46
+    file.get(config.testPath, function(filePath, data) {
  47
+      file.cache[filePath.replace(config.cwd, '')] = data;
  48
+    });
  49
+  },
50 50
 
51  
-    /*
52  
-     * Prepare and cache all views.
53  
-     */
54  
-    view: function() {
55  
-        Object.keys(config.layoutPath).forEach(function(type) {
56  
-            fs.readFile(config.layoutPath[type], 'utf8', function(err, layoutHtml) {
57  
-                if (err) {
58  
-                    return log.error(err);
59  
-                }
  51
+  /*
  52
+   * Prepare and cache all views.
  53
+   */
  54
+  view: function() {
  55
+    Object.keys(config.layoutPath).forEach(function(type) {
  56
+      fs.readFile(config.layoutPath[type], 'utf8', function(err, layoutHtml) {
  57
+        if (err) {
  58
+          return log.error(err);
  59
+        }
60 60
 
61  
-                file.get(config.viewPath, function(filePath, viewHtml) {
62  
-                    if(filePath.match(layoutPattern) !== null) return;
  61
+        file.get(config.viewPath, function(filePath, viewHtml) {
  62
+          if(filePath.match(layoutPattern) !== null) return;
63 63
 
64  
-                    view.parseLocals(layoutHtml, {view: viewHtml}, function(html) {
65  
-                        var rawPath = filePath.replace(config.viewPath, '');
  64
+          view.parseLocals(layoutHtml, {view: viewHtml}, function(html) {
  65
+            var rawPath = filePath.replace(config.viewPath, '');
66 66
 
67  
-                        view.cache['none' + rawPath] = viewHtml;
68  
-                        view.cache[type + rawPath] = html;
69  
-                    });
70  
-                });
71  
-            });
  67
+            view.cache['none' + rawPath] = viewHtml;
  68
+            view.cache[type + rawPath] = html;
  69
+          });
72 70
         });
73  
-    },
  71
+      });
  72
+    });
  73
+  },
74 74
 
75  
-    /*
76  
-     * Cache all necessary files to respond as fast as posible.
77  
-     */
78  
-    init: function() {
79  
-        cache.dependencies();
80  
-        cache.public();
81  
-        cache.test();
82  
-        cache.view();
83  
-    }
  75
+  /*
  76
+   * Cache all necessary files to respond as fast as posible.
  77
+   */
  78
+  init: function() {
  79
+    cache.dependencies();
  80
+    cache.public();
  81
+    cache.test();
  82
+    cache.view();
  83
+  }
84 84
 };
85 85
 
86 86
 module.exports = cache;
  87
+
141  lib/cookie.js
@@ -2,85 +2,84 @@
81  lib/file.js
@@ -9,57 +9,58 @@ var fs = require('fs')
9 9
  * File module.
10 10
  */
11 11
 var file = {
12  
-    /*
13  
-     * Cache all static files to memory. See ./cache.js.
14  
-     */
15  
-    cache: {},
  12
+  /*
  13
+   * Cache all static files to memory. See ./cache.js.
  14
+   */
  15
+  cache: {},
16 16
 
17  
-    /*
18  
-     * Get the extension of a path. Search for the last occurrence
19  
-     * of a dot (.) and get the follwoing chars. Is needed for
20  
-     * request type identification. Is 50% faster than path.extname().
21  
-     */
22  
-    ext: function(string) {
23  
-        var splited = string.split('.');
  17
+  /*
  18
+   * Get the extension of a path. Search for the last occurrence
  19
+   * of a dot (.) and get the follwoing chars. Is needed for
  20
+   * request type identification. Is 50% faster than path.extname().
  21
+   */
  22
+  ext: function(string) {
  23
+    var splited = string.split('.');
24 24
 
25  
-        if (splited.length > 1) {
26  
-            return splited[splited.length - 1];
27  
-        }
  25
+    if (splited.length > 1) {
  26
+      return splited[splited.length - 1];
  27
+    }
28 28
 
29  
-        return '';
30  
-    },
  29
+    return '';
  30
+  },
31 31
 
32  
-    /*
33  
-     * Get files of a directory. Loop trough all directories until all
34  
-     * files are found. Read found files and send the data to a callback.
35  
-     */
36  
-    get: function(dirPath, cb) {
37  
-        fs.readdir(dirPath, function(err, files) {
38  
-            if(typeof files === 'undefined') return;
  32
+  /*
  33
+   * Get files of a directory. Loop trough all directories until all
  34
+   * files are found. Read found files and send the data to a callback.
  35
+   */
  36
+  get: function(dirPath, cb) {
  37
+    fs.readdir(dirPath, function(err, files) {
  38
+      if(typeof files === 'undefined') return;
39 39
 
40  
-            files.forEach(function(item) {
41  
-                var i = 0
42  
-                  , ii = config.cacheIgnore.length
43  
-                  , filePath = dirPath + '/' + item;
  40
+      files.forEach(function(item) {
  41
+        var i = 0
  42
+          , ii = config.cacheIgnore.length
  43
+          , filePath = dirPath + '/' + item;
44 44
 
45  
-                for(i; i < ii; i++) {
46  
-                    // Ignore unneeded files and directories.
47  
-                    if(config.cacheIgnore[i] == dirPath) return;
48  
-                    if(config.cacheIgnore[i] == filePath) return;
49  
-                }
  45
+        for(i; i < ii; i++) {
  46
+          // Ignore unneeded files and directories.
  47
+          if(config.cacheIgnore[i] == dirPath) return;
  48
+          if(config.cacheIgnore[i] == filePath) return;
  49
+        }
50 50
 
51 51
 
52  
-                // No files, but directories.
53  
-                if(file.ext(item) === '') return file.get(filePath, cb);
  52
+        // No files, but directories.
  53
+        if(file.ext(item) === '') return file.get(filePath, cb);
54 54
 
55  
-                var encoding = config.fileTypes[file.ext(filePath)].encoding;
  55
+        var encoding = config.fileTypes[file.ext(filePath)].encoding;
56 56
 
57  
-                fs.readFile(filePath, encoding, function(err, data) {
58  
-                    cb(filePath, data);
59  
-                });
60  
-            });
  57
+        fs.readFile(filePath, encoding, function(err, data) {
  58
+          cb(filePath, data);
61 59
         });
62  
-    }
  60
+      });
  61
+    });
  62
+  }
63 63
 };
64 64
 
65 65
 module.exports = file;
  66
+
236  lib/redis.js
@@ -10,125 +10,125 @@
10 10
 var log = require('logerize');
11 11
 
12 12
 var redis = {
13  
-    /*
14  
-     * Store a list of data.
15  
-     *
16  
-     * @param data, array including objects (e.g. [{key: 'foo', value: 'bar'}]).
17  
-     * @param cb, function to execute.
18  
-     */
19  
-    prefill: function redisPrefill(data, cb) {
20  
-        var self = this
21  
-          , i = 0
22  
-          , ii = data.length;
23  
-
24  
-        for(i; i < ii; i++) {
25  
-            var dataset = data[i];
26  
-
27  
-            if(Array.isArray(dataset.value)) saveArray(dataset);
28  
-            else if(typeof dataset.value === 'string') saveData(dataset, 'set');
29  
-            else saveData(dataset, 'hmset');
30  
-        }
31  
-
32  
-        function saveArray(dataset) {
33  
-            var i = 0
34  
-              , ii = dataset.value.length;
35  
-
36  
-            for(i; i < ii; i++) {
37  
-                saveArrayItem(dataset.value[i]);
38  
-            }
39  
-
40  
-            function saveArrayItem(value) {
41  
-                self.client.lpush(dataset.key, value, function(err, result) {
42  
-                    if(err) log.error(err.stack);
43  
-
44  
-                    dataset.value.shift();
45  
-                    if(dataset.value.length === 0) data.shift();
46  
-                    if(data.length === 0) return cb();
47  
-                });
48  
-            }
49  
-        }
50  
-
51  
-        function saveData(dataset, method) {
52  
-            self.client[method](dataset.key, dataset.value, function(err, result) {
53  
-                if(err) log.error(err.stack);
54  
-
55  
-                data.shift();
56  
-                if(data.length === 0) return cb();
57  
-            });
58  
-        }
59  
-    },
60  
-
61  
-    /*
62  
-     * Wrap the redis client flushall() method.
63  
-     *
64  
-     * @param cb, function to execute.
65  
-     */
66  
-    flushAll: function(cb) {
67  
-        this.client.flushall(function(err, result) {
68  
-            if(err) log.error(err);
69  
-
70  
-            if(result === 'OK') log.success('Flushed all redis db´s.');
71  
-            else log.error('Could not flush all redis db´s.');
72  
-
73  
-            if(typeof cb === 'function') cb(err, result);
  13
+  /*
  14
+   * Store a list of data.
  15
+   *
  16
+   * @param data, array including objects (e.g. [{key: 'foo', value: 'bar'}]).
  17
+   * @param cb, function to execute.
  18
+   */
  19
+  prefill: function redisPrefill(data, cb) {
  20
+    var self = this
  21
+      , i = 0
  22
+      , ii = data.length;
  23
+
  24
+    for(i; i < ii; i++) {
  25
+      var dataset = data[i];
  26
+
  27
+      if(Array.isArray(dataset.value)) saveArray(dataset);
  28
+      else if(typeof dataset.value === 'string') saveData(dataset, 'set');
  29
+      else saveData(dataset, 'hmset');
  30
+    }
  31
+
  32
+    function saveArray(dataset) {
  33
+      var i = 0
  34
+        , ii = dataset.value.length;
  35
+
  36
+      for(i; i < ii; i++) {
  37
+        saveArrayItem(dataset.value[i]);
  38
+      }
  39
+
  40
+      function saveArrayItem(value) {
  41
+        self.client.lpush(dataset.key, value, function(err, result) {
  42
+          if(err) log.error(err.stack);
  43
+
  44
+          dataset.value.shift();
  45
+          if(dataset.value.length === 0) data.shift();
  46
+          if(data.length === 0) return cb();
74 47
         });
75  
-    },
76  
-
77  
-    /*
78  
-     * Bind the redis client on its events.
79  
-     */
80  
-    events: function() {
81  
-        redis.client.on('connect', function() {
82  
-            log.success('Connect redis client to ' + redis.client.host + ':' + redis.client.port);
83  
-        });
84  
-
85  
-        redis.client.on('end', function() {
86  
-            log.info('Close redis server.');
87  
-        });
88  
-
89  
-        redis.client.on('error', function (err) {
90  
-            log.error(err);
91  
-        });
92  
-    },
93  
-
94  
-    /*
95  
-     * Get a fresh redis client.
96  
-     *
97  
-     * @param port, string of the redis server port.
98  
-     * @param host, string of the redis server host.
99  
-     *
100  
-     * @return object, of a fresh redis client.
101  
-     */
102  
-    getClient: function redisGetClient(port, host) {
103  
-        port = port || redis.config.port;
104  
-        host = host || redis.config.host;
105  
-
106  
-        return require('redis').createClient(port, host);
107  
-    },
108  
-
109  
-    /*
110  
-     * Set the redis server configuration.
111  
-     *
112  
-     * @dependencie port, string of the redis server port.
113  
-     * @dependencie host, string of the redis server host.
114  
-     */
115  
-    config: {
116  
-        port: '6379',
117  
-        host: '127.0.0.1'
118  
-    },
119  
-
120  
-    /*
121  
-     * Initialize the redis module.
122  
-     *
123  
-     * @return object, including a fresh redis client.
124  
-     */
125  
-    init: function redisInit() {
126  
-        redis.client = redis.getClient();
127  
-
128  
-        redis.events();
129  
-
130  
-        return redis;
131  
-    },
  48
+      }
  49
+    }
  50
+
  51
+    function saveData(dataset, method) {
  52
+      self.client[method](dataset.key, dataset.value, function(err, result) {
  53
+        if(err) log.error(err.stack);
  54
+
  55
+        data.shift();
  56
+        if(data.length === 0) return cb();
  57
+      });
  58
+    }
  59
+  },
  60
+
  61
+  /*
  62