Loading README.md +34 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,40 @@ Major design objectives: 3. `npm install` 4. `npm start` ## Storage ## File To use file storage (the default) change the storage section in `config.js` to something like: ``` json { "path": "./data", "type": "file" } ``` Where `path` represents where you want the files stored ### Redis To use redis storage you must install the redis package in npm globall using `npm install redis --global` Once you've done that, your config section should look like: ``` json { "type": "redis", "host": "localhost", "port": 6379, "db": 2 } ``` All of which are optional except `type` with very logical default values. ## Author John Crepezzi <john.crepezzi@gmail.com> Loading TODO +5 −1 Original line number Diff line number Diff line cache headers for static assets redis storing chng how file def is written make redis work without in package make redis connection into a separate method tests # shared version only twitter posting with ^T Loading config.js +4 −2 Original line number Diff line number Diff line Loading @@ -14,8 +14,10 @@ ], "storage": { "type": "file", "path": "./data" "type": "redis", "host": "localhost", "port": 6379, "db": 2 } } lib/redis_document_store.js 0 → 100644 +38 −0 Original line number Diff line number Diff line var redis = require('redis'); var winston = require('winston'); var hashlib = require('hashlib'); // TODO move to a different method (conn) var RedisDocumentStore = function(options) { if (!RedisDocumentStore.client) { var host = options.host || '127.0.0.1'; var port = options.port || 6379; var index = options.db || 0; RedisDocumentStore.client = redis.createClient(port, host); RedisDocumentStore.client.select(index, function(err, reply) { if (err) { winston.error('error connecting to redis index ' + index, { error: error.message }); process.exit(1); } else { winston.info('connected to redis on ' + host + ':' + port + '/' + index); } }); } }; // Save file in a key RedisDocumentStore.prototype.set = function(key, data, callback) { RedisDocumentStore.client.set(key, data, function(err, reply) { callback(!err); }); }; // Get a file from a key RedisDocumentStore.prototype.get = function(key, callback) { RedisDocumentStore.client.get(key, function(err, reply) { callback(err ? false : reply); }); }; module.exports = RedisDocumentStore; package.json +2 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,8 @@ "dependencies": { "winston": "*", "hashlib": "*" "hashlib": "*", "package": "*" }, "devDependencies": { Loading Loading
README.md +34 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,40 @@ Major design objectives: 3. `npm install` 4. `npm start` ## Storage ## File To use file storage (the default) change the storage section in `config.js` to something like: ``` json { "path": "./data", "type": "file" } ``` Where `path` represents where you want the files stored ### Redis To use redis storage you must install the redis package in npm globall using `npm install redis --global` Once you've done that, your config section should look like: ``` json { "type": "redis", "host": "localhost", "port": 6379, "db": 2 } ``` All of which are optional except `type` with very logical default values. ## Author John Crepezzi <john.crepezzi@gmail.com> Loading
TODO +5 −1 Original line number Diff line number Diff line cache headers for static assets redis storing chng how file def is written make redis work without in package make redis connection into a separate method tests # shared version only twitter posting with ^T Loading
config.js +4 −2 Original line number Diff line number Diff line Loading @@ -14,8 +14,10 @@ ], "storage": { "type": "file", "path": "./data" "type": "redis", "host": "localhost", "port": 6379, "db": 2 } }
lib/redis_document_store.js 0 → 100644 +38 −0 Original line number Diff line number Diff line var redis = require('redis'); var winston = require('winston'); var hashlib = require('hashlib'); // TODO move to a different method (conn) var RedisDocumentStore = function(options) { if (!RedisDocumentStore.client) { var host = options.host || '127.0.0.1'; var port = options.port || 6379; var index = options.db || 0; RedisDocumentStore.client = redis.createClient(port, host); RedisDocumentStore.client.select(index, function(err, reply) { if (err) { winston.error('error connecting to redis index ' + index, { error: error.message }); process.exit(1); } else { winston.info('connected to redis on ' + host + ':' + port + '/' + index); } }); } }; // Save file in a key RedisDocumentStore.prototype.set = function(key, data, callback) { RedisDocumentStore.client.set(key, data, function(err, reply) { callback(!err); }); }; // Get a file from a key RedisDocumentStore.prototype.get = function(key, callback) { RedisDocumentStore.client.get(key, function(err, reply) { callback(err ? false : reply); }); }; module.exports = RedisDocumentStore;
package.json +2 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,8 @@ "dependencies": { "winston": "*", "hashlib": "*" "hashlib": "*", "package": "*" }, "devDependencies": { Loading