Raddy Website Design & Development Tutorials

How to Build a Blog with Node.js, Express & MongoDB

By Raddy in NodeJs ·

I’m thrilled to share that I had the honour of creating a guest post for the one and only Black Belt Coding Ninja here on YouTube! @NetNinja

Being featured on such a prominent channel is an incredible opportunity! The first lesson is up, go and check it out.

We made a simple NodeJs, Express and MongoDB blog.

crud nodejs blog

  1. Hi Raddy, I have followed the whole tutorial and is great thanks for sharing. I have made a few changes, like add a contact page and about. I’ve tried to deploy it on render, vercel, cyclic and a few more, obiously something is wrong in my config. It woks perfectly locally on my home network. Do I need change something before the deploy?. Can you give some ideas of what could be wrong?. Also added the variables, mongodb, jwt… Many thanks.

    1. Raddy says:

      Hi, Antonio that’s great to hear. Cyclic and Render should work, but one thing that you need to know is that they are mostly for web services, meaning that they don’t like to serve static files such as styles, images, media… You can link them from another source, but that makes it more painful to maintain. If it’s just for learning purposes I am pretty sure that Cyclic will work.

      Cyclic does things slightly different when it comes to MongoDB.
      Cyclic MongoDB docs: https://docs.cyclic.sh/how-to/using-mongo-db

      Let’s start:
      1) Make sure that you have your PORT in the following order: `const PORT = process.env.PORT || 3000`
      2) You need to connect to the Database before you listen on the PORT
      //Connect to the database before listening
      connectDB().then(() => {
      app.listen(PORT, () => {
      console.log("listening for requests");
      })
      })

      3) Make sure that you allow your MongoDB to be accessible from anywhere. That’s under the Networking tab. You can put the IP of: 0.0.0.0/0
      4) The main ‘app.js’ file needs to be called ‘server.js’ or ‘index.js’.

      That’s pretty much it. When you deploy look into the Terminal / Console logs on Cyclic. It normally tells you what is wrong

      On Render you won’t have to change all that (maybe the PORT number like above), but your static assets might not work.

      I actually have two videos on Cyclic. One is super quick 3 min video and the other one is fairly detailed version.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.