This is a simple login microservice to be used for authentication in other future projects, it works in a simple way, with some routes, which will be mentioned below.
To run this project you will need follow the next steps:
- Install the dependencies running
npm install. - Set up the docker by running
docker-compose up - Run the migrations
npx prisma migrate - Run one instance local of rabbitMQ (I will add this to docker container after).
- Run the backend (Will be added to docker compose as well)
npx ts-node src/main.ts.
This first route is used to create a user, as this repository is a microservice we dont have lots of fields to user model we only need to provide the next fields:
POST /user
body:
{
"email": "validmail@email.com",
"password": "validPassword*123",
"username": "Username"
}response:
{
"id": "Sample UUID"
}After user create you need to verify your mail to confirm the account creation.
If the confirmation mail did not arrive you can resend it by requeting this route:
POST /resent-mail-confirmation
{
"email": "validmail@email.com"
}To authenticate as a user you need to Sign In using your register email and password:
POST /auth
body:
{
"email": "validmail@email.com",
"password": "validPassword*123"
}response:
{
"token": "Sample JWT"
}This route is for validations if the token still fresh:
body:
{
"token": "Sample JWT"
}response:
{
"email": "validmail@email.com"
}This project stil on its beggining i need to add some features to it:
- Error code/handling;
- Refresh token;
- Password recover;
- Error screen;