From c42772ce4729f16901e9cc99fa45cc6ed8df64de Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Tue, 7 Nov 2023 06:55:57 -0600 Subject: [PATCH] Changed endpoints to environment variables. --- src/env.d.ts | 11 +++++++++++ src/integration/pouchdbPersistenceManager.ts | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/env.d.ts diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 0000000..f936976 --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1,11 @@ +/// + +interface ImportMetaEnv { + readonly VITE_SYNCDB_ENDPOINT: string, + readonly VITE_SYNCDB_USER: string + // more env variables... +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} \ No newline at end of file diff --git a/src/integration/pouchdbPersistenceManager.ts b/src/integration/pouchdbPersistenceManager.ts index 249d487..34fa0f5 100644 --- a/src/integration/pouchdbPersistenceManager.ts +++ b/src/integration/pouchdbPersistenceManager.ts @@ -213,10 +213,10 @@ export class PouchdbPersistenceManager implements IPersistenceManager { try { const syncTarget = "user123"; - const dbs = await axios.get('https://syncdb-service-d3f974de56ef.herokuapp.com/_all_dbs'); + const dbs = await axios.get(import.meta.env.VITE_SYNCDB_ENDPOINT); if (dbs.data.indexOf(syncTarget) == -1) { console.log('sync target missing'); - const buildTarget = await axios.post('https://deepdiagram.com/.netlify/functions/users', + const buildTarget = await axios.post(import.meta.env.VITE_USER_ENDPOINT, {username: syncTarget, password: 'password', db: syncTarget}); if (buildTarget.status != 200) { console.log(buildTarget.statusText);