A REST API service to expose endpoints that allow users to Register, Login and make authenticated Requests to acess the blog articles.
- An authservice REST API in Node JS:
- Database: MongoDb
- Backend: NodeJS and Express
to login/ authorize the user.
API endpoints allow users to:
- Register
- Log in
based on JWT tokens
- A Blogging Service REST API in Node JS:
- Database: MongoDb
- Backend: NodeJS and Express
API endpoints allow users to:
- Read,
- Write,
- Update,
- Delete Blogs,
- search Blogs by Author Name.
Server: Express
Language: JavaScript
Database: MongoDb
POST api/users/register
Parameter | Type | Description |
---|---|---|
username |
string |
Required. username to register |
email |
string |
Required. email id of user |
password |
string |
Required. password of the user |
confirmPassword |
string |
Required. password of the user |
User Story | Response code | Type | Response Message |
---|---|---|---|
New user enters correct details expects registration | 200 |
success |
"Succesfully Registered" |
User Enters an email which is already registered | 400 |
failure |
"Email already exists, try login" |
User leaves the name blank | 400 |
failure |
"Name cannot be empty" |
User leaves the e-mail blank | 400 |
failure |
"E-mail cannot be empty" |
User enters and invalid e-mail | 400 |
failure |
"Email is invalid" |
User leaves the password blank | 400 |
failure |
"Password field is required" |
User leaves the confirm password blank | 400 |
failure |
"Confirm password field is required" |
User Enters a password less than 8 characters | 400 |
failure |
"Password must be at least 8 characters" |
User enters different password, confirm password | 400 |
failure |
"Passwords must match" |
{
"name": "Rohit Kumar",
"email": "[email protected]",
"password": "rohit_password1 ",
"confirmPassword": "rohit_password1"
}
{
"msg": "Succesfully Registered"
}
POST api/users/login
Parameter | Type | Description |
---|---|---|
email |
string |
Required. email id of user |
password |
string |
Required. password of the user |
User Story | Response code | Type | Response Message |
---|---|---|---|
New user enters correct details expects login | 200 |
success |
"User successfully logged in" |
User enters an email which is not registered | 400 |
failure |
"Email not found" |
User enters a wrong password | 400 |
failure |
"Password Incorrect" |
User leaves the e-mail blank | 400 |
failure |
"E-mail cannot be empty" |
User enters and invalid e-mail | 400 |
failure |
"Email is invalid" |
User leaves the password blank | 400 |
failure |
"Password field is required" |
User Enters a password less than 8 characters | 400 |
failure |
"Password must be at least 8 characters" |
{
"email": "[email protected]",
"password": "rohit_password1 "
}
{
"success": true,
"msg": "User successfully logged in",
"token": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMjMzZDMxNTUxNDc3ZmFiYjBlNzZhNCIsIm5hbWUiOiJSb2hpdCBLdW1hciIsImlhdCI6MTY0NjQ4MjM1NCwiZXhwIjoxNjc4MDM5MjgwfQ.N8BUmTS2w82E3ORX4n9tv21r8AT9TT5I3I9-K6KqzSM"
}
-
Open your terminal in the required directory
-
Clone the repository
git clone [email protected]:stenzr/authService.git
- CD to the project directory
cd authService
- Install the required modules
npm install
- Start server
nodemon run start
-
The server starts on localhost:5000
-
Use Postman to send request to the endpoints