mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-04 23:17:34 +08:00
feat: improve address credential connections
This commit is contained in:
+19
-2
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user