diff --git a/bun.lockb b/bun.lockb index 28c7ae4..f38cf1d 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/projects/backend/src/controller/app.controller.ts b/projects/backend/src/controller/app.controller.ts index b646126..a636562 100644 --- a/projects/backend/src/controller/app.controller.ts +++ b/projects/backend/src/controller/app.controller.ts @@ -1,5 +1,6 @@ import { Controller, Get } from "elysia-decorators"; import { getAppVersion } from "../common/app-utils"; +import { AppService } from "../service/app.service"; @Controller() export default class AppController { @@ -10,4 +11,9 @@ export default class AppController { version: getAppVersion(), }; } + + @Get("/statistics") + public async getStatistics() { + return await AppService.getAppStatistics(); + } } diff --git a/projects/backend/src/service/app.service.ts b/projects/backend/src/service/app.service.ts new file mode 100644 index 0000000..2575987 --- /dev/null +++ b/projects/backend/src/service/app.service.ts @@ -0,0 +1,15 @@ +import { PlayerModel } from "../model/player"; +import { AppStatistics } from "@ssr/common/types/backend/app-statistics"; + +export class AppService { + /** + * Gets the app statistics. + */ + public static async getAppStatistics(): Promise { + const trackedPlayers = await PlayerModel.countDocuments(); + + return { + trackedPlayers, + }; + } +} diff --git a/projects/common/src/types/backend/app-statistics.ts b/projects/common/src/types/backend/app-statistics.ts new file mode 100644 index 0000000..d41543b --- /dev/null +++ b/projects/common/src/types/backend/app-statistics.ts @@ -0,0 +1,6 @@ +export type AppStatistics = { + /** + * The total amount of players being tracked. + */ + trackedPlayers: number; +}; diff --git a/projects/website/package.json b/projects/website/package.json index c1103e0..e57194f 100644 --- a/projects/website/package.json +++ b/projects/website/package.json @@ -39,6 +39,7 @@ "node-cache": "^5.1.2", "react": "19.0.0-rc-3edc000d-20240926", "react-chartjs-2": "^5.2.0", + "react-countup": "^6.5.3", "react-dom": "19.0.0-rc-3edc000d-20240926", "react-hook-form": "^7.53.0", "tailwind-merge": "^2.5.2", diff --git a/projects/website/src/app/(pages)/page.tsx b/projects/website/src/app/(pages)/page.tsx index 30816af..e468de5 100644 --- a/projects/website/src/app/(pages)/page.tsx +++ b/projects/website/src/app/(pages)/page.tsx @@ -1,3 +1,32 @@ -export default function HomePage() { - return
hi
; +import { Button } from "@/components/ui/button"; +import Link from "next/link"; +import ky from "ky"; +import { config } from "../../../config"; +import { AppStatistics } from "@ssr/common/types/backend/app-statistics"; +import Statistic from "@/components/home/statistic"; + +export default async function HomePage() { + const statistics = await ky.get(config.siteApi + "/statistics").json(); + + return ( +
+
+

ScoreSaber Reloaded

+

Welcome to the ScoreSaber Reloaded website.

+
+ +
+

ScoreSaber Reloaded is a website that allows you to track your ScoreSaber data over time.

+
+ +
+

Site Statistics

+ +
+ + + + +
+ ); } diff --git a/projects/website/src/components/home/statistic.tsx b/projects/website/src/components/home/statistic.tsx new file mode 100644 index 0000000..e090ef1 --- /dev/null +++ b/projects/website/src/components/home/statistic.tsx @@ -0,0 +1,16 @@ +"use client"; + +import CountUp from "react-countup"; + +type Statistic = { + title: string; + value: number; +}; + +export default function Statistic({ title, value }: Statistic) { + return ( +

+ {title}: +

+ ); +}