Serverless API for Comment Submission


This document specifies the serverless function deployed on Vercel for handling comment submissions to blog posts. The function will receive POST requests containing comment data, update the relevant post’s comment file in the repository on a separate comments branch, and commit the changes.


Request Body

The request body must be a JSON object containing the following fields:


  1. Parse Request: Extract postId, commentParentId, name, email, and commentText from the incoming request.

  2. Repository Setup:

  3. Comment File Update:

  4. Commit and Push:

  5. Cleanup: Ensure temporary files and the cloned repository are cleaned up after the operation.

Security and Best Practices


Error Handling

The function should gracefully handle and log errors, including:


Comprehensive testing should cover:


Deploy the serverless function on Vercel, ensuring that all environment variables and permissions are correctly set up.