A JWT-based authentication backend built with Node.js, Express, and MongoDB, featuring secure user registration, login, refresh tokens, and protected routes. Includes Swagger API documentation and optional Supabase integration.
- User Registration & Login
- JWT Authentication (access & refresh tokens)
- Password Hashing with bcrypt
- Protected Routes via middleware
- RESTful API structure
- Swagger API Docs for easy testing
- Supabase integration (optional)
- Node.js
- Express.js
- MongoDB (Mongoose)
- JWT
- bcrypt
- Swagger
- Supabase
authback/
│── models/ # Mongoose models (User schema, etc.)
│── routes/ # Express routes (auth, protected, cart, etc.)
│── node_modules/ # Dependencies
│── server.js # Entry point of the application
│── swagger.js # Swagger configuration
│── supabase.js # Supabase client setup
│── .env # Environment variables
│── package.json # Project metadata & dependencies
│── README.md # Documentation
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/signup |
Register a new user |
| POST | /api/auth/login |
Login user |
| POST | /api/auth/logout |
Logout user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/user/userdetails |
Get logged-in user info |
| PUT | /api/user/updateuser |
Update user profile |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/getallproducts |
List all products |
| GET | /api/productsbycategory |
Get product details |
| POST | /api/createproduct |
Add new product (admin only) |
| DELETE | /api/deleteproduct |
Delete product (admin only) |
-
Clone the repo
git clone https://github.com/Tsaishashanth/authback.git cd authback -
Install the dependencies
npm install
-
Create .env file
PORT=5000 MONGO_URI=your_mongodb_connection JWT_SECRET=your_jwt_secret JWT_REFRESH_SECRET=your_refresh_secret SUPABASE_URL=your_supabase_url SUPABASE_KEY=your_supabase_key
-
Run the server
npm run dev