Prettier format pending files

This commit is contained in:
Builder.io 2025-10-19 03:54:12 +00:00
parent 25461d4b6c
commit 250b5c7e55
2 changed files with 32 additions and 11 deletions

View file

@ -89,9 +89,12 @@ export default function Directory() {
if (client === devconnect) {
fetch(`/api/devconnect/rest/${userTable}?select=*&limit=200`)
.then(async (r) => (r.ok ? r.json() : Promise.reject(new Error(String(r.status)))))
.then(async (r) =>
r.ok ? r.json() : Promise.reject(new Error(String(r.status))),
)
.then((data) => {
if (Array.isArray(data) && data.length) return setDevs(data.map(normalize));
if (Array.isArray(data) && data.length)
return setDevs(data.map(normalize));
return devconnect
?.from<any>(userTable as any)
.select("*")
@ -137,9 +140,12 @@ export default function Directory() {
"id,name,description,type,is_recruiting,recruiting_roles,tags,slug,created_at, collective_members:collective_members(count)",
);
fetch(`/api/devconnect/rest/${studiosTable}?select=${sel}&limit=200`)
.then(async (r) => (r.ok ? r.json() : Promise.reject(new Error(String(r.status)))))
.then(async (r) =>
r.ok ? r.json() : Promise.reject(new Error(String(r.status))),
)
.then((data) => {
if (Array.isArray(data) && data.length) return setStudios(data.map(mapStudio));
if (Array.isArray(data) && data.length)
return setStudios(data.map(mapStudio));
return devconnect
?.from<any>(studiosTable as any)
.select(
@ -174,7 +180,9 @@ export default function Directory() {
fetch(
`/api/devconnect/rest/collective_members?select=collective_id,profile_id&collective_id=in.(${list})&limit=200`,
)
.then(async (r) => (r.ok ? r.json() : Promise.reject(new Error(String(r.status)))))
.then(async (r) =>
r.ok ? r.json() : Promise.reject(new Error(String(r.status))),
)
.then(async (rows) => {
const byCollective: Record<string, string[]> = {};
(rows || []).forEach((row: any) => {
@ -183,14 +191,18 @@ export default function Directory() {
if (byCollective[cid].length < 5)
byCollective[cid].push(String(row.profile_id));
});
const profileIds = Array.from(new Set(Object.values(byCollective).flat()));
const profileIds = Array.from(
new Set(Object.values(byCollective).flat()),
);
if (profileIds.length) {
const pids = encodeURIComponent(profileIds.join(","));
let profs: any[] = [];
try {
profs = await fetch(
`/api/devconnect/rest/profiles?select=id,display_name,avatar_url&id=in.(${pids})`,
).then((r) => (r.ok ? r.json() : Promise.reject(new Error(String(r.status)))));
).then((r) =>
r.ok ? r.json() : Promise.reject(new Error(String(r.status))),
);
} catch {
const { data } = await devconnect
?.from<any>("profiles" as any)

View file

@ -24,9 +24,15 @@ export function createServer() {
try {
const base = process.env.DEVCONNECT_URL;
const key = process.env.DEVCONNECT_ANON_KEY;
if (!base || !key) return res.status(500).json({ error: "DevConnect env not set" });
const table = String(req.params.table || "").replace(/[^a-zA-Z0-9_]/g, "");
const qs = req.url.includes("?") ? req.url.substring(req.url.indexOf("?")) : "";
if (!base || !key)
return res.status(500).json({ error: "DevConnect env not set" });
const table = String(req.params.table || "").replace(
/[^a-zA-Z0-9_]/g,
"",
);
const qs = req.url.includes("?")
? req.url.substring(req.url.indexOf("?"))
: "";
const url = `${base}/rest/v1/${table}${qs}`;
const r = await fetch(url, {
headers: {
@ -37,7 +43,10 @@ export function createServer() {
});
const text = await r.text();
if (!r.ok) return res.status(r.status).send(text);
res.setHeader("content-type", r.headers.get("content-type") || "application/json");
res.setHeader(
"content-type",
r.headers.get("content-type") || "application/json",
);
return res.status(200).send(text);
} catch (e: any) {
return res.status(500).json({ error: e?.message || String(e) });