This repository provides a starter kit for building user authentication and authorization features in a Node.js application. It includes a sample login and registration flow, as well as an example of how to protect routes and manage user roles and permissions.
- User registration and login
- Hashing and salting of passwords
- JWT-based authentication
- Route protection and user role management
- Example implementation of user roles and permissions
- Clone the repository
git clone https://github.com/sandeepkv93/node-user-auth-starterkit.git
- Install dependencies
npm install
- Start the server
npm start
- Test the endpoints using a tool like Postman or Insomnia. The following routes are available:
- POST /register for user registration
- POST /login for user login
- GET /protected for a protected route example
- Update the config.js file with your own JWT secret and database configuration
- Add more roles and permissions in the config.js file as per your requirements
- Update the User model in models directory with any additional fields you need
- Update the auth middleware in middlewares directory as per your requirements
- Add more routes and update the existing routes as per your requirements
- Node.js
- Express.js
- MongoDB (with Mongoose)
- jsonwebtoken
- bcrypt