Express.js and MySQL-based Task Manager: Simplify task management with user-friendly features including task creation, editing, and completion tracking.
-
Clone the repository:
git clone git@github.com:armanmartirosyan/taskmanager.git
-
Install dependencies:
This command will install all project dependencies listed in the package.json file
cd taskmanager npm install
-
Set up environment variables:
Create a
.env
file in the root directory of the project, using the provided.env-example
as a template. Customize the values of the variables in the.env
file according to your environment and configuration needs. These environment variables are essential for configuring database connections, API keys, and other sensitive information required by the Task Manager application. -
Run migrations:
This command will execute the database migrations and set up the necessary database schema for the Task Manager application.
npm run migrate
-
Start server:
This command will start the server on specified port, allowing users to access the application via their web browsers.
npm start
-
GET /api/v1/tasks/: Use this endpoint to fetch all tasks stored in the database.
-
POST /api/v1/tasks/: Use this endpoint to add a new task to the database. Send a JSON object with the task details in the request body.
-
GET /api/v1/tasks/:id: Use this endpoint to retrieve a specific task from the database by providing its ID in the URL path.
-
PATCH /api/v1/tasks/:id: Use this endpoint to update the state (e.g., completion status) of a task in the database. Send a JSON object with the updated task details in the request body.
-
DELETE /api/v1/tasks/:id: Use this endpoint to delete a specific task from the database by providing its ID in the URL path.
You can access the Task Manager user interface by navigating to http://localhost:3000(3000 port by default) in your web browser. This page allows you to create, update, and delete tasks interactively.
-
POST /api/v1/tasks/
{ "name": "New Task", "completed": false }
-
Response:
{ "id": 1 }
-
PATCH /api/v1/tasks/:id
{ "name": "Old Task", "completed": true }
-
Response:
{ "task": { "id": 1, "name": "Old Task", "completed": 1 } }
For more details on request payloads and responses for each endpoint, please refer to the source code.
You'll need to set up a MySQL database with at least the following table:
- tasks
- id (int, auto_increment, primary key)
- name (varchar)
- completed (tinyint)
-
"migrate": "npx knex migrate:latest --knexfile ./config/knexfile.js"
: This script executes database migrations to ensure that the database schema is up to date with the latest changes in the project. It uses Knex to manage migrations and runs the migrations defined in theknexfile.js
configuration file located in the./config
directory. -
"rollback": "npx knex migrate:rollback --knexfile ./config/knexfile.js"
: This script rolls back the most recent database migration, reverting the changes made to the database schema. It utilizes Knex to handle the rollback process and operates on theknexfile.js
configuration file in the./config
directory. -
"start": "node app.js"
: This script starts the application by running theapp.js
file using Node.js. It is typically used in a production environment to launch the application server. -
"dev": "nodemon app.js"
: This script is intended for development purposes. It utilizes Nodemon to monitor changes to files and automatically restarts the server when changes are detected. It runs theapp.js
file, facilitating a smoother development workflow.
This project is licensed under the MIT License - see the LICENSE file for details.