This web app allows users to create study notes using markdown
This web app is really a port from studythat express version. I wanted to see if there really is a need for a MERN Stack considering that NextJS allows users to use serverside-rendering with their own API methods, so I created a new version. Like the Express version, I was able to use MongoDB as my database of choice. In this new version, I added authentication using auth0, improved markdown parsing using markdown-it and highlight.js, and a newer UI.
At first, I tried to use NextAuth; however, I kept on getting an error message indicating that a database is required. I tried to find a solution; however, I could not. After some time, I decided to try a different authentication method. That's when I discovered Auth0. While Auth0's easy-to-use application menu and starter kit made it easy to set up authentication, it was their documentation and login customization that won me over.
Like the original version, I used mongoose to connect to a collection that I set up for this new version. At first, I ran to an error message claiming that I was trying to overwrite a collection. I eventually patched the problem by writing the following within the try
statement:
mongoose.set('useFindAndModify', false)
const connection = await mongoose.createConnection(process.env.MONGODB_CONNECTION, {
useNewUrlParser: true,
useUnifiedTopology: true
}).catch(function(err){
console.log("error:", err)
})
const Schema = mongoose.Schema
const cardSchema = Schema({
title: String,
note: String,
user: String
})
const Card = connection.model('Notes', cardSchema)
Although this is not perfect (considering that MongoDB sends me alerts saying that I have created more than 80 connections every now and then), it will suffice until I find a better solution.