Files
RSSHub/lib/routes/test/index.js
T
Henry Wang e1d91a591e del: line breaker handling in middleware (#1592)
* del: remove line breaker handling

As it's slowing down RSSHub drastically

* del: related test case

* feat: weibo line breaker handling
2019-02-21 15:24:55 +08:00

43 lines
1.3 KiB
JavaScript

const config = require('../../config');
let cacheIndex = 0;
module.exports = async (ctx) => {
if (ctx.params.id === '0') {
throw Error('Error test');
}
const item = [];
if (ctx.params.id === 'long') {
item.push({
title: `Long Title `.repeat(10),
description: `Long Description `.repeat(10),
pubDate: new Date(`2018-3-1`).toUTCString(),
link: `https://github.com/DIYgod/RSSHub/issues/0`,
author: `DIYgod0`,
});
} else if (ctx.params.id === 'cache') {
const description = await ctx.cache.tryGet('test', () => `Cache${++cacheIndex}`, config.cacheExpire * 2);
item.push({
title: 'Cache Title',
description: description,
pubDate: new Date(`2018-3-1`).toUTCString(),
link: `https://github.com/DIYgod/RSSHub/issues/0`,
author: `DIYgod0`,
});
}
for (let i = 1; i < 6; i++) {
item.push({
title: `Title${i}`,
description: `Description${i}`,
pubDate: new Date(`2018-4-${i}`).toUTCString(),
link: `https://github.com/DIYgod/RSSHub/issues/${i}`,
author: `DIYgod${i}`,
});
}
ctx.state.data = {
title: `Test ${ctx.params.id}`,
link: 'https://github.com/DIYgod/RSSHub',
item: item,
};
};