rsshub
Version:
Make RSS Great Again!
67 lines (65 loc) • 2.43 kB
JavaScript
import "./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 "./md5-C8GRvctM.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as hash } from "./utils-BQjhp5B5.mjs";
//#region lib/routes/dockerhub/tag.ts
const route = {
path: "/tag/:owner/:image/:limits?",
categories: ["program-update"],
example: "/dockerhub/tag/library/mariadb",
parameters: {
owner: "Image owner",
image: "Image name",
limits: "Tag count, 10 by default"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "Image New Tag",
maintainers: ["pseudoyu"],
handler,
description: `::: warning
Use \`library\` as the \`owner\` for official images, such as [https://rsshub.app/dockerhub/tag/library/mysql](https://rsshub.app/dockerhub/tag/library/mysql)
:::`
};
async function handler(ctx) {
const { owner, image, limits } = ctx.req.param();
const namespace = `${owner}/${image}`;
const link = `https://hub.docker.com/r/${namespace}`;
const pageSize = Number.isNaN(Number.parseInt(limits)) ? 10 : Number.parseInt(limits);
const data = await got_default.get(`https://hub.docker.com/v2/repositories/${namespace}/tags/?page_size=${pageSize}`);
const metadata = await got_default.get(`https://hub.docker.com/v2/repositories/${namespace}/`);
const tags = data.data.results;
return {
title: `${namespace} tags`,
description: metadata.data.description,
link,
language: "en",
item: tags.map((item) => {
const architectures = item.images?.length ? item.images.map((img) => `${img.os}/${img.architecture}`).join(", ") : "unknown architectures";
const imageDigest = item.digest?.replace(":", "-") || "";
const layerLink = `https://hub.docker.com/layers/${owner === "library" ? `${image}/` : ""}${namespace}/${item.name}/images/${imageDigest}`;
return {
title: `${namespace}:${item.name} was updated`,
description: `${namespace}:${item.name} was updated, supporting the ${architectures}`,
link: layerLink,
author: owner,
pubDate: parseDate(item.tag_last_pushed),
guid: `${namespace}:${item.name}@${hash(item.images || [])}`
};
})
};
}
//#endregion
export { route };