rsshub
Version:
Make RSS Great Again!
44 lines (43 loc) • 1.67 kB
JavaScript
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";
import markdownit from "markdown-it";
//#region lib/routes/gitlab/release.ts
const md = markdownit({
html: true,
linkify: true
});
const route = {
path: "/release/:namespace/:project/:host?",
categories: ["programming"],
example: "/gitlab/release/gitlab-org/gitlab-runner",
parameters: {
namespace: "owner or namespace. `/` needs to be replaced with `%2F`",
project: "project name",
host: "Gitlab instance hostname, default to gitlab.com"
},
name: "Releases",
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}/releases`);
return {
title: `${project} - Releases - Gitlab`,
link: `https://${host}/${namespace}/${project}/-/releases`,
description: `${namespace}/${project} Releases`,
item: data.map((item) => ({
title: item.name,
author: item.author.name,
description: md.render(item.description),
pubDate: parseDate(item.released_at),
link: item._links.self
}))
};
}
//#endregion
export { route };