diff --git a/api-/gitter.ts b/api-/gitter.ts deleted file mode 100644 index 71b23df1..00000000 --- a/api-/gitter.ts +++ /dev/null @@ -1,39 +0,0 @@ -import got from '../libs/got' -import { millify } from '../libs/utils' -import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler' - -const BRAND_COLOR = 'ED1965' - -export default createBadgenHandler({ - title: 'Gitter', - examples: { - '/gitter/members/redom/lobby': 'members', - '/gitter/members/redom/redom': 'members' - }, - handlers: { - '/gitter/members/:org/:room': handler - } -}) - -async function handler ({ org, room }: PathArgs) { - const membersCount = await fetchMembersCount(org, room) - if (Number.isNaN(membersCount)) { - return { - subject: 'gitter', - status: 'unknown', - color: 'grey' - } - } - - const suffix = membersCount === 1 ? 'member' : 'members' - return { - subject: 'gitter', - status: `${millify(membersCount)} ${suffix}`, - color: BRAND_COLOR - } -} - -export async function fetchMembersCount(org: string, room: string) { - const html = await got(`https://gitter.im/${org}/${room}`).text() - return Number(html.match(/"userCount"\s*:\s*(\d+)/)?.[1]) -} diff --git a/api-/appveyor.ts b/api-legacy/appveyor.ts similarity index 100% rename from api-/appveyor.ts rename to api-legacy/appveyor.ts diff --git a/api-/azure-pipelines.ts b/api-legacy/azure-pipelines.ts similarity index 100% rename from api-/azure-pipelines.ts rename to api-legacy/azure-pipelines.ts diff --git a/api-/badgesize.ts b/api-legacy/badgesize.ts similarity index 100% rename from api-/badgesize.ts rename to api-legacy/badgesize.ts diff --git a/api-/cocoapods.ts b/api-legacy/cocoapods.ts similarity index 100% rename from api-/cocoapods.ts rename to api-legacy/cocoapods.ts diff --git a/api-/codacy.ts b/api-legacy/codacy.ts similarity index 100% rename from api-/codacy.ts rename to api-legacy/codacy.ts diff --git a/api-/cpan.ts b/api-legacy/cpan.ts similarity index 100% rename from api-/cpan.ts rename to api-legacy/cpan.ts diff --git a/api-/cran.ts b/api-legacy/cran.ts similarity index 100% rename from api-/cran.ts rename to api-legacy/cran.ts diff --git a/api-/ctan.ts b/api-legacy/ctan.ts similarity index 100% rename from api-/ctan.ts rename to api-legacy/ctan.ts diff --git a/api-/deepscan.ts b/api-legacy/deepscan.ts similarity index 100% rename from api-/deepscan.ts rename to api-legacy/deepscan.ts diff --git a/api-/dependabot.ts b/api-legacy/dependabot.ts similarity index 100% rename from api-/dependabot.ts rename to api-legacy/dependabot.ts diff --git a/api-/devrant.ts b/api-legacy/devrant.ts similarity index 100% rename from api-/devrant.ts rename to api-legacy/devrant.ts diff --git a/api-/dub.ts b/api-legacy/dub.ts similarity index 100% rename from api-/dub.ts rename to api-legacy/dub.ts diff --git a/api-/elm-package.ts b/api-legacy/elm-package.ts similarity index 100% rename from api-/elm-package.ts rename to api-legacy/elm-package.ts diff --git a/api-/f-droid.ts b/api-legacy/f-droid.ts similarity index 100% rename from api-/f-droid.ts rename to api-legacy/f-droid.ts diff --git a/api-/haxelib.ts b/api-legacy/haxelib.ts similarity index 100% rename from api-/haxelib.ts rename to api-legacy/haxelib.ts diff --git a/api-/homebrew.ts b/api-legacy/homebrew.ts similarity index 100% rename from api-/homebrew.ts rename to api-legacy/homebrew.ts diff --git a/api-/jenkins.ts b/api-legacy/jenkins.ts similarity index 100% rename from api-/jenkins.ts rename to api-legacy/jenkins.ts diff --git a/api-/jsdelivr.ts b/api-legacy/jsdelivr.ts similarity index 100% rename from api-/jsdelivr.ts rename to api-legacy/jsdelivr.ts diff --git a/api-/keybase.ts b/api-legacy/keybase.ts similarity index 100% rename from api-/keybase.ts rename to api-legacy/keybase.ts diff --git a/api-/liberapay.ts b/api-legacy/liberapay.ts similarity index 100% rename from api-/liberapay.ts rename to api-legacy/liberapay.ts diff --git a/api-/mastodon.ts b/api-legacy/mastodon.ts similarity index 100% rename from api-/mastodon.ts rename to api-legacy/mastodon.ts diff --git a/api-/maven.ts b/api-legacy/maven.ts similarity index 100% rename from api-/maven.ts rename to api-legacy/maven.ts diff --git a/api-/melpa.ts b/api-legacy/melpa.ts similarity index 100% rename from api-/melpa.ts rename to api-legacy/melpa.ts diff --git a/api-/nuget.ts b/api-legacy/nuget.ts similarity index 100% rename from api-/nuget.ts rename to api-legacy/nuget.ts diff --git a/api-/opam.ts b/api-legacy/opam.ts similarity index 100% rename from api-/opam.ts rename to api-legacy/opam.ts diff --git a/api-/opencollective.ts b/api-legacy/opencollective.ts similarity index 100% rename from api-/opencollective.ts rename to api-legacy/opencollective.ts diff --git a/api-/packagist.ts b/api-legacy/packagist.ts similarity index 100% rename from api-/packagist.ts rename to api-legacy/packagist.ts diff --git a/api-/reddit.ts b/api-legacy/reddit.ts similarity index 100% rename from api-/reddit.ts rename to api-legacy/reddit.ts diff --git a/api-/rubygems.ts b/api-legacy/rubygems.ts similarity index 100% rename from api-/rubygems.ts rename to api-legacy/rubygems.ts diff --git a/api-/scoop.ts b/api-legacy/scoop.ts similarity index 100% rename from api-/scoop.ts rename to api-legacy/scoop.ts diff --git a/api-/shards.ts b/api-legacy/shards.ts similarity index 100% rename from api-/shards.ts rename to api-legacy/shards.ts diff --git a/api-/snapcraft.ts b/api-legacy/snapcraft.ts similarity index 100% rename from api-/snapcraft.ts rename to api-legacy/snapcraft.ts diff --git a/api-/snyk.ts b/api-legacy/snyk.ts similarity index 100% rename from api-/snyk.ts rename to api-legacy/snyk.ts diff --git a/api-/tidelift.ts b/api-legacy/tidelift.ts similarity index 100% rename from api-/tidelift.ts rename to api-legacy/tidelift.ts diff --git a/api-/twitter.ts b/api-legacy/twitter.ts similarity index 100% rename from api-/twitter.ts rename to api-legacy/twitter.ts diff --git a/api-/uptime-robot.ts b/api-legacy/uptime-robot.ts similarity index 100% rename from api-/uptime-robot.ts rename to api-legacy/uptime-robot.ts diff --git a/api-/wapm.ts b/api-legacy/wapm.ts similarity index 100% rename from api-/wapm.ts rename to api-legacy/wapm.ts diff --git a/libs/badge-list.ts b/libs/badge-list.ts index 89cb58b4..76875b67 100644 --- a/libs/badge-list.ts +++ b/libs/badge-list.ts @@ -41,8 +41,6 @@ export const liveBadgeList = [ // social 'devrant', 'reddit', - // chat - 'gitter', // utilities 'opencollective', 'keybase', @@ -55,7 +53,7 @@ export const liveBadgeList = [ export async function loadBadgeMeta() { const liveBadgeExamples = await Promise.all(liveBadgeList.map(async id => { - const mod = await import(rel('../api-', id)) + const mod = await import(rel('../api-legacy', id)) const { title, examples, handlers } = mod.default.meta return { diff --git a/libs/got.ts b/libs/got.ts index 796ccf03..c5023a79 100644 --- a/libs/got.ts +++ b/libs/got.ts @@ -2,7 +2,7 @@ import got from 'got' export default got.extend({ timeout: { - request: 4600, + request: 6400, }, retry: { limit: 0, diff --git a/next.config.js b/next.config.js index e8b6cfce..81bc50b9 100644 --- a/next.config.js +++ b/next.config.js @@ -54,6 +54,7 @@ const nextConfig = { '/xo', // social network '/discord', + '/gitter', '/matrix', '/runkit', '/peertube', diff --git a/pages/api/matrix.ts b/pages/api/matrix.ts index 94571b70..4a421e78 100644 --- a/pages/api/matrix.ts +++ b/pages/api/matrix.ts @@ -1,7 +1,6 @@ import { Got } from 'got' import got from '../../libs/got' import { millify } from '../../libs/utils' -import { fetchMembersCount as fetchGitterMembersCount } from '../../api-/gitter' import { createBadgenHandler, PathArgs } from '../../libs/create-badgen-handler-next' const BRAND_COLOR = 'black' @@ -12,7 +11,6 @@ export default createBadgenHandler({ '/matrix/members/rust/matrix.org': 'members', '/matrix/members/thisweekinmatrix': 'members', '/matrix/members/archlinux/archlinux.org': 'members', - '/matrix/members/redom_redom/gitter.im': 'members' }, handlers: { '/matrix/members/:room/:server?': handler @@ -44,10 +42,6 @@ async function handler ({ room, server = 'matrix.org' }: PathArgs) { } async function fetchMembersCount(roomName: string, server: string) { - if (server === 'gitter.im') { - const [gitterOrg, gitterRoom] = roomName.split('_') - return fetchGitterMembersCount(gitterOrg, gitterRoom) - } const homeserver = await getHomeserver(server) const client = got.extend({ prefixUrl: `${homeserver}/_matrix/client/r0` }) const roomAlias = `#${roomName}:${server}` diff --git a/tsconfig.json b/tsconfig.json index 1ada543d..e48a1b8a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,7 +29,7 @@ ] }, "include": [ - "api-", + "api-legacy", "libs", "index.ts", "components",