Loading TODO +2 −2 Original line number Diff line number Diff line cache headers for static assets cache headers for static assets (and on document GET) tests fix any annoying visual quirks add FAVICON Loading @@ -6,7 +6,7 @@ cache static in memory add feedback for errors to UI - esp. too long copy URL to clipboard button add about page add conflict resolution for keys when creating a post support built-in expiration # shared version only some way to do announcements easily (and use for ads) lib/document_handler.js +26 −12 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ DocumentHandler.prototype.handleGet = function(key, response) { // Handle adding a new Document DocumentHandler.prototype.handlePost = function(request, response) { var _this = this; var key = this.randomKey(); var buffer = ''; request.on('data', function(data) { if (!buffer) { Loading @@ -38,13 +37,14 @@ DocumentHandler.prototype.handlePost = function(request, response) { buffer += data.toString(); if (_this.maxLength && buffer.length > _this.maxLength) { _this.cancelled = true; winston.warn('attempted to upload a document >maxLength', { maxLength: _this.maxLength }); winston.warn('document >maxLength', { maxLength: _this.maxLength }); response.writeHead(400, { 'content-type': 'application/json' }); response.end(JSON.stringify({ message: 'document exceeds maximum length' })); } }); request.on('end', function(end) { if (_this.cancelled) return; _this.chooseKey(function(key) { _this.store.set(key, buffer, function(res) { if (res) { winston.verbose('added document', { key: key }); Loading @@ -57,6 +57,7 @@ DocumentHandler.prototype.handlePost = function(request, response) { } }); }); }); request.on('error', function(error) { winston.error('connection error: ' + error.message); response.writeHead(500, { 'content-type': 'application/json' }); Loading @@ -64,6 +65,19 @@ DocumentHandler.prototype.handlePost = function(request, response) { }); }; // Get a random key that hasn't been already used DocumentHandler.prototype.chooseKey = function(callback) { var key = this.randomKey(); var _this = this; this.store.get(key, function(ret) { if (ret) { _this.chooseKey(callback); } else { callback(key); } }); }; // Generate a random key DocumentHandler.prototype.randomKey = function() { var text = ''; Loading Loading
TODO +2 −2 Original line number Diff line number Diff line cache headers for static assets cache headers for static assets (and on document GET) tests fix any annoying visual quirks add FAVICON Loading @@ -6,7 +6,7 @@ cache static in memory add feedback for errors to UI - esp. too long copy URL to clipboard button add about page add conflict resolution for keys when creating a post support built-in expiration # shared version only some way to do announcements easily (and use for ads)
lib/document_handler.js +26 −12 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ DocumentHandler.prototype.handleGet = function(key, response) { // Handle adding a new Document DocumentHandler.prototype.handlePost = function(request, response) { var _this = this; var key = this.randomKey(); var buffer = ''; request.on('data', function(data) { if (!buffer) { Loading @@ -38,13 +37,14 @@ DocumentHandler.prototype.handlePost = function(request, response) { buffer += data.toString(); if (_this.maxLength && buffer.length > _this.maxLength) { _this.cancelled = true; winston.warn('attempted to upload a document >maxLength', { maxLength: _this.maxLength }); winston.warn('document >maxLength', { maxLength: _this.maxLength }); response.writeHead(400, { 'content-type': 'application/json' }); response.end(JSON.stringify({ message: 'document exceeds maximum length' })); } }); request.on('end', function(end) { if (_this.cancelled) return; _this.chooseKey(function(key) { _this.store.set(key, buffer, function(res) { if (res) { winston.verbose('added document', { key: key }); Loading @@ -57,6 +57,7 @@ DocumentHandler.prototype.handlePost = function(request, response) { } }); }); }); request.on('error', function(error) { winston.error('connection error: ' + error.message); response.writeHead(500, { 'content-type': 'application/json' }); Loading @@ -64,6 +65,19 @@ DocumentHandler.prototype.handlePost = function(request, response) { }); }; // Get a random key that hasn't been already used DocumentHandler.prototype.chooseKey = function(callback) { var key = this.randomKey(); var _this = this; this.store.get(key, function(ret) { if (ret) { _this.chooseKey(callback); } else { callback(key); } }); }; // Generate a random key DocumentHandler.prototype.randomKey = function() { var text = ''; Loading