This is a simple blog application that demonstrates CRUD (Create, Read, Update, Delete) operations using Node.js, Express, EJS, and MongoDB. The application allows users to create, view, edit, and delete blog posts, making it an excellent starting point for learning about full-stack development with these technologies.
To set up and run this project, you need:
- Node.js: Download Node.js
- MongoDB: A free MongoDB cluster. Sign up at MongoDB Atlas
- Create a free cluster on MongoDB Atlas by following their documentation.
- Obtain your connection string (e.g.,
mongodb+srv://<username>:<password>@clusterName.xxxxxxx.mongodb.net/blog
).
Create a .env
file in the root directory of the project to store your environment variables securely. Use the following template:
MONGODB_URI=mongodb+srv://<username>:<password>@clusterName.xxxxxxx.mongodb.net/blog
JWT_SECRET=MySecretBlog
- Replace
<username>
,<password>
, andclusterName
with your MongoDB credentials. JWT_SECRET
is used for authentication and should be replaced with a secure value.
Follow these steps to install dependencies and start the server:
-
Install project dependencies:
npm install
-
Start the development server:
npm run dev
The server will start, and the application will be accessible at http://localhost:3000
by default.