This is a user authentication backend built using Node.js and Mogogo DB. It provides secure authentication and user management features for your application.
- User registration with email verification.
- User login with JWT (JSON Web Tokens) authentication.
- Password reset functionality.
- Secure password hashing.
- Role-based access control.
- MongoDB integration.
Before you begin, ensure you have met the following requirements:
- Node.js installed. Download it from nodejs.org.
- Mogogo DB or MongoDB installed and running. You can get it from mongodb.com.
-
Clone the repository:
git clone https://github.com/yourusername/express.backend.git cd express.backend
-
Install dependencies:
npm install
-
Create a
.env
file in the project root and configure your environment variables (see Configuration). -
Start the server:
- to start server without nodemon
npm start
- to start a server with nodemon
npm run dev
Your authentication backend should now be running on http://localhost:4000
.
You need to set up your environment variables in a .env
file in the project root. Here's an example .env
file:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/mogogodb
JWT_SECRET=mysecretkey
EMAIL_SENDER=email@example.com
EMAIL_PASSWORD=email_password
Make sure to replace the placeholder values with your actual configuration.
This backend provides the following API endpoints:
POST /users/register
- Register a new user.GET /users
- get all the users in the database.GET /users/:username
- get a perticular user based on userame
You can explore these endpoints using a tool like Postman or integrate them into your frontend application.