Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rahul-sahani04/userapimongo

A Node.js, Express, and MongoDB-based API for effortless user data management. Create, retrieve, update, and delete users with built-in authentication and authorization. Simplify user interactions while ensuring data security.
https://github.com/rahul-sahani04/userapimongo

api expressjs mongodb mongoose nodejs

Last synced: 10 days ago
JSON representation

A Node.js, Express, and MongoDB-based API for effortless user data management. Create, retrieve, update, and delete users with built-in authentication and authorization. Simplify user interactions while ensuring data security.

Awesome Lists containing this project

README

        

# User API for MERN Projects
This repository contains a User API built on top of MongoDB, designed to be integrated into MERN (MongoDB, Express, React, Node.js) stack projects or for other use cases. The API provides basic CRUD (Create, Read, Update, Delete) operations for managing user data.

## Features
User Management: Perform CRUD operations on user data, including creating new users, fetching user details, updating user information, and deleting users.
Authentication: Secure endpoints with authentication to ensure only authorized users can access and modify user data.
Validation: Input data is validated to ensure integrity and consistency.
Scalable: Built on top of MongoDB, the API can handle a large number of users and is suitable for scaling up.

## Prerequisites
Node.js and npm installed.
MongoDB server running.
Basic understanding of RESTful APIs.

## Installation
Clone this repository.

```bash

git clone https://github.com/Rahul-Sahani04/UserApiMongo
```
```bash
cd user-api
```

Install dependencies.
```bash
npm install
```

Configure environment variables.

## Start the server.

```bash
npm run dev
```

## Usage
Register a new user:
Send a POST request to /api/users/register with user data in the request body.

Login:
Send a POST request to /api/users/login with valid credentials. You will receive a JWT token upon successful login.

### Access User Data:
Include the received JWT token in the Authorization header for authenticated routes to access user data.

### CRUD Operations:

- Create: Send a POST request to /users/add with new user data.
- Read: Send a GET request to /users/search to fetch user details.
- Update: Send a PUT request to /users/:userId with updated user data.
- Delete: Send a DELETE request to /users/:userId to delete a user.

## Contributing
Contributions are welcome! If you find any issues or improvements, feel free to open a pull request.

## License
This project is licensed under the [MIT License](https://mit-license.org/).

---
Happy coding!