feat: migrate /peertube. Fix #572

pull/625/head
Amio 2023-07-09 17:52:24 +08:00 zatwierdzone przez Amio Jin
rodzic f5e72c4c00
commit e9dccf4391
6 zmienionych plików z 20 dodań i 14 usunięć

Wyświetl plik

@ -45,7 +45,6 @@ export const liveBadgeList = [
'jsdelivr',
// social
'devrant',
'peertube',
'reddit',
// chat
'gitter',

Wyświetl plik

@ -12,6 +12,7 @@ import chromeWebStore from '../pages/api/chrome-web-store'
import vsMarketplace from '../pages/api/vs-marketplace'
import hackage from '../pages/api/hackage'
import pypi from '../pages/api/pypi'
import peertube from '../pages/api/peertube'
import discord from '../pages/api/discord'
import matrix from '../pages/api/matrix'
import runkit from '../pages/api/runkit'
@ -34,6 +35,7 @@ export default {
codeclimate: codeclimate.meta,
codecov: codecov.meta,
travis: travis.meta,
peertube: peertube.meta,
discord: discord.meta,
matrix: matrix.meta,
runkit: runkit.meta,

Wyświetl plik

@ -2,7 +2,7 @@ import got from 'got'
export default got.extend({
timeout: {
request: 4200,
request: 4600,
},
retry: {
limit: 0,

Wyświetl plik

@ -64,6 +64,7 @@ const nextConfig = {
'/discord',
'/matrix',
'/runkit',
'/peertube',
// discontinued
'/apm',
'/lgtm',

Wyświetl plik

@ -1,6 +1,6 @@
import got from '../libs/got'
import { millify } from '../libs/utils'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
import got from '../../libs/got'
import { millify } from '../../libs/utils'
import { createBadgenHandler, PathArgs } from '../../libs/create-badgen-handler-next'
const BRAND_COLOR = 'F1680D'
@ -27,7 +27,7 @@ async function handler ({ instance, topic, 'video-uuid': videoUUID }: PathArgs)
switch (topic) {
case 'comments': {
const { total } = await client.get(`/videos/${videoUUID}/comment-threads`).json<any>()
const { total } = await client.get(`videos/${videoUUID}/comment-threads`).json<any>()
return {
subject: 'comments',
status: millify(total),
@ -35,19 +35,27 @@ async function handler ({ instance, topic, 'video-uuid': videoUUID }: PathArgs)
}
}
case 'views': {
const { views } = await client.get(`/videos/${videoUUID}`).json<any>()
const { views } = await client.get(`videos/${videoUUID}`).json<any>()
return {
subject: 'views',
status: millify(views),
color: BRAND_COLOR
}
}
default:
return {
subject: 'peertube',
status: 'unknown topic',
color: 'grey'
}
}
}
async function votesHandler ({ instance, 'video-uuid': videoUUID, format }: PathArgs) {
const client = createClient(instance)
const { likes, dislikes } = await client.get(`/videos/${videoUUID}`).json<any>()
console.log(33)
const { likes, dislikes } = await client.get(`videos/${videoUUID}`).json<any>()
console.log(44)
switch (format) {
case 'likes': {
@ -76,7 +84,7 @@ async function followersHandler ({ instance, account, channel }: PathArgs) {
const client = createClient(instance)
if (channel) {
const { followersCount } = await client.get(`/video-channels/${channel}`).json<any>()
const { followersCount } = await client.get(`video-channels/${channel}`).json<any>()
return {
subject: 'followers',
status: millify(followersCount),
@ -84,7 +92,7 @@ async function followersHandler ({ instance, account, channel }: PathArgs) {
}
}
const { followersCount } = await client.get(`/accounts/${account}`).json<any>()
const { followersCount } = await client.get(`accounts/${account}`).json<any>()
return {
subject: 'followers',
status: millify(followersCount),

Wyświetl plik

@ -142,10 +142,6 @@
"source": "/packagist/:match*",
"destination": "https://v2022.badgen.net/packagist/:match*"
},
{
"source": "/peertube/:match*",
"destination": "https://v2022.badgen.net/peertube/:match*"
},
{
"source": "/pub/:match*",
"destination": "https://v2022.badgen.net/pub/:match*"