This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function proxyHook (hook) { | |
hook.res.end('proxied'); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function echoHttp (hook) { | |
hook.debug("test messages are sent to the debug console"); | |
hook.debug(hook.params); | |
hook.debug(hook.req.path); | |
hook.debug(hook.req.method); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function getCoin (hook) { | |
var request = require('request'); | |
var url = 'http://coinmarketcap-nexuist.rhcloud.com/api/' + hook.params.coin; | |
request(url, { json: true }, function (err, response, body) { | |
if (hook.params.currency !== 'all') { | |
// if a specific currency is selected, filter the results | |
return hook.res.end(body['price'][hook.params.currency]); | |
} else { | |
// else, send all coin data back | |
hook.res.end(JSON.stringify(body)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function markdownHook (hook) { | |
var marked = require('marked'); | |
// TODO: expose parser options through schema | |
marked.setOptions({ | |
renderer: new marked.Renderer(), | |
gfm: true, | |
tables: true, | |
breaks: false, | |
pedantic: false, | |
sanitize: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function geoipHook (hook) { | |
var geoip = require('geoip-lite'); | |
var ip = hook.params.ip; | |
if (typeof ip === "undefined" || ip.length === 0) { | |
ip = hook.req.headers['x-forwarded-for']; | |
} | |
console.log('attempting to lookup ' + ip); | |
var geo = geoip.lookup(ip); | |
if (geo === null) { | |
return hook.res.end(JSON.stringify({ message: "invalid ip " + ip.toString(), error: true }, true, 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function echoHttp (hook) { | |
var path = require('path'); | |
var SpellCheck = require('spellcheck'), | |
base = __dirname + "../../../../modules/builds/hunspell/en_US/"; | |
base = path.resolve(base); | |
base = base + "/"; | |
spell = new SpellCheck(base + 'en_US.aff', base + 'en_US.dic'); | |
// If the hook is not currently streaming, req has already been fully buffered |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _colors = ["random", "red", "green", "blue", "yellow", "cyan", "rainbow", "zalgo"]; | |
module['exports'] = function colorsHook (hook) { | |
var colors = require('colors'), | |
color = hook.params.color; | |
var text = hook.params.text || ""; | |
// if random color is selected, return a random color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function view (hook) { | |
var view = require('view'); | |
var marak = 'https://raw.githubusercontent.com/Marak/marak.com/master/view'; | |
var url = hook.req.headers['x-forwarded-url']; | |
view.create( { remote: marak } , function (err, v) { | |
if (err) { | |
return hook.res.end(err.message); | |
} | |
v.remote(url, function (err, result) { | |
if (err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function staticHook (hook) { | |
hook.debug("Debug messages are sent to the debug console"); | |
hook.debug(hook.params); | |
hook.debug(hook.req.path); | |
hook.debug(hook.req.method); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module['exports'] = function faker (hook) { | |
var faker = require('faker'); | |
var params = hook.params; | |
var parts = params.property.split('.'); | |
faker.locale = hook.params.locale; | |
var result = faker[parts[0]][parts[1]](); | |
hook.res.end(JSON.stringify(result, true, 2)); |