Windshaft-cartodb/lib/api/middlewares/increment-map-view-count.js

18 lines
554 B
JavaScript
Raw Normal View History

'use strict';
module.exports = function incrementMapViewCount (metadataBackend) {
2019-10-22 01:07:24 +08:00
return function incrementMapViewCountMiddleware (req, res, next) {
const { mapConfig, user, logger } = res.locals;
const statTag = mapConfig.obj().stat_tag;
metadataBackend.incMapviewCount(user, statTag, (err) => {
if (err) {
err.message = `Failed to increment mapview count for user '${user}'. ${err.message}`;
logger.warn({ error: err });
}
next();
});
};
};