rsshub
Version:
Make RSS Great Again!
45 lines (43 loc) • 1.49 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./types-D84BRIt4.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import { n as CommonDataProperties, r as CommonRouteProperties, s as getPostItems } from "./common-Bz4cAewj.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 };