Merged
Conversation
This commit introduces several major features to the WhatsApp API server:
1. **Multi-Session Management:**
* The application is refactored from a single-client architecture to support multiple, isolated WhatsApp sessions.
* Each session is identified by a unique API key provided in the `X-API-KEY` request header.
* Session data is persisted to the `./sessions` directory, allowing connections to survive server restarts.
2. **Master API Key Authentication:**
* A new master authentication middleware is added to protect all API endpoints.
* A global `MASTER_API_KEY` must be set in the environment and provided in the `X-MASTER-KEY` header for all requests.
3. **File Upload Endpoint (`/upload`):**
* A new `POST /api/upload` endpoint is created to handle file uploads.
* It uses `multer` to accept files up to 25MB.
* Uploaded files are stored temporarily in the `./uploads` directory and a public URL is returned.
* A cleanup mechanism automatically deletes the uploaded files after 5 minutes.
4. **GET API for Sending Messages (`/send`):**
* A new `GET /api/send` endpoint is added for a simpler way to send messages.
* It accepts `number`, `message`, and an optional `attachmentUrl` as query parameters.
This commit introduces several major features to the WhatsApp API server:
1. **Multi-Session Management:**
* The application is refactored from a single-client architecture to support multiple, isolated WhatsApp sessions.
* Each session is identified by a unique API key provided in the `X-API-KEY` request header.
* Session data is persisted to the `./sessions` directory, allowing connections to survive server restarts.
2. **Master API Key Authentication:**
* A new master authentication middleware is added to protect all API endpoints.
* A global `MASTER_API_KEY` must be set in the environment and provided in the `X-MASTER-KEY` header for all requests.
3. **File Upload Endpoint (`/upload`):**
* A new `POST /api/upload` endpoint is created to handle file uploads.
* It uses `multer` to accept files up to 25MB.
* Uploaded files are stored temporarily in the `./uploads` directory and a public URL is returned.
* A cleanup mechanism automatically deletes the uploaded files after 5 minutes.
4. **GET API for Sending Messages (`/send`):**
* A new `GET /api/send` endpoint is added for a simpler way to send messages.
* It accepts `number`, `message`, and an optional `attachmentUrl` as query parameters.
5. **Documentation:**
* The `README.md` has been updated to reflect all new features, including the new authentication flow and API endpoints.
This commit introduces several major features and enhancements to the WhatsApp API server:
1. **Multi-Session Management:**
* The application is refactored from a single-client architecture to support multiple, isolated WhatsApp sessions.
* Each session is identified by a unique API key provided in the `X-API-KEY` request header.
* Session data is persisted to the `./sessions` directory, allowing connections to survive server restarts.
2. **Master API Key Authentication:**
* A new master authentication middleware is added to protect all API endpoints.
* A global `MASTER_API_KEY` must be set in the environment and provided in the `X-MASTER-KEY` header for all requests.
3. **Enhanced Attachment Sending:**
* The `POST /api/send-attachment` endpoint is updated to accept direct file uploads (`multipart/form-data`) in addition to URL and Base64-encoded files.
* A shared middleware for handling file uploads is created to ensure consistent behavior.
4. **File Upload Endpoint (`/upload`):**
* A new `POST /api/upload` endpoint is created to handle file uploads for later use.
* It returns a temporary URL (valid for 5 minutes) that can be used in other API calls.
5. **GET API for Sending Messages (`/send`):**
* A new `GET /api/send` endpoint is added for a simpler way to send messages and attachments via URL.
6. **Documentation:**
* The `README.md` has been comprehensively updated to reflect all new features, including the dual-key authentication flow, multi-session management, and updated API endpoints with examples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.