feat: improve address credential connections

This commit is contained in:
Dream Hunter
2026-04-30 15:33:06 +08:00
committed by GitHub
parent 347be5c762
commit 796a5e4ac5
32 changed files with 854 additions and 118 deletions
+19 -2
View File
@@ -611,7 +611,8 @@ export const handleListQuery = async (
limit: string | number | undefined | null,
offset: string | number | undefined | null,
/** Must be pre-validated (e.g. whitelist), NOT raw user input. Interpolated directly into SQL. */
orderBy?: string
orderBy?: string,
hiddenFields: string[] = []
): Promise<Response> => {
const msgs = i18n.getMessagesbyContext(c);
if (typeof limit === "string") {
@@ -634,7 +635,23 @@ export const handleListQuery = async (
const count = offset == 0 ? await c.env.DB.prepare(
countQuery
).bind(...params).first("count") : 0;
return c.json({ results, count });
if (hiddenFields.length === 0) {
return c.json({ results, count });
}
const filteredResults = results.map((row) => hideObjectFields(row, hiddenFields));
return c.json({ results: filteredResults, count });
}
export const hideObjectFields = <T extends Record<string, unknown>>(
row: T,
fields: string[]
): T => {
const filteredRow = { ...row };
for (const field of fields) {
delete filteredRow[field];
}
return filteredRow;
}
/**