From 78d851d4edb1e4017fa1ce7417c2533d1b82b2ba Mon Sep 17 00:00:00 2001 From: dan13ram Date: Wed, 15 Mar 2023 10:05:28 +0530 Subject: [PATCH] fixed plausible & quest chains url --- lib/mongodb/client.ts | 16 ++++++++++------ pages/_app.tsx | 3 ++- utils/constants.ts | 30 ++++++++++++++++++++---------- utils/errors.ts | 7 +++++++ 4 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 utils/errors.ts diff --git a/lib/mongodb/client.ts b/lib/mongodb/client.ts index f53d5771..7d8e0546 100644 --- a/lib/mongodb/client.ts +++ b/lib/mongodb/client.ts @@ -1,19 +1,23 @@ import { Db, MongoClient } from 'mongodb'; +import { EnvironmentError } from '@/utils/errors'; + if (!process.env.MONGODB_URI) { - throw new Error('Invalid/Missing environment variable: "MONGODB_URI"'); + throw new EnvironmentError('MONGODB_URI'); } +const MONGODB_URI = process.env.MONGODB_URI; + if (!process.env.MONGODB_DATABASE) { - throw new Error('Invalid/Missing environment variable: "MONGODB_DATABASE"'); + throw new EnvironmentError('MONGODB_DATABASE'); } +const MONGODB_DATABASE = process.env.MONGODB_DATABASE; + declare const global: { _clientPromise: Promise; }; -const uri = process.env.MONGODB_URI; -const database = process.env.MONGODB_DATABASE; const options = {}; let clientPromise: Promise; @@ -42,10 +46,10 @@ export const initIndexes = async (client: Db): Promise => { }; const createClientPromise = async (): Promise => { - const client = new MongoClient(uri, options); + const client = new MongoClient(MONGODB_URI, options); return client .connect() - .then((client: MongoClient) => client.db(database)) + .then((client: MongoClient) => client.db(MONGODB_DATABASE)) .then(initIndexes); }; diff --git a/pages/_app.tsx b/pages/_app.tsx index 7624df9e..c92242da 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -14,6 +14,7 @@ import { Toaster } from 'react-hot-toast'; import { hotjar } from 'react-hotjar'; import { AppLayout } from '@/components/Layout/AppLayout'; +import { PLAUSIBLE_DATA_DOMAIN } from '@/utils/constants'; import { globalStyles, theme } from '@/utils/theme'; import { WalletProvider } from '@/web3'; @@ -44,7 +45,7 @@ const App = ({ Component, pageProps }: AppProps): JSX.Element => {