UNPKG

nodebb-plugin-solr

Version:

Full-text searching for NodeBB using Apache Solr

37 lines (29 loc) 717 B
'use strict'; const Solr = module.parent.exports; const async = require('async'); const Middleware = {}; Middleware.ping = function (req, res, next) { Solr.ping(function (err, response) { res.locals.ping = !err ? response : undefined; next(); }); }; Middleware.getEnabled = function (req, res, next) { res.locals.enabled = parseInt(Solr.config.enabled, 10) || false; next(); }; Middleware.getStats = function (req, res, next) { async.parallel({ count: async.apply(Solr.getRecordCount), topics: async.apply(Solr.getTopicCount), }, function (err, data) { if (!err) { res.locals.stats = { total: data.count, topics: data.topics, }; } next(); }); }; module.exports = Middleware;