A simple Task Manager application built with Express.js and PostgreSQL. This app allows users to manage tasks by adding, updating, and deleting them. It uses EJS for rendering tasks and connects to a PostgreSQL database to persist data.
- Add new tasks
- Update existing tasks
- Delete tasks
- View tasks in a web interface
- Node.js
- PostgreSQL
-
Clone the repository:
git clone https://github.com/Manish312002/task-manager-express.git cd task-manager-express
-
Install dependencies:
- npm i
- Set up PostgreSQL database:
- Create a PostgreSQL database named Web Dev and set up a table named to_do with the following schema:
CREATE TABLE to_do ( id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL );
-
Configure database connection:
const db = new pg.Client({ user: "postgres", password: "root", database: "Web Dev", host: "localhost", port: 5432 });
-
Start the server:
- node index.js
- GET /: Renders the main page with the list of tasks.
- POST /add: Adds a new task.
- req.body.newItem - The title of the new task.
- POST /edit: Updates an existing task.
- req.body.updatedItemId - The ID of the task to be updated.
- req.body.updatedItemTitle - The new title for the task.
- POST /delete: Deletes a task.
- req.body.deleteItemId - The ID of the task to be deleted.