Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix: simplify sorting logic in handleList function

nirholas3211a55373e5
diff --git a/api/plugins/[action].js b/api/plugins/[action].js
index c1b12d328..70cbe8690 100644
--- a/api/plugins/[action].js
+++ b/api/plugins/[action].js
@@ -136,6 +136,13 @@ async function handleList(req, res, url) {
const limit = Math.min(40, Math.max(1, Number(url.searchParams.get('limit')) || 20));
const offset = cursor ? Math.max(0, Number(cursor)) : 0;
+ const sortClause =
+ sort === 'popular'
+ ? 'p.install_count DESC, p.created_at DESC'
+ : sort === 'new'
+ ? 'p.created_at DESC'
+ : 'p.name ASC';
+
const rows = await sql`
SELECT p.*, u.display_name AS author_display_name
FROM plugins p
@@ -144,13 +151,7 @@ async function handleList(req, res, url) {
AND p.deleted_at IS NULL
${category ? sql`AND p.category = ${category}` : sql``}
${q ? sql`AND (p.name ILIKE ${'%' + q + '%'} OR p.description ILIKE ${'%' + q + '%'})` : sql``}
- ORDER BY ${sql.unsafe(
- sort === 'popular'
- ? 'p.install_count DESC, p.created_at DESC'
- : sort === 'new'
- ? 'p.created_at DESC'
- : 'p.name ASC',
- )}
+ ORDER BY ${sql.unsafe(sortClause)}
LIMIT ${limit + 1} OFFSET ${offset}
`;