A simple blog application built with Express.js, MongoDB, and Passport.js authentication.
- User registration and login authentication
- Create, read, update, and delete blog posts
- Session management
- Responsive UI with EJS templates
- Backend: Node.js, Express.js
- Database: MongoDB
- Authentication: Passport.js (Local Strategy)
- Frontend: EJS, CSS
- Session: Express-session
-
Clone the repository:
git clone <repository-url> cd blog-app
-
Install dependencies:
npm install
-
Make sure MongoDB is running on your system
-
Start the server:
npm start
-
Open your browser and navigate to
http://localhost:3000
- Register: Create a new account with email and address
- Login: Sign in with your credentials
- Create Blog: Write and publish new blog posts
- View Blogs: See all blog posts from all users
- Edit/Delete: Manage your own blog posts
- Logout: Sign out of your account
blog-app/
├── models/ # Database schemas (User, Blog)
├── routes/ # Route handlers (auth, blogs)
├── views/ # EJS template files
├── public/ # Static files (CSS, images)
├── config/ # Configuration files (Passport)
├── app.js # Main application file
├── package.json # Dependencies
└── README.md # This file
GET /- Home pageGET /register- Registration pagePOST /register- Register new userGET /login- Login pagePOST /login- Login userGET /logout- Logout userGET /blogs- View all blogsGET /blogs/new- Create blog formPOST /blogs- Create new blogGET /blogs/:id/edit- Edit blog formPUT /blogs/:id- Update blogDELETE /blogs/:id- Delete blog
- MongoDB must be running locally or connection string must be updated
- Passwords are currently stored as plain text (not hashed) - implement bcrypt for production
- Session data is stored in memory (use MongoDB store for production)
ISC