This is a RESTful API for managing a medicine inventory system, built using Node.js, Express, and MongoDB. It allows CRUD operations for medicines, with seller-level management and authentication.
Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes.
Ensure you have the following software installed on your machine:
-
Clone the repository:
git clone https://github.com/Tech-Fear/ZM.git cd ZM -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and add your MongoDB connection string:MONGODB_URI=mongodb://localhost:27017/medicineDB
-
Start the MongoDB server (if not already running):
mongod
-
Start the application:
npm start
The server should now be running on http://localhost:3000.
Use tools like Postman or curl to interact with the API endpoints.
- URL:
/api/medicine/addMedicine - Method:
POST - Body:
{ "name": "Medicine Name", "price": 100, "salt": ["Salt1", "Salt2"], "manufacturer": "Manufacturer Name", "type": "tablet", "quantity": 10, "description": "Description", "category": "category1", "expiry": "2023-12-31" } - Response:
201 Created
- URL:
/api/medicine/getMedicine - Method:
GET - Response:
200 OK[ { "_id": "medicineId", "name": "Medicine Name", ... } ]
- URL:
/api/medicine/getMedicine/Name/:name - Method:
GET - Response:
200 OK[ { "_id": "medicineId", "name": "Medicine Name", ... } ]
- URL:
/api/medicine/getMedicine/Category/:category - Method:
GET - Response:
200 OK[ { "_id": "medicineId", "category": "category1", ... } ]
- URL:
/api/medicine/getMedicine/Type/:type - Method:
GET - Response:
200 OK[ { "_id": "medicineId", "type": "tablet", ... } ]
- URL:
/api/medicine/getMedicine/Manufacturer/:manufacturer - Method:
GET - Response:
200 OK[ { "_id": "medicineId", "manufacturer": "Manufacturer Name", ... } ]
- URL:
/api/medicine/updateMedicine/quantity/:name - Method:
PUT - Body:
{ "quantity": 20 } - Response:
200 OK
- URL:
/api/medicine/updateMedicine/price/:name - Method:
PUT - Body:
{ "price": 150 } - Response:
200 OK
- URL:
/api/medicine/deleteMedicine/:name - Method:
DELETE - Response:
200 OK
.
├── controllers
│ ├── medicine.controller.js
│ └── sellerLevel.controller.js
├── models
│ ├── medicine.js
│ ├── medicineSellerManageable.js
│ └── seller.js
├── routes
│ ├── medicine.routes.js
│ └── seller.routes.js
├── app.js
└── package.jsonFeel free to fork the repository, create pull requests, and suggest improvements. Your contributions are always welcome!