new format wip

This commit is contained in:
Dylan Pizzo
2026-06-10 21:47:30 -04:00
parent 07595c31ef
commit 876404d8f5
45 changed files with 10893 additions and 144129 deletions
+40 -10
View File
@@ -1,29 +1,59 @@
import { Type } from "@sinclair/typebox";
import { FirRouteInput, FirRouteOptions } from "../util/routewrap.ts";
import { getAuthorGames, getReleases } from "../dbal/dbal.ts";
import { authors } from "../../data/authors.ts";
import { Octokit } from "octokit";
import { decrypt } from "../util/crypt.ts";
const method = "GET";
const url = "/api/author";
const payloadT = Type.Any();
const handler = async ({payload}: FirRouteInput<typeof payloadT>) => {
const {author} = payload;
const handler = async ({ payload }: FirRouteInput<typeof payloadT>) => {
const { author } = payload;
if (typeof author !== "string") {
const authorData = authors.find((x) => x.username === author);
if (!authorData) {
return {
author: null,
releases: [],
games: [],
};
}
console.log("author", author);
console.log("author", authorData);
const pat = decrypt({
password: process.env.ENCRYPTION_PASSWORD!,
cyphertext: authorData.auth.pat,
});
const octokit = new Octokit({
auth: pat,
});
const gameStuff = await octokit.rest.repos.getContent({
owner: authorData.username,
repo: authorData.repo,
path: ".picobook",
});
// TODO: get the games.
const games: string[] = [];
if (Array.isArray(gameStuff.data)) {
games.push(
...gameStuff.data
.map((x) => x.name)
.filter((x) => x.endsWith(".p8.png"))
.map((x) => x.slice(0, -".p8.png".length)),
);
console.log("hi");
}
const games = await getAuthorGames({author});
return {
author,
games,
}
};
};
export default {
@@ -31,4 +61,4 @@ export default {
url,
payloadT,
handler,
} as const satisfies FirRouteOptions<typeof payloadT>;
} as const satisfies FirRouteOptions<typeof payloadT>;