mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 15:52:55 +01:00
feat: proxy avatars
This commit is contained in:
1 parent
4b8e73fa57
commit
437bee4a85
9 files changed
+47
-65
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import type { APIContext, GetStaticPaths } from "astro";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
|
||||
export const getStaticPaths = (async () => {
|
||||
const avatars = await api.avatars();
|
||||
|
||||
return avatars.map((avatar) => ({
|
||||
params: { id: avatar.name },
|
||||
}));
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
/**
|
||||
* One day I will write documentation for this
|
||||
*/
|
||||
export async function GET({ params }: APIContext<never, { id: string }>) {
|
||||
const avatar = await api.avatar(params.id);
|
||||
const profileAvatar = avatar.ProfileAvatar();
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
return Response.redirect(profileAvatar.avatar);
|
||||
}
|
||||
|
||||
const response = await fetch(profileAvatar.avatar);
|
||||
const buffer = await response.arrayBuffer();
|
||||
|
||||
return new Response(buffer);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { api } from "../../core/api/dynamic";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
|
||||
/**
|
||||
* Literally all the tanks in one place lmao.
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { api } from "../../core/api/dynamic";
|
||||
import { Tanks } from "../../protos/tanks";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
import { Tanks } from "../../../protos/tanks";
|
||||
|
||||
/**
|
||||
* Literally all the tanks in one place lmao.
|
||||
@@ -24,7 +24,7 @@ const avatars = await api.avatars();
|
||||
{ui.obtaining_methods && <p>{ui.obtaining_methods}</p>}
|
||||
{ui.features && <p>{ui.features}</p>}
|
||||
|
||||
<img width="128" src={profileAvatar.avatar} />
|
||||
<img width="128" src={`/api/avatars/${avatar.name}.webp`} />
|
||||
|
||||
{avatar.components.sellableComponent && (
|
||||
<pre>{JSON.stringify(avatar.Sellable(), null, 2)}</pre>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import "@radix-ui/colors/amber-dark.css";
|
||||
import packageJson from "../../../../package.json";
|
||||
import { tools } from "../core/tools/tools";
|
||||
import BaseLayout from "../layouts/BaseLayout.astro";
|
||||
---
|
||||
|
||||
@@ -9,9 +10,11 @@ import BaseLayout from "../layouts/BaseLayout.astro";
|
||||
|
||||
<h1>blitzkit {packageJson.version}</h1>
|
||||
|
||||
<p><a href="/tanks">/tanks</a></p>
|
||||
|
||||
<p><a href="/avatars">/avatars</a></p>
|
||||
|
||||
<p><a href="/api">/api</a></p>
|
||||
{
|
||||
Object.values(tools).map((tool) => (
|
||||
<p>
|
||||
<a href={`/${tool.id}`}>{tool.id}</a>
|
||||
</p>
|
||||
))
|
||||
}
|
||||
</BaseLayout>
|
||||
Reference in new issue
Block a user