You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
521 B

function setup(labelGenerator) {
function middleware(req, res, next) {
return assignLabel(req, res, next, labelGenerator || require('pelias-labels'));
}
return middleware;
}
function assignLabel(req, res, next, labelGenerator) {
// do nothing if there's nothing to process
if (!res || !res.body || !res.body.features) {
return next();
}
res.body.features.forEach(function (feature) {
feature.properties.label = labelGenerator(feature.properties);
});
next();
}
module.exports = setup;