refactor: async/await routes/feeds

v1.18.x
Barış Soner Uşaklı 5 years ago
parent 5de6d8857a
commit ec3b5dd95a

@ -1,15 +1,15 @@
'use strict'; 'use strict';
var nconf = require('nconf'); const nconf = require('nconf');
var winston = require('winston'); const winston = require('winston');
var validator = require('validator'); const validator = require('validator');
var meta = require('../meta'); const meta = require('../meta');
var plugins = require('../plugins'); const plugins = require('../plugins');
exports.handle404 = function handle404(req, res) { exports.handle404 = function handle404(req, res) {
var relativePath = nconf.get('relative_path'); const relativePath = nconf.get('relative_path');
var isClientScript = new RegExp('^' + relativePath + '\\/assets\\/src\\/.+\\.js(\\?v=\\w+)?$'); const isClientScript = new RegExp('^' + relativePath + '\\/assets\\/src\\/.+\\.js(\\?v=\\w+)?$');
if (plugins.hasListeners('action:meta.override404')) { if (plugins.hasListeners('action:meta.override404')) {
return plugins.fireHook('action:meta.override404', { return plugins.fireHook('action:meta.override404', {
@ -38,11 +38,11 @@ exports.handle404 = function handle404(req, res) {
exports.send404 = function (req, res) { exports.send404 = function (req, res) {
res.status(404); res.status(404);
var path = String(req.path || ''); const path = String(req.path || '');
if (res.locals.isAPI) { if (res.locals.isAPI) {
return res.json({ path: validator.escape(path.replace(/^\/api/, '')), title: '[[global:404.title]]' }); return res.json({ path: validator.escape(path.replace(/^\/api/, '')), title: '[[global:404.title]]' });
} }
var middleware = require('../middleware'); const middleware = require('../middleware');
middleware.buildHeader(req, res, function () { middleware.buildHeader(req, res, function () {
res.render('404', { path: validator.escape(path), title: '[[global:404.title]]' }); res.render('404', { path: validator.escape(path), title: '[[global:404.title]]' });
}); });

@ -1,22 +1,21 @@
'use strict'; 'use strict';
var async = require('async'); const rss = require('rss');
var rss = require('rss'); const nconf = require('nconf');
var nconf = require('nconf'); const validator = require('validator');
var validator = require('validator');
const posts = require('../posts');
var posts = require('../posts'); const topics = require('../topics');
var topics = require('../topics'); const user = require('../user');
var user = require('../user'); const categories = require('../categories');
var categories = require('../categories'); const meta = require('../meta');
var meta = require('../meta'); const helpers = require('../controllers/helpers');
var helpers = require('../controllers/helpers'); const privileges = require('../privileges');
var privileges = require('../privileges'); const db = require('../database');
var db = require('../database'); const utils = require('../utils');
var utils = require('../utils'); const controllers404 = require('../controllers/404.js');
var controllers404 = require('../controllers/404.js');
const terms = {
var terms = {
daily: 'day', daily: 'day',
weekly: 'week', weekly: 'week',
monthly: 'month', monthly: 'month',
@ -38,327 +37,244 @@ module.exports = function (app, middleware) {
app.get('/tags/:tag.rss', middleware.maintenanceMode, generateForTag); app.get('/tags/:tag.rss', middleware.maintenanceMode, generateForTag);
}; };
function validateTokenIfRequiresLogin(requiresLogin, cid, req, res, callback) { async function validateTokenIfRequiresLogin(requiresLogin, cid, req, res) {
var uid = parseInt(req.query.uid, 10) || 0; const uid = parseInt(req.query.uid, 10) || 0;
var token = req.query.token; const token = req.query.token;
if (!requiresLogin) { if (!requiresLogin) {
return callback(); return true;
} }
if (uid <= 0 || !token) { if (uid <= 0 || !token) {
return helpers.notAllowed(req, res); return helpers.notAllowed(req, res);
} }
const userToken = await db.getObjectField('user:' + uid, 'rss_token');
async.waterfall([ if (userToken !== token) {
function (next) { await user.auth.logAttempt(uid, req.ip);
db.getObjectField('user:' + uid, 'rss_token', next); return helpers.notAllowed(req, res);
}, }
function (_token, next) { const userPrivileges = privileges.categories.get(cid, uid);
if (token === _token) { if (!userPrivileges.read) {
async.waterfall([ return helpers.notAllowed(req, res);
function (next) { }
privileges.categories.get(cid, uid, next); return true;
},
function (privileges, next) {
if (!privileges.read) {
return helpers.notAllowed(req, res);
}
next();
},
], callback);
return;
}
user.auth.logAttempt(uid, req.ip, next);
},
function () {
helpers.notAllowed(req, res);
},
], callback);
} }
function generateForTopic(req, res, callback) { async function generateForTopic(req, res) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
var tid = req.params.topic_id; const tid = req.params.topic_id;
var userPrivileges;
var topic; const [userPrivileges, topic] = await Promise.all([
async.waterfall([ privileges.topics.get(tid, req.uid),
function (next) { topics.getTopicData(tid),
async.parallel({ ]);
privileges: function (next) {
privileges.topics.get(tid, req.uid, next); if (!topic || (topic.deleted && !userPrivileges.view_deleted)) {
}, return controllers404.send404(req, res);
topic: function (next) { }
topics.getTopicData(tid, next);
}, if (await validateTokenIfRequiresLogin(!userPrivileges['topics:read'], topic.cid, req, res)) {
}, next); const topicData = await topics.getTopicWithPosts(topic, 'tid:' + tid + ':posts', req.uid || req.query.uid || 0, 0, 25, false);
},
function (results, next) { topics.modifyPostsByPrivilege(topicData, userPrivileges);
if (!results.topic || (results.topic.deleted && !results.privileges.view_deleted)) {
return controllers404.send404(req, res); const feed = new rss({
} title: utils.stripHTMLTags(topicData.title, utils.tags),
userPrivileges = results.privileges; description: topicData.posts.length ? topicData.posts[0].content : '',
topic = results.topic; feed_url: nconf.get('url') + '/topic/' + tid + '.rss',
validateTokenIfRequiresLogin(!results.privileges['topics:read'], results.topic.cid, req, res, next); site_url: nconf.get('url') + '/topic/' + topicData.slug,
}, image_url: topicData.posts.length ? topicData.posts[0].picture : '',
function (next) { author: topicData.posts.length ? topicData.posts[0].username : '',
topics.getTopicWithPosts(topic, 'tid:' + tid + ':posts', req.uid || req.query.uid || 0, 0, 25, false, next); ttl: 60,
}, });
function (topicData) {
topics.modifyPostsByPrivilege(topicData, userPrivileges); if (topicData.posts.length > 0) {
feed.pubDate = new Date(parseInt(topicData.posts[0].timestamp, 10)).toUTCString();
var description = topicData.posts.length ? topicData.posts[0].content : ''; }
var image_url = topicData.posts.length ? topicData.posts[0].picture : '';
var author = topicData.posts.length ? topicData.posts[0].username : ''; topicData.posts.forEach(function (postData) {
if (!postData.deleted) {
var feed = new rss({ const dateStamp = new Date(parseInt(parseInt(postData.edited, 10) === 0 ? postData.timestamp : postData.edited, 10)).toUTCString();
title: utils.stripHTMLTags(topicData.title, utils.tags),
description: description, feed.item({
feed_url: nconf.get('url') + '/topic/' + tid + '.rss', title: 'Reply to ' + utils.stripHTMLTags(topicData.title, utils.tags) + ' on ' + dateStamp,
site_url: nconf.get('url') + '/topic/' + topicData.slug, description: postData.content,
image_url: image_url, url: nconf.get('url') + '/post/' + postData.pid,
author: author, author: postData.user ? postData.user.username : '',
ttl: 60, date: dateStamp,
}); });
var dateStamp;
if (topicData.posts.length > 0) {
feed.pubDate = new Date(parseInt(topicData.posts[0].timestamp, 10)).toUTCString();
} }
});
topicData.posts.forEach(function (postData) { sendFeed(feed, res);
if (!postData.deleted) { }
dateStamp = new Date(parseInt(parseInt(postData.edited, 10) === 0 ? postData.timestamp : postData.edited, 10)).toUTCString();
feed.item({
title: 'Reply to ' + utils.stripHTMLTags(topicData.title, utils.tags) + ' on ' + dateStamp,
description: postData.content,
url: nconf.get('url') + '/post/' + postData.pid,
author: postData.user ? postData.user.username : '',
date: dateStamp,
});
}
});
sendFeed(feed, res);
},
], callback);
} }
function generateForCategory(req, res, callback) { async function generateForCategory(req, res, next) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
var cid = req.params.category_id; const cid = req.params.category_id;
var category;
if (!parseInt(cid, 10)) { if (!parseInt(cid, 10)) {
return setImmediate(callback); return next();
}
const [userPrivileges, category] = await Promise.all([
privileges.categories.get(cid, req.uid),
categories.getCategoryById({
cid: cid,
set: 'cid:' + cid + ':tids',
reverse: true,
start: 0,
stop: 25,
uid: req.uid || req.query.uid || 0,
}),
]);
if (!category) {
return next();
}
if (await validateTokenIfRequiresLogin(!userPrivileges.read, cid, req, res)) {
const feed = await generateTopicsFeed({
uid: req.uid || req.query.uid || 0,
title: category.name,
description: category.description,
feed_url: '/category/' + cid + '.rss',
site_url: '/category/' + category.cid,
}, category.topics);
sendFeed(feed, res);
} }
async.waterfall([
function (next) {
async.parallel({
privileges: function (next) {
privileges.categories.get(cid, req.uid, next);
},
category: function (next) {
categories.getCategoryById({
cid: cid,
set: 'cid:' + cid + ':tids',
reverse: true,
start: 0,
stop: 25,
uid: req.uid || req.query.uid || 0,
}, next);
},
}, next);
},
function (results, next) {
category = results.category;
if (!category) {
return callback();
}
validateTokenIfRequiresLogin(!results.privileges.read, cid, req, res, next);
},
function (next) {
generateTopicsFeed({
uid: req.uid || req.query.uid || 0,
title: category.name,
description: category.description,
feed_url: '/category/' + cid + '.rss',
site_url: '/category/' + category.cid,
}, category.topics, next);
},
function (feed) {
sendFeed(feed, res);
},
], callback);
} }
function generateForTopics(req, res, next) { async function generateForTopics(req, res) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
let token = null;
if (req.query.token && req.query.uid) {
token = await db.getObjectField('user:' + req.query.uid, 'rss_token');
}
async.waterfall([ await sendTopicsFeed({
function (next) { uid: token && token === req.query.token ? req.query.uid : req.uid,
if (req.query.token && req.query.uid) { title: 'Most recently created topics',
db.getObjectField('user:' + req.query.uid, 'rss_token', next); description: 'A list of topics that have been created recently',
} else { feed_url: '/topics.rss',
next(null, null); useMainPost: true,
} }, 'topics:tid', res);
},
function (token, next) {
sendTopicsFeed({
uid: token && token === req.query.token ? req.query.uid : req.uid,
title: 'Most recently created topics',
description: 'A list of topics that have been created recently',
feed_url: '/topics.rss',
useMainPost: true,
}, 'topics:tid', req, res, next);
},
], next);
} }
function generateForRecent(req, res, next) { async function generateForRecent(req, res) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
let token = null;
if (req.query.token && req.query.uid) {
token = await db.getObjectField('user:' + req.query.uid, 'rss_token');
}
async.waterfall([ await sendTopicsFeed({
function (next) { uid: token && token === req.query.token ? req.query.uid : req.uid,
if (req.query.token && req.query.uid) { title: 'Recently Active Topics',
db.getObjectField('user:' + req.query.uid, 'rss_token', next); description: 'A list of topics that have been active within the past 24 hours',
} else { feed_url: '/recent.rss',
next(null, null); site_url: '/recent',
} }, 'topics:recent', res);
},
function (token, next) {
sendTopicsFeed({
uid: token && token === req.query.token ? req.query.uid : req.uid,
title: 'Recently Active Topics',
description: 'A list of topics that have been active within the past 24 hours',
feed_url: '/recent.rss',
site_url: '/recent',
}, 'topics:recent', req, res, next);
},
], next);
} }
function generateForTop(req, res, next) { async function generateForTop(req, res) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
var term = terms[req.params.term] || 'day'; const term = terms[req.params.term] || 'day';
var uid;
async.waterfall([ let token = null;
function (next) { if (req.query.token && req.query.uid) {
if (req.query.token && req.query.uid) { token = await db.getObjectField('user:' + req.query.uid, 'rss_token');
db.getObjectField('user:' + req.query.uid, 'rss_token', next); }
} else {
next(null, null); const uid = token && token === req.query.token ? req.query.uid : req.uid;
}
}, const result = await topics.getSortedTopics({
function (token, next) { uid: uid,
uid = token && token === req.query.token ? req.query.uid : req.uid; start: 0,
stop: 19,
topics.getSortedTopics({ term: term,
uid: uid, sort: 'votes',
start: 0, });
stop: 19,
term: term, const feed = await generateTopicsFeed({
sort: 'votes', uid: uid,
}, next); title: 'Top Voted Topics',
}, description: 'A list of topics that have received the most votes',
function (result, next) { feed_url: '/top/' + (req.params.term || 'daily') + '.rss',
generateTopicsFeed({ site_url: '/top/' + (req.params.term || 'daily'),
uid: uid, }, result.topics);
title: 'Top Voted Topics',
description: 'A list of topics that have received the most votes', sendFeed(feed, res);
feed_url: '/top/' + (req.params.term || 'daily') + '.rss',
site_url: '/top/' + (req.params.term || 'daily'),
}, result.topics, next);
},
function (feed) {
sendFeed(feed, res);
},
], next);
} }
function generateForPopular(req, res, next) { async function generateForPopular(req, res) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
var term = terms[req.params.term] || 'day'; const term = terms[req.params.term] || 'day';
var uid;
async.waterfall([ let token = null;
function (next) { if (req.query.token && req.query.uid) {
if (req.query.token && req.query.uid) { token = await db.getObjectField('user:' + req.query.uid, 'rss_token');
db.getObjectField('user:' + req.query.uid, 'rss_token', next); }
} else {
next(null, null); const uid = token && token === req.query.token ? req.query.uid : req.uid;
}
}, const result = await topics.getSortedTopics({
function (token, next) { uid: uid,
uid = token && token === req.query.token ? req.query.uid : req.uid; start: 0,
stop: 19,
topics.getSortedTopics({ term: term,
uid: uid, sort: 'posts',
start: 0, });
stop: 19,
term: term, const feed = await generateTopicsFeed({
sort: 'posts', uid: uid,
}, next); title: 'Popular Topics',
}, description: 'A list of topics that are sorted by post count',
function (result, next) { feed_url: '/popular/' + (req.params.term || 'daily') + '.rss',
generateTopicsFeed({ site_url: '/popular/' + (req.params.term || 'daily'),
uid: uid, }, result.topics);
title: 'Popular Topics', sendFeed(feed, res);
description: 'A list of topics that are sorted by post count',
feed_url: '/popular/' + (req.params.term || 'daily') + '.rss',
site_url: '/popular/' + (req.params.term || 'daily'),
}, result.topics, next);
},
function (feed) {
sendFeed(feed, res);
},
], next);
} }
function sendTopicsFeed(options, set, req, res, next) { async function sendTopicsFeed(options, set, res) {
var start = options.hasOwnProperty('start') ? options.start : 0; const start = options.hasOwnProperty('start') ? options.start : 0;
var stop = options.hasOwnProperty('stop') ? options.stop : 19; const stop = options.hasOwnProperty('stop') ? options.stop : 19;
async.waterfall([ const topicData = await topics.getTopicsFromSet(set, options.uid, start, stop);
function (next) { const feed = await generateTopicsFeed(options, topicData.topics);
topics.getTopicsFromSet(set, options.uid, start, stop, next); sendFeed(feed, res);
},
function (data, next) {
generateTopicsFeed(options, data.topics, next);
},
function (feed) {
sendFeed(feed, res);
},
], next);
} }
function generateTopicsFeed(feedOptions, feedTopics, callback) { async function generateTopicsFeed(feedOptions, feedTopics) {
feedOptions.ttl = 60; feedOptions.ttl = 60;
feedOptions.feed_url = nconf.get('url') + feedOptions.feed_url; feedOptions.feed_url = nconf.get('url') + feedOptions.feed_url;
feedOptions.site_url = nconf.get('url') + feedOptions.site_url; feedOptions.site_url = nconf.get('url') + feedOptions.site_url;
feedTopics = feedTopics.filter(Boolean); feedTopics = feedTopics.filter(Boolean);
var feed = new rss(feedOptions); const feed = new rss(feedOptions);
if (feedTopics.length > 0) { if (feedTopics.length > 0) {
feed.pubDate = new Date(feedTopics[0].lastposttime).toUTCString(); feed.pubDate = new Date(feedTopics[0].lastposttime).toUTCString();
} }
async.eachSeries(feedTopics, function (topicData, next) { for (const topicData of feedTopics) {
var feedItem = { /* eslint-disable no-await-in-loop */
const feedItem = {
title: utils.stripHTMLTags(topicData.title, utils.tags), title: utils.stripHTMLTags(topicData.title, utils.tags),
url: nconf.get('url') + '/topic/' + topicData.slug, url: nconf.get('url') + '/topic/' + topicData.slug,
date: new Date(topicData.lastposttime).toUTCString(), date: new Date(topicData.lastposttime).toUTCString(),
@ -368,89 +284,62 @@ function generateTopicsFeed(feedOptions, feedTopics, callback) {
feedItem.description = topicData.teaser.content; feedItem.description = topicData.teaser.content;
feedItem.author = topicData.teaser.user.username; feedItem.author = topicData.teaser.user.username;
feed.item(feedItem); feed.item(feedItem);
return next(); return;
} }
topics.getMainPost(topicData.tid, feedOptions.uid, function (err, mainPost) { const mainPost = await topics.getMainPost(topicData.tid, feedOptions.uid);
if (err) { if (!mainPost) {
return next(err);
}
if (!mainPost) {
feed.item(feedItem);
return next();
}
feedItem.description = mainPost.content;
feedItem.author = mainPost.user.username;
feed.item(feedItem); feed.item(feedItem);
next(); return;
}); }
}, function (err) { feedItem.description = mainPost.content;
callback(err, feed); feedItem.author = mainPost.user && mainPost.user.username;
}); feed.item(feedItem);
}
return feed;
} }
function generateForRecentPosts(req, res, next) { async function generateForRecentPosts(req, res) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
const postData = await posts.getRecentPosts(req.uid, 0, 19, 'month');
async.waterfall([ const feed = generateForPostsFeed({
function (next) { title: 'Recent Posts',
posts.getRecentPosts(req.uid, 0, 19, 'month', next); description: 'A list of recent posts',
}, feed_url: '/recentposts.rss',
function (posts) { site_url: '/recentposts',
var feed = generateForPostsFeed({ }, postData);
title: 'Recent Posts',
description: 'A list of recent posts', sendFeed(feed, res);
feed_url: '/recentposts.rss',
site_url: '/recentposts',
}, posts);
sendFeed(feed, res);
},
], next);
} }
function generateForCategoryRecentPosts(req, res, callback) { async function generateForCategoryRecentPosts(req, res) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
var cid = req.params.category_id; const cid = req.params.category_id;
var category;
var posts; const [userPrivileges, category, postData] = await Promise.all([
async.waterfall([ privileges.categories.get(cid, req.uid),
function (next) { categories.getCategoryData(cid),
async.parallel({ categories.getRecentReplies(cid, req.uid || req.query.uid || 0, 20),
privileges: function (next) { ]);
privileges.categories.get(cid, req.uid, next);
}, if (!category) {
category: function (next) { return controllers404.send404(req, res);
categories.getCategoryData(cid, next); }
},
posts: function (next) { if (await validateTokenIfRequiresLogin(!userPrivileges.read, cid, req, res)) {
categories.getRecentReplies(cid, req.uid || req.query.uid || 0, 20, next); const feed = generateForPostsFeed({
}, title: category.name + ' Recent Posts',
}, next); description: 'A list of recent posts from ' + category.name,
}, feed_url: '/category/' + cid + '/recentposts.rss',
function (results, next) { site_url: '/category/' + cid + '/recentposts',
if (!results.category) { }, postData);
return controllers404.send404(req, res);
} sendFeed(feed, res);
category = results.category; }
posts = results.posts;
validateTokenIfRequiresLogin(!results.privileges.read, cid, req, res, next);
},
function () {
var feed = generateForPostsFeed({
title: category.name + ' Recent Posts',
description: 'A list of recent posts from ' + category.name,
feed_url: '/category/' + cid + '/recentposts.rss',
site_url: '/category/' + cid + '/recentposts',
}, posts);
sendFeed(feed, res);
},
], callback);
} }
function generateForPostsFeed(feedOptions, posts) { function generateForPostsFeed(feedOptions, posts) {
@ -477,45 +366,36 @@ function generateForPostsFeed(feedOptions, posts) {
return feed; return feed;
} }
function generateForUserTopics(req, res, callback) { async function generateForUserTopics(req, res, next) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
var userslug = req.params.userslug; const userslug = req.params.userslug;
const uid = await user.getUidByUserslug(userslug);
async.waterfall([ if (!uid) {
function (next) { return next();
user.getUidByUserslug(userslug, next); }
}, const userData = await user.getUserFields(uid, ['uid', 'username']);
function (uid, next) { await sendTopicsFeed({
if (!uid) { uid: req.uid,
return callback(); title: 'Topics by ' + userData.username,
} description: 'A list of topics that are posted by ' + userData.username,
user.getUserFields(uid, ['uid', 'username'], next); feed_url: '/user/' + userslug + '/topics.rss',
}, site_url: '/user/' + userslug + '/topics',
function (userData, next) { }, 'uid:' + userData.uid + ':topics', res);
sendTopicsFeed({
uid: req.uid,
title: 'Topics by ' + userData.username,
description: 'A list of topics that are posted by ' + userData.username,
feed_url: '/user/' + userslug + '/topics.rss',
site_url: '/user/' + userslug + '/topics',
}, 'uid:' + userData.uid + ':topics', req, res, next);
},
], callback);
} }
function generateForTag(req, res, next) { async function generateForTag(req, res) {
if (meta.config['feeds:disableRSS']) { if (meta.config['feeds:disableRSS']) {
return controllers404.send404(req, res); return controllers404.send404(req, res);
} }
var tag = validator.escape(String(req.params.tag)); const tag = validator.escape(String(req.params.tag));
var page = parseInt(req.query.page, 10) || 1; const page = parseInt(req.query.page, 10) || 1;
var topicsPerPage = meta.config.topicsPerPage || 20; const topicsPerPage = meta.config.topicsPerPage || 20;
var start = Math.max(0, (page - 1) * topicsPerPage); const start = Math.max(0, (page - 1) * topicsPerPage);
var stop = start + topicsPerPage - 1; const stop = start + topicsPerPage - 1;
sendTopicsFeed({ await sendTopicsFeed({
uid: req.uid, uid: req.uid,
title: 'Topics tagged with ' + tag, title: 'Topics tagged with ' + tag,
description: 'A list of topics that have been tagged with ' + tag, description: 'A list of topics that have been tagged with ' + tag,
@ -523,10 +403,10 @@ function generateForTag(req, res, next) {
site_url: '/tags/' + tag, site_url: '/tags/' + tag,
start: start, start: start,
stop: stop, stop: stop,
}, 'tag:' + tag + ':topics', req, res, next); }, 'tag:' + tag + ':topics', res);
} }
function sendFeed(feed, res) { function sendFeed(feed, res) {
var xml = feed.xml(); const xml = feed.xml();
res.type('xml').set('Content-Length', Buffer.byteLength(xml)).send(xml); res.type('xml').set('Content-Length', Buffer.byteLength(xml)).send(xml);
} }

Loading…
Cancel
Save