Skip to content

Commit

Permalink
why does it run npm run build on my pc but doesn't work gdsopfjs]das
Browse files Browse the repository at this point in the history
  • Loading branch information
AntGa committed Oct 1, 2024
1 parent 83d9f4e commit 22bd97a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
26 changes: 16 additions & 10 deletions src/scripts/serveTeamDescriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,42 @@ import { PrismaClient } from '@prisma/client';
// Initialize Prisma Client
const prisma = new PrismaClient();

// Define the structure of the team with tags included
type TeamWithTags = {
name: string;
description: string | null;
tags: { name: string }[]; // Array of tag objects with 'name' field
};

type TeamDescriptions = {
name: string;
description?: string;
tags?: string[]; // Array of tag names
};

export async function serveTeamDescriptions(): Promise<TeamDescriptions[]> {
let teamDescriptions: TeamDescriptions[] = []; // Explicitly type the result variable
let teamDescriptions: TeamDescriptions[] = [];

try {
// Fetch team descriptions with their related tags

const descriptions = await prisma.teamDescription.findMany({
include: {
tags: true, // Fetch related tags
tags: true,
},
});
}) as TeamWithTags[];

// Map the results to the TeamDescriptions type

teamDescriptions = descriptions.map((team) => ({
name: team.name,
description: team.description ?? undefined, // Handle null values for description
tags: team.tags.map((tag) => tag.name) || [], // Convert tag objects to an array of tag names
description: team.description ?? undefined,
tags: team.tags?.map((tag) => tag.name) || [],
}));

} catch (err) {
console.error("Error fetching team descriptions:", err);
teamDescriptions = []; // Fallback to an empty array in case of error
teamDescriptions = [];
} finally {
// Close Prisma Client connection
await prisma.$disconnect();
await prisma.$disconnect();
}

return teamDescriptions;
Expand Down
8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "react"
"jsxImportSource": "react",
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"verbatimModuleSyntax": true,
"isolatedModules": true

}
}

0 comments on commit 22bd97a

Please sign in to comment.