Stories:
- A user can login with a username and password
- Return success and a JWT token if username and password are correct
- Return fail if username and password are not matched
- A user has a maximum of 3 attempts within 5 minutes, otherwise, the user will be locked.
- Return fail if a user is locked
Important: This application does not contain signup functionality. Please use this test account for testing
username = admin@predictivehire.com
password = predictivehire
Use http://localhost:3000/v1/login
to test the API
Here is a sample request
curl --request POST \
--url http://localhost:3000/v1/login \
--header 'Content-Type: application/json' \
--data '{
"email": "admin@predictivehire.com",
"password": "predictivehire"
}'
If your account is locked, send a POST request to /v1/reset to reset the account :D
curl --request POST \
--url http://localhost:3000/v1/reset
By default, the account will be unlocked automatically after 1 minute. Please change the value of LOCK_TIME in auth.service.ts file to modify the lock period.
docker-compose up
and DONE!
Start your own mongoDB instance (port 27017) or using docker
docker run --name mongo -p 27017:27017 mongo
Run following commands
npm install
npm install -g typescript (if needed)
npm run dev
npm install
npm run build
Output files will be stored in /dist folder
You can run npm start
or node dist/index.js
to run the application
This application was tested using Jest framework. To run the test npm run test
Copyright (c) 2022 Trung Duc Nguyen