A RESTful API for managing user health information and medications.
This API provides endpoints for managing users, their medications, and health information. Built with Node.js and Express.js, it uses MongoDB for data persistence and includes authentication features.
- Node.js (v14 or higher)
- npm (Node Package Manager)
- MongoDB
- Clone the repository:
git clone https://github.com/yourusername/zerin-labs-api.git
cd zerin-labs-api
- Install dependencies:
npm install
- Configure environment variables in
env.js
:
export const MONGOURI = "your_mongodb_connection_string";
export const secretKey = "your_secret_key_for_jwt";
export const salt = "your_bcrypt_salt";
- Start the server:
node src/app.js
The server will start on http://localhost:3001/api/
zerin-labs-api/
├── src/
│ ├── app.js # Express app setup
│ ├── controllers/ # Route controllers
│ ├── models/ # Database models
│ └── routes/ # API routes
├── env.js # Environment variables
├── .gitignore
├── package.json
└── README.md
http://localhost:3001/api/
GET /users
- Get all usersPOST /users
- Create a new userPOST /users/login
- User loginPATCH /users
- Update user informationPOST /users/points
- Manage user points
GET /medications
- Get all medicationsPOST /medications
- Add a new medicationGET /medications/:docId
- Get specific medication informationPATCH /medications/:docId
- Update medication information
- express: ^4.18.2 - Web framework
- mongoose: ^7.1.0 - MongoDB ODM
- bcrypt: ^5.1.0 - Password hashing
- jsonwebtoken: ^9.0.0 - JWT authentication
- cors: ^2.8.5 - Cross-Origin Resource Sharing
- dotenv: ^16.0.3 - Environment variable management
- mongodb: ^5.4.0 - MongoDB driver
Required environment variables in env.js
:
MONGOURI
: MongoDB connection stringsecretKey
: Secret key for JWT token generationsalt
: BCrypt salt for password hashing
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the ISC License.