@graffy/server
Advanced tools
Comparing version 0.8.2 to 0.8.3
105
index.js
@@ -39,6 +39,7 @@ "use strict"; | ||
if (!(req.method === 'GET')) { | ||
_context.next = 50; | ||
_context.next = 65; | ||
break; | ||
} | ||
_context.prev = 1; | ||
parsed = url.parse(req.url, true); | ||
@@ -48,3 +49,3 @@ query = (0, _getQuery["default"])(parsed.query.include); | ||
if (!(req.headers['accept'] === 'text/event-stream')) { | ||
_context.next = 44; | ||
_context.next = 51; | ||
break; | ||
@@ -56,2 +57,3 @@ } | ||
_context.prev = 6; | ||
stream = store.sub(query, { | ||
@@ -63,20 +65,20 @@ raw: true | ||
_didIteratorError = false; | ||
_context.prev = 8; | ||
_context.prev = 10; | ||
_iterator = (0, _asyncIterator2["default"])(stream); | ||
case 10: | ||
_context.next = 12; | ||
case 12: | ||
_context.next = 14; | ||
return _iterator.next(); | ||
case 12: | ||
case 14: | ||
_step = _context.sent; | ||
_iteratorNormalCompletion = _step.done; | ||
_context.next = 16; | ||
_context.next = 18; | ||
return _step.value; | ||
case 16: | ||
case 18: | ||
_value = _context.sent; | ||
if (_iteratorNormalCompletion) { | ||
_context.next = 25; | ||
_context.next = 27; | ||
break; | ||
@@ -88,43 +90,43 @@ } | ||
if (!(req.aborted || res.finished)) { | ||
_context.next = 21; | ||
_context.next = 23; | ||
break; | ||
} | ||
return _context.abrupt("break", 25); | ||
return _context.abrupt("break", 27); | ||
case 21: | ||
case 23: | ||
res.write("data: " + (0, _stringify["default"])(value) + "\n\n"); | ||
case 22: | ||
case 24: | ||
_iteratorNormalCompletion = true; | ||
_context.next = 10; | ||
_context.next = 12; | ||
break; | ||
case 25: | ||
_context.next = 31; | ||
case 27: | ||
_context.next = 33; | ||
break; | ||
case 27: | ||
_context.prev = 27; | ||
_context.t0 = _context["catch"](8); | ||
case 29: | ||
_context.prev = 29; | ||
_context.t0 = _context["catch"](10); | ||
_didIteratorError = true; | ||
_iteratorError = _context.t0; | ||
case 31: | ||
_context.prev = 31; | ||
_context.prev = 32; | ||
case 33: | ||
_context.prev = 33; | ||
_context.prev = 34; | ||
if (!(!_iteratorNormalCompletion && _iterator["return"] != null)) { | ||
_context.next = 36; | ||
_context.next = 38; | ||
break; | ||
} | ||
_context.next = 36; | ||
_context.next = 38; | ||
return _iterator["return"](); | ||
case 36: | ||
_context.prev = 36; | ||
case 38: | ||
_context.prev = 38; | ||
if (!_didIteratorError) { | ||
_context.next = 39; | ||
_context.next = 41; | ||
break; | ||
@@ -135,15 +137,24 @@ } | ||
case 39: | ||
return _context.finish(36); | ||
case 41: | ||
return _context.finish(38); | ||
case 40: | ||
return _context.finish(31); | ||
case 42: | ||
return _context.finish(33); | ||
case 41: | ||
res.end(); | ||
case 43: | ||
_context.next = 48; | ||
break; | ||
case 44: | ||
_context.next = 46; | ||
case 45: | ||
_context.prev = 45; | ||
_context.t1 = _context["catch"](6); | ||
res.write("event: graffyerror\ndata: " + _context.t1.message + "\n\n"); | ||
case 48: | ||
res.end(); | ||
_context.next = 56; | ||
break; | ||
case 51: | ||
_context.next = 53; | ||
return store.get(query, { | ||
@@ -153,15 +164,27 @@ raw: true | ||
case 46: | ||
case 53: | ||
_value2 = _context.sent; | ||
res.writeHead(200); | ||
res.end((0, _stringify["default"])(_value2)); | ||
case 48: | ||
_context.next = 52; | ||
case 56: | ||
_context.next = 63; | ||
break; | ||
case 50: | ||
case 58: | ||
_context.prev = 58; | ||
_context.t2 = _context["catch"](1); | ||
res.writeHead(400); | ||
res.write(_context.t2.message + "\n\n"); | ||
return _context.abrupt("return"); | ||
case 63: | ||
_context.next = 67; | ||
break; | ||
case 65: | ||
res.writeHead(501); | ||
res.end('Not implemented'); | ||
case 52: | ||
case 67: | ||
case "end": | ||
@@ -171,3 +194,3 @@ return _context.stop(); | ||
} | ||
}, _callee, null, [[8, 27, 31, 41], [32,, 36, 40]]); | ||
}, _callee, null, [[1, 58], [6, 45], [10, 29, 33, 43], [34,, 38, 42]]); | ||
})); | ||
@@ -174,0 +197,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"author": "aravind (https://github.com/aravindet)", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
7557
180