Skip to content

Commit

Permalink
feat: use universal load function for tools/[toolId]
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin committed Feb 28, 2025
1 parent 8818fc8 commit ac60722
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 46 deletions.
46 changes: 0 additions & 46 deletions src/routes/tools/[toolId]/+layout.server.ts

This file was deleted.

26 changes: 26 additions & 0 deletions src/routes/tools/[toolId]/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { base } from "$app/paths";
import type { ReviewStatus } from "$lib/types/Review";
import type { Tool } from "$lib/types/Tool.js";
import type { Serialize } from "$lib/utils/serialize";
import { error } from "@sveltejs/kit";

export const load = async ({ params, fetch }) => {
const r = await fetch(`${base}/api/v2/tools/${params.toolId}`);

if (!r.ok) {
throw error(r.status, r.statusText);
}

const data = await r.json();

return {
tool: data as Serialize<
Tool & {
createdById: string | null;
createdByMe: boolean;
reported: boolean;
review: ReviewStatus;
}
>,
};
};

0 comments on commit ac60722

Please sign in to comment.