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.
- Prerequisites
- Installation
- Environment Configuration
- Running the Application
- Running Migrations
- Testing
- License
Before you begin, ensure you have the following installed:
- Node.js (v14.x or later)
- Docker
- Docker-compose (should come preinstalled with Docker)
-
Clone the repository:
git clone https://github.com/adebisit/task-management-api cd task-management-api
-
Build Docker Image:
docker build -t task-mgmt-api .
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 |
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
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.
docker-compose down
To run TypeORM migrations, use the following commands:
Run migrations:
docker-compose exec api npx typeorm migration:run -d dist/data-source.js
Documentations for the API endpoints are available at http://localhost:3000/api/.
Test scripts are currently under development