Skip to content

Commit

Permalink
Refactor sitemap.xml server.ts
Browse files Browse the repository at this point in the history
Exclude user-specific routes from sitemap generation to improve privacy and security.
  • Loading branch information
DarthGigi committed Oct 21, 2024
1 parent a35586f commit f356de1
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions src/routes/sitemap.xml/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,10 @@ import type { RequestHandler } from "./$types";

export const GET: RequestHandler = async () => {
try {
const [users, minions] = await Promise.all([
prisma.user.findMany({
select: {
username: true
}
}),
prisma.auction.findMany({
select: {
id: true,
user: {
select: {
username: true
}
}
}
})
]);

return await sitemap.response({
origin: "https://minionah.com",
excludeRoutePatterns: [".*\\(protected\\).*", "^/api.*"],
additionalPaths: ["/api/craftcost/docs"],
paramValues: {
"/user/[user=username]": users.map(({ username }: { username: string }) => username),
"/user/[user=username]/[minionID]": minions.map(({ user: { username }, id }: { user: { username: string }; id: string }) => [username, id])
}
excludeRoutePatterns: [".*\\(protected\\).*", "^/api.*", ".*\\[user=username\\].*"],
additionalPaths: ["/api/craftcost/docs"]
});
} catch (e) {
console.error(e);
Expand Down

0 comments on commit f356de1

Please sign in to comment.