about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README.md79
1 files changed, 41 insertions, 38 deletions
diff --git a/README.md b/README.md
index 27b662b..53e57df 100644
--- a/README.md
+++ b/README.md
@@ -42,14 +42,15 @@ Gn-Markdown is an API endpoint to edit, parse, and commit markdown files for gn-
 
 1. **Navigate to the Web Directory and Start the Server**
 
-    ```sh
-    cd web
-    . .guix-shell -- guile -L .. --listen=1970 -e main ./webserver.scm 8091
-    ```
+```sh
+cd web
+export GN_REPO_PATH=<repo_path>
+. .guix-shell -- guile -L .. --listen=1970 -e main ./webserver.scm 8091
+```
 
 2. **Test Endpoints**
 
-    The main endpoints provided are `/edit` and `/commit`. More endpoints may be added in the future.
+The main endpoints provided are `/edit` and `/commit`. More endpoints may be added in the future.
 
 ## Edit (GET)
 
@@ -57,8 +58,9 @@ This is a GET request to retrieve a file's details. Make sure you pass a valid f
 
 **Request Example:**
 
-```
-localhost:8091/edit?file_path=test.md
+```bash
+
+curl -G -d "file_path=test.md"  localhost:8091/edit
 
 ```
 
@@ -66,9 +68,9 @@ localhost:8091/edit?file_path=test.md
 
 ```json
 {
-    "path": "test.md",
-    "content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n",
-    "hash": "ecd96f27c45301279150fbda411544687db1aa45"
+"path": "test.md",
+"content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n",
+"hash": "ecd96f27c45301279150fbda411544687db1aa45"
 }
 ```
 
@@ -76,8 +78,8 @@ localhost:8091/edit?file_path=test.md
 
 ```json
 {
-    "error": "file-error",
-    "msg": "The file path /home/kabui/test_repo/test.md does not exist"
+"error": <error_type>,
+"msg": <error_reason>
 }
 ```
 
@@ -87,42 +89,43 @@ This is a POST request to commit changes to a file.
 
 **Request URL:**
 
-```
-localhost:8091/commit
-```
+```bash
 
-**Request Body Example:**
+curl -X POST http://127.0.0.1:8091/commit \
+-H 'Content-Type: application/json' \
+-d '{
+"content": "make test commit",
+"filename": "test.md",
+"email": "test@gmail.com",
+"username": "test",
+"commit_message": "init commit",
+"prev_commit": "7cbfc40d98b49a64e98e7cd562f373053d0325bd"
+}'
 
-```json
-{
-    "content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n",
-    "prev_commit"  : "ecd96f27c45301279150fbda411544687db1aa45",
-    "filename": "./test.md",
-    "username": "genetics",
-    "email": "genetics@gmail.com",
-    "commit_message": "commit by genetics"
-}
 ```
 
-**Expected Success Response:**
+
+
+**Expected Response for success:**
 
 ```json
 {
-    "status": "201",
-    "message": "Committed file successfully",
-    "content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n",
-    "commit-sha": "47df3b7f13a935d50cc8b40e98ca9e513cba104c",
-    "commit-message": "commit by genetics"
+"status": "201",
+"message": "Committed file successfully",
+"content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n",
+"commit_sha": "47df3b7f13a935d50cc8b40e98ca9e513cba104c",
+"commit_message": "commit by genetics"
 }
+
 ```
 
 **If No Changes to File:**
 
 ```json
 {
-    "status": "200",
-    "message": "Nothing to commit, working tree clean",
-    "commit-sha": "ecd96f27c45301279150fbda411544687db1aa45"
+"status": "200",
+"message": "Nothing to commit, working tree clean",
+"commit-sha": "ecd96f27c45301279150fbda411544687db1aa45"
 }
 ```
 
@@ -130,14 +133,14 @@ localhost:8091/commit
 
 ```json
 {
-    "error": "system-error",
-    "msg": "Commits do not match. Please pull in the latest changes for the current commit *ecd96f27c45301279150fbda411544687db1aa45* and previous commits."
+"error": "system-error",
+"msg": "Commits do not match. Please pull in the latest changes for the current commit *ecd96f27c45301279150fbda411544687db1aa45* and previous commits."
 }
 ```
 
-## Notes 
+## Notes
 
-This is meant to be used as api endpoint only to edit any local repo; Clients are expected to handle other service e.g User Interface, authentication 
+This is meant to be used as api endpoint only to edit any local repo; Clients are expected to handle other service e.g User Interface, authentication
 
 # Development