-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Connects to MongoDB | ||
// Only need one client instance | ||
|
||
const { MongoClient, ServerApiVersion } = require("mongodb"); | ||
const USER = process.env.DBUSER; | ||
const PSWD = process.env.DBPASS; | ||
const HOST = process.env.DBHOST; | ||
|
||
// Atlas connection string | ||
const uri = `mongodb+srv://${USER}:${PSWD}@${HOST}/?retryWrites=true&w=majority&appName=LuminosityCluster-0`; | ||
|
||
// Create a MongoClient | ||
const client = new MongoClient(uri, { | ||
serverApi: { | ||
version: ServerApiVersion.v1, | ||
strict: true, | ||
deprecationErrors: true, | ||
} | ||
} | ||
); | ||
|
||
async function run() { | ||
try { | ||
// Connect to the server | ||
await client.connect(); | ||
|
||
// Confirm connection | ||
await client.db("admin").command({ ping: 1 }); | ||
console.log("Connected to MongoDB. Great success!"); | ||
} | ||
finally { | ||
await client.close(); | ||
} | ||
} | ||
run().catch(console.dir); | ||
|
||
export default client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import GetServerSideProps from 'next' | ||
|
||
export const getServerSideProps = (async () => { | ||
const response = await fetch("") | ||
const pageData = await response.json() | ||
|
||
return pageData | ||
return { | ||
props: { | ||
todos: pageData | ||
} | ||
} | ||
}) |