lokiwind
05/25/2023, 9:05 AMjavascript
export default {
async fetch(request, env, ctx) {
const keys = new Set();
let cursor = undefined;
async function gatherKeys() {
while (true) {
const result = await env.LOG_IP.list({ cursor });
for (const { name } of result.keys) {
keys.add(name);
}
if (result.list_complete) {
break;
}
cursor = result.cursor;
}
}
await gatherKeys();
const keysArray = Array.from(keys.values());
const keysText = keysArray.join('\n');
return new Response(keysText, {
status: 200,
headers: { 'Content-Type': 'text/plain' },
});
},
};
navaru
05/25/2023, 8:22 PMlokiwind
05/26/2023, 8:10 PM