This is a web application built using Node.js, MongoDB, and JWT authentication. It provides a RESTful API for performing CRUD (Create, Read, Delete) operations on user details.
- User authentication using JWT (JSON Web Tokens)
- User registration and login
- Create, read, and delete user details
- Secure API endpoints with authentication middleware
- Node.js: A JavaScript runtime environment for server-side development.
- Express.js: A web application framework for Node.js.
- MongoDB: A NoSQL database for storing user details.
- Mongoose: An object modeling library for MongoDB and Node.js.
- JSON Web Tokens (JWT): A standard for secure authentication and authorization.
- Bcrypt: A library for password hashing and salting.
-
Clone this repository to your local machine.
git clone https://github.com/AjayPrasadVerma/registration.git
-
Navigate to the project directory.
cd your-repo
-
Install the dependencies using npm (Node Package Manager).
npm install
-
Configure the environment variables.
-
Create a
.env
file in the root directory. -
Provide the necessary environment variables:
PORT=1000 MONGODB_URI=<your-mongodb-uri> JWT_SECRET=<your-jwt-secret>
-
-
Start the application.
npm start
-
The application should now be running on
http://localhost:1000
.
-
Endpoint:
POST /signup
-
Request Body:
{ "username": "example@gmail.com", "password": "secretpassword" }
-
Response:
{ "message": "Successfully Signup please login!." }
-
Endpoint:
POST /login
-
Request Body:
{ "username": "example@gmail.com", "password": "secretpassword" }
-
Response:
{ "token": "<jwt-token>" }
-
Endpoint:
GET /user
-
Response:
{ "id": "1", "name": "John Doe", "email": "john.doe@example.com", "Date of Birth" : --/--/----, "Age": "--", "Gender": "----", "Country": "----", "State": "-----", "City" : "-------" }
-
Endpoint:
POST /user
-
Request Body:
{ "id": "1", "name": "John Doe", "email": "john.doe@example.com", "Date of Birth" : --/--/----, "Age": "--", "Gender": "----", "Country": "----", "State": "-----", "City" : "-------" }
-
Response:
{ "id": "1", "name": "John Doe", "email": "john.doe@example.com", "Date of Birth" : --/--/----, "Age": "--", "Gender": "----", "Country": "----", "State": "-----", "City" : "-------" }
-
Endpoint:
DELETE /api/user/delete
-
Response:
{ "message": "User deleted successfully." }
Contributions are welcome! If you find any issues or want to enhance the project, please open an issue or submit a pull request.
This project is licensed under the MIT License.
Feel free to customize the content according to your project's specific requirements. The README.md
file serves as a detailed guide for developers to understand your web app, its features, how to install it, and how to use its API endpoints.
Make sure to update the installation steps, API endpoints, and any other relevant information specific to your project.