Add DB dump support
This commit is contained in:
14
functions/dump/[dump].js
Normal file
14
functions/dump/[dump].js
Normal file
@@ -0,0 +1,14 @@
|
||||
export async function onRequest(context) {
|
||||
console.log(context);
|
||||
if (context.params.dump !== context.env.DUMP_KEY) {
|
||||
return new Response();
|
||||
}
|
||||
const db = context.env.D1DB;
|
||||
const dump = await db.dump();
|
||||
return new Response(dump, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream'
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
name = "cryptopad"
|
||||
compatibility_date = "2023-03-15"
|
||||
|
||||
[vars]
|
||||
DUMP_KEY = "dump"
|
||||
|
||||
[[ d1_databases ]]
|
||||
binding = "D1DB"
|
||||
database_name = "cryptopad"
|
||||
|
||||
Reference in New Issue
Block a user