- A user can log in using a username and password.
- If the username and password are correct, return success and a JWT token.
- If the username and password do not match, return failure.
- A user has a maximum of 3 attempts within 5 minutes; otherwise, the user will be locked out for the next five minutes.
- Once the user is unlocked, they have another three attempts. If these attempts also fail, the user will be locked out indefinitely.
- If a user is locked out, return failure.
curl -X POST \
'http://localhost:3113/v1/auth/login' \
--header 'Accept: */*' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "test",
"password": "test"
}'
{
username: 'test',
password: 'test',
},
{
username: 'test2',
password: 'test2',
},
{
username: 'test3',
password: 'test3',
},
{
username: 'test4',
password: 'test4',
},
This project includes a Dockerfile and a docker-compose.yml file for running the application in a Docker container.
To build and start the application with Docker, execute the following command:
docker-compose --env-file env/.env up -d --build
The application will be accessible at http://localhost:3113
.
- Run unit tests:
docker-compose exec --env-file env/.env nestjs_app_main yarn test
- Run integration tests:
docker-compose --env-file env/.test.env -f docker-compose.test.yml up nestjs_app_test --build
This project is a Node.js application built with the NestJS framework. Ensure you have Node.js and Yarn installed on your local machine.
- Node.js (version 20.12.2 or later)
- Yarn (latest version)
- Clone this repository to your local machine.
- Navigate to the project directory.
- Create
.env
file
cp env/.env.example env/.env
- Install project dependencies by running:
yarn install
- Start the containerized database:
docker-compose --env-file env/.env up mongodb -d
- Generate test data:
npx nest start --entryFile main.seeder
- Start the application in development mode:
yarn start:dev
The application will be accessible at http://localhost:3113
.
- Start the containerized test database:
docker-compose --env-file env/.test.env -f docker-compose.test.yml up mongodb_test -d
- Run unit tests:
yarn test
- Run integration tests:
docker-compose --env-file env/.test.env -f docker-compose.test.yml up mongodb_test -d
yarn test:e2e