Task Management API

The api is a NestJS API that performs CRUD services on tasks. It also implements user authentication with Json Web Tokens (JWT). The project implements NestJS and MySql in Docker.

Table of Contents

Prerequisites

Before you begin, ensure you have the following installed:

Installation

  1. Clone the repository:

    git clone https://github.com/adebisit/task-management-api
    cd task-management-api
  2. Build Docker Image:

    docker build -t task-mgmt-api .

Environment Configuration

Create a .env file in the root directory of the project with the following content:

o run this project, you will need to add the following environment variables to your .env file:

Variable Name Description Example Value
DATABASE_PORT The port number your database server uses 3306
DATABASE_USER The username for your database connection root
DATABASE_PASSWORD The password for your database connection password
DATABASE_NAME The name of your database my_database
JWT_SECRET Secret key for JWT token generation your_jwt_secret_key

Example .env File

You can rename the .env.example file to .env and populate it with your variables.

DB_PASSWORD=password
DB_PORT=3306
DB_USERNAME=root
DB_NAME=my_database
JWT_SECRET=your_jwt_token

Running the Application

Start both the NestJS and the MySql db services with docker-compose

docker-compose up --build -d

Note: NestJs service might fail to connect to the database initially. This is because mysql_db takes some time to start up. It should succesfully connect after a few retries.

The application will be available at http://localhost:3000.

Stopping the Application

docker-compose down

Running Migrations

To run TypeORM migrations, use the following commands:

Run migrations:

docker-compose exec api npx typeorm migration:run -d dist/data-source.js

API Documentation

Documentations for the API endpoints are available at http://localhost:3000/api/.

Testing

Test scripts are currently under development