This is the backend for the customer management application. It provides a RESTful API to manage customers and addresses.
- Node.js
- Express.js
- MongoDB
- Mongoose
-
Clone this repository:
git clone https://github.com/zhadowx/Customer-Management-Backend.git cd backend-repo
-
Install the dependencies:
npm install
-
Set up the environment variables: Create a
.env
file in the root of the project and add the following variables:NODE_ENV=development PORT=3000 DATABASE=YOUR-DATABASE DATABASE_PASSWORD=YOUR-DATABSE-PASSWORD
Note: The MongoDB connection string and password is not shared as it is linked to a personal account. Please use your own MongoDB credentials.
-
Start the server:
npm start
GET /api/v1/customers
- Get all customers.GET /api/v1/customers/:id
- Get a customer by ID.POST /api/v1/customers
- Create a new customer.PATCH /api/v1/customers/:id
- Update a customer by ID.DELETE /api/v1/customers/:id
- Delete a customer by ID.
GET /api/v1/addresses
- Get all addresses.GET /api/v1/addresses/:id
- Get an address by ID.POST /api/v1/addresses
- Create a new address.PATCH /api/v1/addresses/:id
- Update an address by ID.DELETE /api/v1/addresses/:id
- Delete an address by ID.
POST /api/v1/customers/:id/addresses
- Update the addresses of a customer by providing an array of address IDs.
backend/ ├── controllers/ │ ├── addressController.js │ └── customerController.js ├── models/ │ ├── addressModel.js │ └── customerModel.js ├── routes/ │ ├── addressRoutes.js │ └── customerRoutes.js ├── .env ├── app.js ├── server.js └── package.json
npm start
: Starts the server with nodemon.
cors
: ^2.8.5dotenv
: ^16.4.5express
: ^4.19.2mongoose
: ^8.4.3morgan
: ^1.10.0
cross-env
: ^7.0.3eslint
: ^8.57.0eslint-config-airbnb
: ^19.0.4eslint-config-prettier
: ^9.1.0eslint-plugin-import
: ^2.29.1eslint-plugin-jsx-a11y
: ^6.8.0eslint-plugin-node
: ^11.1.0eslint-plugin-prettier
: ^5.1.3eslint-plugin-react
: ^7.34.1ndb
: ^1.1.5nodemon
: ^3.1.3prettier
: ^3.2.5
This project requires Node.js version 20.0.0 or higher.