UNPKG

rsshub

Version:
40 lines (39 loc) 1.62 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as config } from "./config-Bpyy15zS.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as ConfigNotFoundError } from "./config-not-found-fQ5mxvDU.mjs"; import { t as allowHost } from "./common-BqKKt6v9.mjs"; //#region lib/routes/gitlab/tag.ts const route = { path: "/tag/:namespace/:project/:host?", categories: ["programming"], example: "/gitlab/tag/rluna-open-source%2Ffile-management%2Fowncloud/core/gitlab.com", parameters: { namespace: "owner or namespace. `/` needs to be replaced with `%2F`", project: "project name", host: "Gitlab instance hostname, default to gitlab.com" }, features: { antiCrawler: true }, name: "Tags", maintainers: ["zoenglinghou"], handler }; async function handler(ctx) { const { namespace, project, host = "gitlab.com" } = ctx.req.param(); if (!config.feature.allow_user_supply_unsafe_domain && !allowHost.includes(new URL(`https://${host}/`).hostname)) throw new ConfigNotFoundError(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`); const data = await rofetch(`https://${host}/api/v4/projects/${encodeURIComponent(namespace)}%2F${project}/repository/tags`); return { title: `${project} - Tags - Gitlab`, link: `https://${host}/${namespace}/${project}/-/tags`, description: `${namespace}/${project} Tags`, item: data.map((item) => ({ title: item.name, author: item.commit.author_name, description: item.message, pubDate: parseDate(item.commit.created_at), link: item.commit.web_url })) }; } //#endregion export { route };