Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
fixed env config
Browse files Browse the repository at this point in the history
  • Loading branch information
vliu36 committed Dec 22, 2024
1 parent 5042a8b commit 0326e07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/routes/connect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Connects to MongoDB
// Only need one client instance

const { MongoClient, ServerApiVersion } = require("mongodb");
require("dotenv").config()
const USER = process.env.DBUSER;
const PSWD = process.env.DBPASS;
const HOST = process.env.DBHOST;
Expand Down Expand Up @@ -32,6 +32,7 @@ async function run() {
await client.close();
}
}

run().catch(console.dir);

export default client;
7 changes: 5 additions & 2 deletions src/routes/serverProps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import client from "./connect";

export const getServerSideProps = (async () => {
const response = await fetch("")
const pageData = await response.json()
await client.connect();
const response = await client.findOne();
const pageData = await response.json();
await client.close();

return {
props: {
Expand Down

0 comments on commit 0326e07

Please sign in to comment.