Switch to CF KV instead of D1, more appropriate for the purpose
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
export async function onRequest(context) {
|
||||
console.log(context);
|
||||
if (context.params.dump !== context.env.DUMP_KEY) {
|
||||
return new Response("Wrong key");
|
||||
}
|
||||
const db = context.env.D1DB;
|
||||
const dump = await db.dump();
|
||||
return new Response(dump, {
|
||||
const db = context.env.cryptopad;
|
||||
console.log(db)
|
||||
let accum = []
|
||||
let cursor = undefined;
|
||||
|
||||
do {
|
||||
const listResult = await db.list({cursor});
|
||||
cursor = listResult.cursor;
|
||||
accum = accum.concat(listResult.keys.map(x => x.name));
|
||||
} while (cursor !== undefined);
|
||||
|
||||
const results = await Promise.all(accum.map(async x => ({key: x, value: await db.get(x)})));
|
||||
return new Response(JSON.stringify(results), {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream'
|
||||
|
||||
Reference in New Issue
Block a user