A simple to-do application made using MongoDB, Express.js, Node.js, and EJS.
- Add a task: Enter a task in the task bar and click "Add" to add the task to the database.
- Date: The date when the task was added is automatically recorded and displayed alongside the task.
- Status: Tasks can be marked as completed or pending.
- Mark as completed/pending: Tasks can be toggled between completed and pending status.
- Delete a task: Tasks can be deleted from the list.
- MongoDB: A NoSQL database used for storing task data.
- Express.js: A web application framework for Node.js used for handling routes and requests.
- Node.js: A JavaScript runtime environment used for building server-side applications.
- EJS: A templating engine used for generating dynamic HTML pages.
- Node.js: Make sure you have Node.js installed on your machine.
-
Clone the repository:
git clone <repository-url>
-
Install the dependencies:
cd ToDo_App_using_MEeN npm install
-
Start the server using nodemon:
nodemon server.js
-
Open your web browser and visit
http://localhost:3000
to access the application.
server.js
: The main server file that sets up the Express.js server and handles routes.routes/mainRouter.js
: Main router for Routing request to appropriate controller.models/mainModel.js
: Defines the Task model using Mongoose for MongoDB integration.views/homepage.ejs
: The EJS template file for the home page view.controllers/mainController.js
: Controller for the application.
- Task: A string representing the task description.
- Date: A string using the Moment.js library to store the date and time when the task was added.
- Status: A boolean value indicating whether the task is completed or pending.
- Home: The main view that displays the table of completed and pending tasks. It includes the following features:
- The table shows the task description, date added, and status of each task.
- New tasks can be added using an input form, which submits the task to the server and stores it in the database.
- Each task has a status toggle button that allows marking it as completed or pending.
- Each task has a delete button to remove it from the list.
- GET
/
: Renders the homepage view. - POST
/add
: Handles adding a new task to the database. This route is used by the form on the homepage. - POST
/delete
: Handles deleting an existing task from the database. If the task doesn't exist, a warning is displayed. - POST
/edit
: Handles editing an existing task in the database.
-
To change the design or layout of the application, modify the
views/homepage.ejs
file. -
To add new features or modify existing functionality, modify the server routes in
server.js
and update the corresponding Controller & EJS templates and database operations.
Contributions are welcome! If you have any ideas, improvements, or bug fixes, please open an issue or submit a pull request.
This project is licensed under the MIT License.