This is a Node.js server project created using Visual Studio Code. The server is designed to perform CRUD operations on a MongoDB database for managing user information.
-
Clone the repository:
git clone https://github.com/brunomatosdev/Node-JS-Server Navigate to the project directory: bash
cd Node-JS-Server
Install dependencies:
bash
npm install
Configure MongoDB:
Update the MongoDB connection details in the config.js file.
Usage
Start the server:
bash
npm start
The server will start running on the specified port (default is 8080).
Access the API:
Open your web browser or use a tool like Postman to interact with the following API endpoints.
Configuration
MongoDB Connection:
Update the MongoDB connection details in the config.js file.
Environment Variables:
Customize environment variables in the .env file.
API Endpoints
-
Create a User
Endpoint: POST /api/users Request Body:
json
{ "name": "John Doe", "email": "[email protected]", "password": "securepassword" }
-
Get All Users
Endpoint: GET /api/users
-
Get User by ID
Endpoint: GET /api/users/:id
-
Update User by ID
Endpoint: PUT /api/users/:id Request Body:
json
{ "name": "Updated Name", "email": "[email protected]" }
-
Delete User by ID
Endpoint: DELETE /api/users/:id
Contributing
If you would like to contribute to the project, please follow these steps:
Fork the repository.
Create a new branch for your feature or bug fix.
Make your changes and submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.