Skip to content

Instantly share code, notes, and snippets.

@mojodna
Created July 30, 2014 21:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojodna/0127d0bd27efa7b1d968 to your computer and use it in GitHub Desktop.
Save mojodna/0127d0bd27efa7b1d968 to your computer and use it in GitHub Desktop.
A minimal tilelive source.
"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