feat(admin) : show Lunaris version and link guide cards
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import "server-only";
|
||||
|
||||
import { and, asc, eq, inArray, isNotNull, isNull } from "drizzle-orm";
|
||||
import * as z from "zod";
|
||||
|
||||
import { getDb } from "@/db";
|
||||
import {
|
||||
@@ -20,7 +21,9 @@ import {
|
||||
teamMembers,
|
||||
weaponRecommendations,
|
||||
} from "@/db/schema";
|
||||
import { publicMediaUrl } from "@/lib/media/storage";
|
||||
import { getMediaStorage, publicMediaUrl } from "@/lib/media/storage";
|
||||
|
||||
const catalogVersionSchema = z.object({ version: z.string() });
|
||||
|
||||
function catalogCharacterWithUrls(item: typeof catalogCharacters.$inferSelect) {
|
||||
return {
|
||||
@@ -48,7 +51,12 @@ export async function getActiveCatalog() {
|
||||
db.select().from(catalogArtifacts).orderBy(asc(catalogArtifacts.name)),
|
||||
]);
|
||||
if (!characters.length) return null;
|
||||
const storage = await getMediaStorage();
|
||||
const { version } = catalogVersionSchema.parse(
|
||||
await storage.file("catalog/current.json").json(),
|
||||
);
|
||||
return {
|
||||
version,
|
||||
characters: characters.map(catalogCharacterWithUrls),
|
||||
weapons: weapons.map((item) => ({ ...item, imageUrl: publicMediaUrl(item.imageKey) })),
|
||||
artifacts: artifacts.map((item) => ({ ...item, imageUrl: publicMediaUrl(item.imageKey) })),
|
||||
|
||||
Reference in New Issue
Block a user