Welcome to the Login-Signup API repository! This project is built using Node.js, Express, and MongoDB to provide a simple user authentication system with JWT support along with a proper interface. Below you'll find instructions on how to set up, run, and use the API.
This API provides endpoints for user registration and login, along with EJS-rendered pages for user interaction. It includes basic form handling with Axios on the frontend to communicate with the backend. It also provides validation and encryption for a safer login and signup.
- User registration and login with JWT authentication
- Error handling for invalid requests
- EJS templates for login and signup pages
- Basic form validation and feedback
- Encrypting password using bcrypt libarary
Follow these steps to set up the project locally:
-
Clone the repository:
git clone https://github.com/your-username/login-signup-api.git cd login-signup-api
-
Install dependencies:
npm install
-
Set up environment variables:
Create a
config.env
file in the root directory and add the following:DATABASE=your_mongodb_connection_string JWT_SECRET=your_jwt_secret JWT_EXPIRES_IN=90d
-
Start MongoDB: Create an account on MongoDb Atlas and then connect your cluster.
Open your browser and navigate to:
- Login Page:
http://localhost:7000/login
- Signup Page:
http://localhost:7000/signup
If You are using Postman to interact with the API.
- URL:
/api/v1/users/signup
- Method:
POST
- Body:
{ "name": "John Doe", "email": "john@example.com", "password": "yourpassword", "passwordConfirm": "yourpassword" }
Here are some screenshots of the application: