Skip to content

Feature/multi session and uploads#2

Merged
Codegres-com merged 3 commits intomainfrom
feature/multi-session-and-uploads
Sep 30, 2025
Merged

Feature/multi session and uploads#2
Codegres-com merged 3 commits intomainfrom
feature/multi-session-and-uploads

Conversation

@Codegres-com
Copy link
Copy Markdown
Owner

No description provided.

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.
@Codegres-com Codegres-com merged commit 6217b7c into main Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant