Clean up some code and move document stores into subfolder

This commit is contained in:
John Crepezzi 2012-01-21 15:19:55 -05:00
parent 483fce891d
commit f37d1ad401
10 changed files with 92 additions and 44 deletions

View file

@ -54,13 +54,15 @@ DocumentHandler.prototype.handlePost = function(request, response) {
request.on('data', function(data) {
if (!buffer) {
response.writeHead(200, { 'content-type': 'application/json' });
}
}
buffer += data.toString();
if (_this.maxLength && buffer.length > _this.maxLength) {
cancelled = true;
winston.warn('document >maxLength', { maxLength: _this.maxLength });
response.writeHead(400, { 'content-type': 'application/json' });
response.end(JSON.stringify({ message: 'Document exceeds maximum length.' }));
response.end(
JSON.stringify({ message: 'Document exceeds maximum length.' })
);
}
});
request.on('end', function(end) {
@ -96,7 +98,7 @@ DocumentHandler.prototype.chooseKey = function(callback) {
} else {
callback(key);
}
});
});
};
DocumentHandler.prototype.acceptableKey = function() {