rsshub
Version:
Make RSS Great Again!
32 lines (31 loc) • 1.34 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as InvalidParameterError } from "./invalid-parameter-CGxhjomn.mjs";
import { n as parsePost, t as apiRoot } from "./utils-BPq-vp73.mjs";
//#region lib/routes/soulapp/index.ts
const route = {
path: "/:id",
categories: ["social-media"],
example: "/soulapp/ekxWSkVQSWtZUkJ1WUNwTVhMR0V3QT09",
parameters: { id: "用户 id, 分享用户主页时的 URL 的 userIdEcpt 参数" },
name: "瞬间更新",
maintainers: ["ImSingee"],
handler
};
async function handler(ctx) {
const { id: userIdEcpt } = ctx.req.param();
const user = await cache_default.tryGet(`soulapp:user:${userIdEcpt}`, async () => {
const infoResponse = await rofetch(`${apiRoot}/html/v2/user/info?userIdEcpt=${userIdEcpt}`);
if (!infoResponse.data) throw new InvalidParameterError("User not found");
return infoResponse.data;
});
const posts = (await rofetch(`https://api-h5.soulapp.cn/html/v2/post/homepage?userIdEcpt=${userIdEcpt}`)).data ?? [];
return {
title: `「${user.signature}」的瞬间`,
link: `https://w3.soulsmile.cn/activity/#/web/user?userIdEcpt=${userIdEcpt}`,
image: `https://china-img.soulapp.cn/heads/${user.avatarName}.png`,
item: posts.map((item) => parsePost(item))
};
}
//#endregion
export { route };