UNPKG

rsshub

Version:
44 lines (42 loc) 1.46 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import { t as ofetch_default } from "./ofetch-DKl_Ma9g.mjs"; import "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import { n as CommonDataProperties, r as CommonRouteProperties, s as getPostItems } from "./common-DWurjA1H.mjs"; //#region lib/routes/voronoiapp/author.ts const route = { ...CommonRouteProperties, name: "Author Posts", path: "/author/:username", radar: [{ source: ["www.voronoiapp.com/author/:username"], target: "/author/:username" }], example: "/voronoiapp/author/visualcapitalist", parameters: { username: "The username of the author" }, handler: async (ctx) => { const { username } = ctx.req.param(); const items = await getPostItems({ order: "DESC", author: await getUidFromUsername(username) }); return { ...CommonDataProperties, title: `Voronoi Posts by ${username}`, link: `https://www.voronoiapp.com/author/${username}`, item: items }; } }; async function getUidFromUsername(username) { return await cache_default.tryGet(`voronoiapp-author-${username}`, async () => { const match = (await ofetch_default(`https://www.voronoiapp.com/author/${username}`)).match(/\\"uid\\":\\"([\w-]+)\\"/); if (!match) throw new Error(`No UID found for username: ${username}`); return match[1]; }); } //#endregion export { route };