From f303794f5c877aaa8db8fcb5d62dddd0f0d03111 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 15 Oct 2024 19:26:55 +0100 Subject: [PATCH] cleanup --- projects/backend/src/common/open-graph.tsx | 54 ------------------- .../backend/src/service/player.service.tsx | 52 +++++++++++++++++- 2 files changed, 50 insertions(+), 56 deletions(-) delete mode 100644 projects/backend/src/common/open-graph.tsx diff --git a/projects/backend/src/common/open-graph.tsx b/projects/backend/src/common/open-graph.tsx deleted file mode 100644 index 8dc59ec..0000000 --- a/projects/backend/src/common/open-graph.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { ImageResponse } from "@vercel/og"; -import { formatNumberWithCommas, formatPp } from "website/src/common/number-utils"; -import { config } from "website/config"; -import React from "react"; -import ScoreSaberPlayerToken from "@ssr/common/types/token/scoresaber/score-saber-player-token"; - -export function generatePlayerOgImage(player: ScoreSaberPlayerToken) { - return new ImageResponse( - ( -
- Player's Avatar -
-

{player.name}

-

{formatPp(player.pp)}pp

-
-
- - - -

#{formatNumberWithCommas(player.rank)}

-
-
- {/* eslint-disable-next-line @next/next/no-img-element */} - Player's Country -

#{formatNumberWithCommas(player.countryRank)}

-
-
-
-
- ), - { - width: 1200, - height: 630, - emoji: "twemoji", - } - ); -} diff --git a/projects/backend/src/service/player.service.tsx b/projects/backend/src/service/player.service.tsx index 26e2b52..244b86d 100644 --- a/projects/backend/src/service/player.service.tsx +++ b/projects/backend/src/service/player.service.tsx @@ -5,7 +5,10 @@ import { scoresaberService } from "@ssr/common/service/impl/scoresaber"; import ScoreSaberPlayerToken from "@ssr/common/types/token/scoresaber/score-saber-player-token"; import { InternalServerError } from "../error/internal-server-error"; import ScoreSaberPlayerScoreToken from "@ssr/common/types/token/scoresaber/score-saber-player-score-token"; -import { generatePlayerOgImage } from "../common/open-graph"; +import { ImageResponse } from "@vercel/og"; +import { formatNumberWithCommas, formatPp } from "website/src/common/number-utils"; +import { config } from "website/config"; +import React from "react"; export class PlayerService { /** @@ -167,6 +170,51 @@ export class PlayerService { if (player == undefined) { return undefined; } - return generatePlayerOgImage(player); + return new ImageResponse( + ( +
+ Player's Avatar +
+

{player.name}

+

{formatPp(player.pp)}pp

+
+
+ + + +

#{formatNumberWithCommas(player.rank)}

+
+
+ {/* eslint-disable-next-line @next/next/no-img-element */} + Player's Country +

#{formatNumberWithCommas(player.countryRank)}

+
+
+
+
+ ), + { + width: 1200, + height: 630, + emoji: "twemoji", + } + ); } }