This project is a simple blog application built using Node.js, Express, EJS, and MongoDB. It allows users to perform CRUD (Create, Read, Update, Delete) operations on blog posts. The application features user authentication using JWT (JSON Web Tokens).
To run this application, you will need:
- Node.js: Ensure you have Node.js installed on your machine. You can download it from Node.js official website.
- MongoDB: A free MongoDB cluster. Sign up for a free database cluster on MongoDB Atlas.
-
Sign Up for MongoDB Free Database Cluster:
- Visit MongoDB Atlas and create an account.
- Create a new cluster and follow the instructions to set up your database.
-
Create a
.env
file:- Create a file named
.env
in the root of your project directory to store your database credentials and other secrets. - Add the following lines to your
.env
file, replacing<username>
,<password>
, andclusterName
with your actual MongoDB credentials:
MONGODB_URI=mongodb+srv://<username>:<password>@clusterName.xxxxxxx.mongodb.net/blog JWT_SECRET=MySecretBlog
- Create a file named
- Clone the repository to your local machine::
- git clone https://github.com/riyazpt/nodejs-blog.
- Navigate to the project directory::
- cd blog-application
- Navigate to the project directory::
- npm install
- npm run dev: