Merge pull request #1791 from cheahjs/feat/external-db-support

feat: add support for using postgres for the backend DB
This commit is contained in:
Timothy Jaeryang Baek 2024-04-27 12:48:56 -07:00 committed by GitHub
commit c1d85f8a6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 350 additions and 24 deletions

View file

@ -83,9 +83,9 @@ export const downloadDatabase = async (token: string) => {
Authorization: `Bearer ${token}`
}
})
.then((response) => {
.then(async (response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
throw await response.json();
}
return response.blob();
})
@ -100,7 +100,11 @@ export const downloadDatabase = async (token: string) => {
})
.catch((err) => {
console.log(err);
error = err;
error = err.detail;
return null;
});
if (error) {
throw error;
}
};

View file

@ -2,6 +2,7 @@
import { downloadDatabase } from '$lib/apis/utils';
import { onMount, getContext } from 'svelte';
import { config } from '$lib/stores';
import { toast } from 'svelte-sonner';
const i18n = getContext('i18n');
@ -32,7 +33,9 @@
on:click={() => {
// exportAllUserChats();
downloadDatabase(localStorage.token);
downloadDatabase(localStorage.token).catch((error) => {
toast.error(error);
});
}}
>
<div class=" self-center mr-3">