This repository contains the backend code for a basic authentication system. The backend is built using Node.js, Express, and MongoDB with Mongoose for data modeling. It includes user signup, signin, logout, and user information retrieval functionalities, secured with JWT for authentication.
- User registration (signup)
- User login (signin)
- User logout
- Retrieve user information
- JWT-based authentication
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT (JSON Web Token)
- Bcrypt.js
- Node.js
- MongoDB
-
Clone the repository:
git clone https://github.com/Rohansaini1512/Basic_Backend.git cd Basic_Backend
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add the following environment variables:PORT=5000 MONGO_URI=your_mongodb_uri JWT_SECRET=your_jwt_secret
-
Start the server:
npm start
The server will start on
http://localhost:5000
.
POST /api/auth/signup
- Register a new userPOST /api/auth/signin
- Authenticate a user and get a tokenPOST /api/auth/logout
- Logout a userGET /api/auth/user
- Get user information (requires token)
PORT=5000
MONGO_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret