MedApp API is a backend server built with Node.js, Express, and MongoDB for managing user authentication, password resets, file uploads, and more. This project was created for a hackathon and includes various features like JWT authentication, OTP generation, and payment processing.
- User Registration and Login
- JWT Authentication with Cookie Support
- Password Reset with OTP Verification
- File Upload and Download
- Payment Processing
- Doctor Management
- Node.js
- Express
- MongoDB
- JWT (JSON Web Tokens)
- Nodemailer
- Body-parser
- Cookie-parser
- Axios
- Cors
- Node.js installed
- MongoDB instance
- Yarn or npm
-
Clone the repository:
git clone https://github.com/your-username/medapp-api.git cd medapp-api
-
Install dependencies:
yarn install # or npm install
-
Set up environment variables:
Create a
.env
file in the root directory with the following contents:PORT=8000 MONGODB_PASSWORD=" MONGODB_URI=mongodb+srv://<username>:<password>@cluster0.xc3pjzx.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0 AI71_APIKEY= JWT_SECRET= GAPPUSER="nodemailer user" GAPP="nodemailer password" CLOUDINARY_CLOUD_NAME='' CLOUDINARY_API_KEY="" CLOUDINARY_API_SECRET="" STRIPE_SECRET_KEY=""
-
Start the server:
yarn start # or npm start
POST /api/users/register
: Register a new userPOST /api/users/login
: Log in a userPOST /api/users/logout
: Log out a user
POST /api/auth/register
: Register a new userPOST /api/auth/login
: Log in a userPOST /api/auth/logout
: Log out a user
POST /api/password-reset/request-reset
: Request a password resetPOST /api/password-reset/reset-password
: Reset the password
GET /api/protected
: Access a protected route (requires JWT token)
POST /api/generateOTP
: Generate an OTP for user verification
POST /api/upload
: Upload a fileGET /api/download/:filename
: Download a file
POST /api/payment
: Process a payment
GET /api/doctor
: Get doctor informationPOST /api/doctor
: Add a new doctor
authMiddleware
: Middleware to protect routes and verify JWT tokens
The application includes basic error handling for MongoDB connection errors and missing environment variables.
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! Please open an issue or submit a pull request for any changes.
Thanks to all the contributors and participants of the hackathon.