Skip to content

Commit

Permalink
first commit-
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePrimeagen committed Feb 12, 2015
0 parents commit a2b7259
Show file tree
Hide file tree
Showing 60 changed files with 24,065 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.idea
falkor_node.iml
node_modules
data
308 changes: 308 additions & 0 deletions Cache.js
@@ -0,0 +1,308 @@
var expiredTimestamp = Date.now() - 100;
var Cache = function() {
return {
"$size": 1002,
"genreList": {
"$size": 81,
"-1": ["lists", "def"],
"0": ["lists", "abcd"],
"1": ["lists", "my-list"],
"2": ["lists", "error-list"],
"3": ["lists", "sentinel-list"],
"4": ["lists", "missing-list"],
"5": ["lists", "to-error-list"],
"6": ["lists", "to-missing-list"],
"7": ["lists", "to-sentinel-list"],
"8": ["lists", "expired-list"],
"9": ["lists", "to-expired-list"],
"10": ["videos", 1234, "summary"],
"11": ["lists", "expired-video-branch"],
"12": ["lists", "future-expired-list"],
"sentinel": {
"$size": 52,
"$type": "sentinel",
"value": ["lists", "to-sentinel-list"]
},
"branch-miss": ['does', 'not', 'exist']
},
"lists": {
"$size": 489,
"abcd": {
"$size": 8,
"-1": ["videos", 4422],
"0": ["videos", 1234],
"1": ["videos", 766],
"2": ["videos", 7531],
"3": ["videos", 6420]
},
"def": {
"$size": 6,
"0": ["videos", 888],
"1": ["videos", 999],
"2": ["videos", 542]
},
"sentinel-list": {
"$size": 104,
"0": {
"$size": 52,
"$type": "sentinel",
"value": ["videos", 333]
},
"1": {
"$size": 52,
"$type": "sentinel",
"value": ["videos", "sentinel"]
}
},
"sentinel-list-2": {
"$size": 52,
"0": {
"$size": 52,
"$type": "sentinel",
"value": ["videos", 733]
}
},
"expired-video-branch": {
"$size": 3,
"0": ['videos', 'expiredBranchByTimestamp', 'summary']
},
"1x5x": {
"$size": 4,
"0": ["videos", 553],
"1": ["videos", 5522]
},
"my-list": ["lists", "1x5x"],
"error-list": {
"$size": 50,
"$type": "error",
"message": "Red is the new Black"
},
"error-list-2": {
"$size": 50,
"$type": "error",
"message": "House of Pain"
},
"expired-list": {
"$size": 51,
"$type": "sentinel",
"$expires": expiredTimestamp,
"value": {
"0": ["videos", 333],
"1": ["videos", "sentinel"]
}
},
"to-error-list": ["lists", "error-list-2"],
"to-missing-list": ["lists", "missing-list-2"],
"to-expired-list": {
"$size": 52,
"$type": "sentinel",
"$expires": expiredTimestamp,
"value": ['lists', 'expired-list']
},
"future-expired-list": {
"$type": "sentinel",
"$expires": Date.now() + 100000,
"$size": 51,
"value": {
"0": ["videos", 1234]
}
},
"to-sentinel-list": {
"$size": 52,
"$type": "sentinel",
"value": ["lists", "sentinel-list-2"]
}
},
"videos": {
"$size": 432,
"1234": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "House of Cards",
"url": "/movies/1234"
}
},
"333": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Terminator 2",
"url": "/movies/333"
}
},
"733": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Total Recall (Without Colin Farrell)",
"url": "/movies/733"
}
},
"553": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Running Man",
"url": "/movies/553"
}
},
"766": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Terminator 3",
"url": "/movies/766"
}
},
"888": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Terminator Salvation",
"url": "/movies/888"
}
},
"999": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Jingle All the Way",
"url": "/movies/999"
}
},
"4422": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Beverly Hills Ninja",
"url": "/movies/4422"
}
},
"7531": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Kindergarten Cop",
"url": "/movies/7531"
}
},
"5522": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Junior",
"url": "/movies/5522"
}
},
"6420": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Commando",
"url": "/movies/6420"
}
},
"sentinel": {
"$size": 51,
"summary": {
"$size": 51,
"$type": "sentinel",
"value": {
"title": "Marco Polo",
"url": "/movies/sentinel"
}
}
},
"expiredLeafByTimestamp": {
"$size": 51,
"summary": {
"$size": 51,
"$expires": expiredTimestamp,
"$type": "sentinel",
"value": {
"sad": "panda"
}
}
},
"expiredLeafBy0": {
"$size": 51,
"summary": {
"$expires": 0,
"$size": 51,
"$type": "sentinel",
"value": {
"sad": "tunafish"
}
}
},
"expiredBranchByTimestamp": {
"$size": 51,
"$expires": expiredTimestamp,
"summary": {
"$size": 51,
"$type": "sentinel",
"value": {
"sad": "liger"
}
}
},
"expiredBranchBy0": {
"$size": 51,
"$expires": 0,
"summary": {
"$size": 51,
"$type": "sentinel",
"value": {
"sad": "turtle"
}
}
},
"errorBranch": {
"$size": 50,
"$type": "error",
"message": "I am yelling timber."
},
"542": {
"$size": 10,
"video-item": {
"$size": 10,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Conan, The Barbarian",
"url": "/movies/6420"
}
}
},
"3355": {
"$size": 26,
"summary": {
"$size": 10,
"$type": "leaf",
"title": "Conan, The Destroyer",
"url": "/movies/3355"
},
"art": {
"$size": 16,
"$type": "leaf",
"box-shot": "www.cdn.com/3355"
}
},
"missingValue": { "$type": "sentinel" }
}
};
};

module.exports = Cache;
Binary file added assets/1585264.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/1585360.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/1641134.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/1712289.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/1829772.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2036766.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2086307.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2091847.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2171006.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2171910.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2187391.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2316690.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2324402.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2325775.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2365903.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2371520.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/2372627.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/822761.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/829299.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/829508.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/830288.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/840951.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/841112.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/841246.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/841257.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/841270.jpg
Binary file added assets/841271.jpg
Binary file added assets/841337.jpg
Binary file added assets/850831.jpg
Binary file added assets/851778.jpg
Binary file added assets/868813.jpg
Binary file added assets/868989.jpg
Binary file added assets/868992.jpg
Binary file added assets/868994.jpg
Binary file added assets/869023.jpg
Binary file added assets/869096.jpg
Binary file added assets/869203.jpg
Binary file added assets/869237.jpg
Binary file added assets/869380.jpg
Binary file added assets/869382.jpg
Binary file added assets/869386.jpg
Binary file added assets/869476.jpg
Binary file added assets/869508.jpg
Binary file added assets/869510.jpg
Binary file added assets/869516.jpg
Binary file added assets/869533.jpg
Binary file added assets/869541.jpg
Binary file added assets/869548.jpg
Binary file added assets/872532.jpg
Binary file added assets/925010.jpg
Binary file added assets/925077.jpg
Binary file added assets/928203.jpg
Binary file added assets/929016.jpg
Binary file added assets/930241.jpg
49 changes: 49 additions & 0 deletions index.js
@@ -0,0 +1,49 @@
var url = require('url');

/**
* @param {JSONGModel} model
* @type {FalkorEndpoint}
*/
var FalkorEndpoint = function(model) {
this._model = model;
};

FalkorEndpoint.prototype = {
/**
*
* @param {Object} context the context object which is the query parameters and any other
* useful information required by falkor
* @param {Function} [callback] The callback when done.
*/
execute: function(context, callback) {
var obs;
try {
debugger;
if (context.method && context.path) {
if (typeof context.path === 'string') {
context.path = JSON.parse(context.path);
}
var method = context.method;
if (method === 'call') {
} else {
// no need to materialize since json always returns errors as values.
obs = this._model[method](context.path).
toJSONG();
}
} else {
throw 'Expected method and path to be defined in the context object.';
}
} catch (e) {
obs = Rx.Observable.throw(e);
}

obs.
subscribe(function(x) {
callback(null, JSON.stringify(x));
}, function(err) {
callback(err);
});
}
};

module.exports = FalkorEndpoint;

0 comments on commit a2b7259

Please sign in to comment.