add author page!
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import { FirRouteInput, FirRouteOptions } from "../util/routewrap.ts";
|
||||
import { getAuthorGames, getReleases } from "../dbal/dbal.ts";
|
||||
|
||||
const method = "GET";
|
||||
const url = "/api/author";
|
||||
|
||||
const payloadT = Type.Any();
|
||||
|
||||
const handler = async ({payload}: FirRouteInput<typeof payloadT>) => {
|
||||
const {author} = payload;
|
||||
|
||||
if (typeof author !== "string") {
|
||||
return {
|
||||
author: null,
|
||||
releases: [],
|
||||
};
|
||||
}
|
||||
console.log("author", author);
|
||||
|
||||
const games = await getAuthorGames({author});
|
||||
|
||||
return {
|
||||
author,
|
||||
games,
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
method,
|
||||
url,
|
||||
payloadT,
|
||||
handler,
|
||||
} as const satisfies FirRouteOptions<typeof payloadT>;
|
||||
Reference in New Issue
Block a user