Created
July 30, 2014 21:15
-
-
Save mojodna/0127d0bd27efa7b1d968 to your computer and use it in GitHub Desktop.
A minimal tilelive source.
This file contains 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
"use strict"; | |
/** | |
* Note: | |
* | |
* setImmediate(callback, null, {}); | |
* | |
* is shorthand for: | |
* | |
* setImmediate(function() { | |
* return callback(null, {}); | |
* }); | |
* | |
* (setImmediate() is used to preserve the contract that these are async calls; | |
* if your output is the result of an async call, it's not necessary.) | |
*/ | |
/** | |
* A minimal tilelive source. | |
*/ | |
module.exports = function(tilelive, options) { | |
var Minimal = function(uri, callback) { | |
return setImmediate(callback, null, this); | |
}; | |
Minimal.prototype.getTile = function(z, x, y, callback) { | |
return setImmediate(callback, null, JSON.stringify({ | |
hello: "world" | |
}), { | |
"Content-Type": "application/json" | |
}); | |
}; | |
Minimal.prototype.getInfo = function(callback) { | |
return setImmediate(callback, null, {}); | |
}; | |
Minimal.prototype.close = function(callback) { | |
return callback && setImmediate(callback); | |
}; | |
Minimal.registerProtocols = function(tilelive) { | |
tilelive.protocols["minimal:"] = Minimal; | |
}; | |
Minimal.registerProtocols(tilelive); | |
return Minimal; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment