From 4919f028c884a041da7ff098abb02389b4eac598 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Tue, 18 Apr 2023 03:02:17 +0800 Subject: ✨add envshare docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/stats.tsx | 57 ------------------------------------------------ 1 file changed, 57 deletions(-) delete mode 100644 app/components/stats.tsx (limited to 'app/components/stats.tsx') diff --git a/app/components/stats.tsx b/app/components/stats.tsx deleted file mode 100644 index 31d74bc..0000000 --- a/app/components/stats.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { Redis } from "@upstash/redis"; - -const redis = Redis.fromEnv(); -export const revalidate = 60; - -export const Stats = asyncComponent(async () => { - const [reads, writes] = await redis - .pipeline() - .get("envshare:metrics:reads") - .get("envshare:metrics:writes") - .exec<[number, number]>(); - const stars = await fetch("https://api.github.com/repos/chronark/envshare") - .then((res) => res.json()) - .then((json) => json.stargazers_count as number); - - const stats = [ - { - label: "Documents Encrypted", - value: writes, - }, - { - label: "Documents Decrypted", - value: reads, - }, - ] satisfies { label: string; value: number }[]; - - if (stars) { - stats.push({ - label: "GitHub Stars", - value: stars, - }); - } - - return ( -
- -
- ); -}); - -// stupid hack to make "server components" actually work with components -// https://www.youtube.com/watch?v=h_9Vx6kio2s -function asyncComponent(fn: (arg: T) => Promise): (arg: T) => R { - return fn as (arg: T) => R; -} -- cgit v1.2.3-70-g09d2