Spaces:
Runtime error
Runtime error
fix(tool): featured required for everyone except admins
Browse files
src/routes/api/tools/[toolId]/+server.ts
CHANGED
|
@@ -33,11 +33,12 @@ export async function GET({ params, locals }) {
|
|
| 33 |
color: tool.color,
|
| 34 |
icon: tool.icon,
|
| 35 |
createdByName: tool.createdByName,
|
|
|
|
| 36 |
}
|
| 37 |
: undefined
|
| 38 |
);
|
| 39 |
|
| 40 |
-
if (!tool) {
|
| 41 |
return new Response(`Tool "${toolId}" not found`, { status: 404 });
|
| 42 |
}
|
| 43 |
|
|
|
|
| 33 |
color: tool.color,
|
| 34 |
icon: tool.icon,
|
| 35 |
createdByName: tool.createdByName,
|
| 36 |
+
featured: tool.featured,
|
| 37 |
}
|
| 38 |
: undefined
|
| 39 |
);
|
| 40 |
|
| 41 |
+
if (!tool || !tool.featured) {
|
| 42 |
return new Response(`Tool "${toolId}" not found`, { status: 404 });
|
| 43 |
}
|
| 44 |
|
src/routes/tools/+page.server.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const load = async ({ url, locals }) => {
|
|
| 44 |
const queryTokens = !!query && generateQueryTokens(query);
|
| 45 |
|
| 46 |
const filter: Filter<CommunityToolDB> = {
|
| 47 |
-
...(!createdByCurrentUser && !activeOnly && { featured: true }),
|
| 48 |
...(user && { createdById: user._id }),
|
| 49 |
...(queryTokens && { searchTokens: { $all: queryTokens } }),
|
| 50 |
...(activeOnly && {
|
|
|
|
| 44 |
const queryTokens = !!query && generateQueryTokens(query);
|
| 45 |
|
| 46 |
const filter: Filter<CommunityToolDB> = {
|
| 47 |
+
...(!createdByCurrentUser && !activeOnly && !locals.user?.isAdmin && { featured: true }),
|
| 48 |
...(user && { createdById: user._id }),
|
| 49 |
...(queryTokens && { searchTokens: { $all: queryTokens } }),
|
| 50 |
...(activeOnly && {
|