Files
RSSHub/lib/v2/huxiu/moment.js
T
Ethan Shen 804a4abbf3 feat(route): add 虎嗅频道 & 源流 (#13945)
* feat(route): add 虎嗅频道 & 源流

* fix: limit to 20

* docs: remove rssbud
2023-12-05 00:38:27 +08:00

26 lines
708 B
JavaScript

const got = require('@/utils/got');
const { rootUrl, apiMomentRootUrl, processItems, fetchData } = require('./util');
module.exports = async (ctx) => {
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 20;
const apiUrl = new URL('web-v2/moment/feed', apiMomentRootUrl).href;
const currentUrl = new URL('moment', rootUrl).href;
const { data: response } = await got.post(apiUrl, {
form: {
platform: 'www',
},
});
const items = await processItems(response.data.moment_list.datalist[0].datalist, limit, ctx.cache.tryGet);
const data = await fetchData(currentUrl);
ctx.state.data = {
item: items,
...data,
};
};