- Endpoints to register and login a user with JWT token as a response.
- Endpoint to allow a user to create contacts, the phone number of the contact should be validated before saving it in the database
- Runtime: NodeJS
- Database: MongoDB
- ORM: Mongoose
- Clone it on the local machine
git clone repo_url
- Install all the dependencies
npm install
- Copy the
.env
file in the root of the repository - Run the development environment
npm run dev
This endpoint is responsible for registering a user. It creates an entry in the database with the User credentials
Input
{
"phoneNumber": 919999999999,
"password": "ThisIsMyVerySafePassword"
}
Possible Outputs
- Success - 201
{
"token": "xyzdfsndkjfsdjThisIstheTokend"
}
- Bad Request - 400 - malformed payload
{
"message": "Phone Number and Password are required"
}
- Bad Request - 400 - Account already Exists
{
"message": "Account already exists"
}
This endpoint logs a user in by returning JWT token for given login credentials.
Input
{
"phoneNumber": 919999999999,
"password": "ThisIsMyVerySafePassword"
}
Possible Outputs
- Success - 200
- Bad Request - 400 - Malform Payload
- Bad Request - 400 - Wrong Login Credentials
Creates a contact for a user after validating the phone number using Bird Messaging Lookup API.
Input
{
"name": "My Friend 1",
"mob_number": 1977979797
}
Possible Outputs
- Success - 201
- Bad Request - 400