You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.0 KiB
32 lines
1.0 KiB
import { DBExportEndpoint, DBImportEndpoint, DBImportRequest, DBWipeEndpoint } from "../../api/api"; |
|
import backendRequest from "./request"; |
|
|
|
export function getDBExportLink() { |
|
return (process.env.REACT_APP_BACKEND || "") + DBExportEndpoint; |
|
} |
|
|
|
export async function wipeDB() { |
|
const requestOpts = { |
|
method: 'POST' |
|
}; |
|
|
|
const response = await backendRequest((process.env.REACT_APP_BACKEND || "") + DBWipeEndpoint, requestOpts) |
|
if (!response.ok) { |
|
throw new Error("Response to DB wipe not OK: " + JSON.stringify(response)); |
|
} |
|
|
|
return; |
|
} |
|
|
|
export async function importDB(jsonData: DBImportRequest) { |
|
const requestOpts = { |
|
method: 'POST', |
|
headers: { 'Content-Type': 'application/json' }, |
|
body: JSON.stringify(jsonData), |
|
}; |
|
|
|
const response = await backendRequest((process.env.REACT_APP_BACKEND || "") + DBImportEndpoint, requestOpts) |
|
if (!response.ok) { |
|
throw new Error("Response to DB import not OK: " + JSON.stringify(response)); |
|
} |
|
} |