A full-featured Todo List web application built with Node.js, Express, MongoDB, and Passport.js for authentication.
- User authentication (login/register)
- Create, read, update, and delete todo items
- Mark todos as complete/incomplete
- Delete all todos at once
- Secure password hashing
- Session management
- MongoDB database integration
- Node.js (v12 or higher)
- MongoDB (local installation or MongoDB Atlas account)
- npm (Node Package Manager)
- Clone the repository:
git clone <repository-url>
cd todolist- Install dependencies:
npm install- Create a
.envfile in the root directory with the following variables:
MONGODB_URI=your_mongodb_connection_string
SESSION_SECRET=your_session_secret
PORT=3000
- Start MongoDB service on your machine
- Run the application:
npm start- Open your browser and navigate to
http://localhost:3000
- express: Web framework
- mongoose: MongoDB object modeling
- passport: Authentication middleware
- bcryptjs: Password hashing
- express-session: Session management
- connect-mongo: MongoDB session store
- ejs: Template engine
- body-parser: Request body parsing
- dotenv: Environment variable management
app.js: Main application filepublic/: Static files (CSS, client-side JavaScript)views/: EJS templatesindex.ejs: Main todo list viewlogin.ejs: Login pageregister.ejs: Registration pageedit.ejs: Todo edit page
GET /: Main todo list page (requires authentication)GET /login: Login pagePOST /login: Login authenticationGET /register: Registration pagePOST /register: User registrationGET /logout: User logoutPOST /newtodo: Create new todoGET /delete/:id: Delete specific todoPOST /toggle/:id: Toggle todo completion statusPOST /delAlltodo: Delete all todosGET /edit/:id: Edit todo pagePOST /update/:id: Update todo
- Password hashing using bcrypt
- Session-based authentication
- MongoDB session store
- Protected routes using Passport.js
- Environment variable configuration
MIT License