UNPKG

rsshub

Version:
76 lines (71 loc) 2.31 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-rr4AgGpp.mjs"; import { t as isValidHost } from "./valid-host-C-u5eW3j.mjs"; import path from "node:path"; //#region lib/routes/ff14/ff14-global.ts init_esm_shims(); const route = { path: ["/global/:lang/:type?", "/ff14_global/:lang/:type?"], categories: ["game"], example: "/ff14/global/na/all", parameters: { lang: "Region", type: "Category, `all` by default" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "FINAL FANTASY XIV (The Lodestone)", maintainers: ["kmod-midori"], handler, description: `Region | North Ameria | Europe | France | Germany | Japan | | ------------ | ------ | ------ | ------- | ----- | | na | eu | fr | de | jp | Category | all | topics | notices | maintenance | updates | status | developers | | --- | ------ | ------- | ----------- | ------- | ------ | ---------- |` }; async function handler(ctx) { const lang = ctx.req.param("lang"); const type = ctx.req.param("type") ?? "all"; if (!isValidHost(lang)) throw new invalid_parameter_default("Invalid lang"); const response = await got_default({ method: "get", url: `https://lodestonenews.com/news/${type}?locale=${lang}` }); let data; if (type === "all") { data = []; for (const arr of Object.values(response.data)) data = [...data, ...arr]; } else data = response.data; return { title: `FFXIV Lodestone updates (${type})`, link: `https://${lang}.finalfantasyxiv.com/lodestone/news/`, item: data.map(({ id, url, title, time, description, image }) => ({ title, link: url, description: art(path.join(__dirname, "templates/description-fc190f49.art"), { image, description }), pubDate: parseDate(time), guid: id })) }; } //#endregion export { route };