Files
RSSHub/lib/v2/dockerhub/build.js
Outvi V 41a06a22bb feat(route): add dockerhub image new tag (#8965)
* feat: /dockerhub/tags/:owner/:image

fix #6916

* fix: update the doc link of /dockerhub/build

* docs(en): /dockerhub/tag/:owner/:image

* docs: fix typo

* fix(dockerhub/tags): use parseDate()

* docs: link docs to h2 instead of h3

* chore: move /dockerhub/build to v2

* docs: put warning inside <Route>

* fix(dockerhub): use docker.com/hub as the radar path

* fix(dockerhub/tag): add :limits?

* feat(dockerhub): polish the GUID

* fix(dockerhub/tag): stricter argument checks

* fix(dockerhub/tag): handle NaN per Deepscan CI
2022-02-03 00:09:01 +08:00

32 lines
1.2 KiB
JavaScript

const got = require('@/utils/got');
const { hash } = require('./utils');
module.exports = async (ctx) => {
const { owner, image, tag = 'latest' } = ctx.params;
const namespace = `${owner}/${image}`;
const link = `https://hub.docker.com/r/${namespace}`;
const data = await got.get(`https://hub.docker.com/v2/repositories/${namespace}/tags/${tag}`);
const metadata = await got.get(`https://hub.docker.com/v2/repositories/${namespace}/`);
const item = data.data;
ctx.state.data = {
title: `${namespace}:${tag} build history`,
description: metadata.data.description,
link,
item: [
{
title: `${namespace}:${tag} was built. ${(item.images[0].size / 1000000).toFixed(2)} MB`,
link: `https://hub.docker.com/layers/docker/${namespace}/${tag}/images/${item.images[0].digest.replace(':', '-')}`,
author: owner,
pubDate: new Date(item.last_updated).toUTCString(),
// only check for different images hashes (considering varients of all arches), since the tag name is already fixed
guid: hash(item.images),
},
],
};
};