@@ -110,22 +110,22 @@ All operations except **GET** require a valid JWT in the `Authorization: Bearer
110110
1111112. ** ✍️ Store or Update a Value (HTTP PUT)**
112112 Create or update a value under ` {table}/{key}` .
113- - URL: ` /default /key/mykey `
113+ - URL: ` /{table} /key/{key} `
114114 - Headers:
115115 ` ` `
116116 Content-Type: application/json
117117 Authorization: Bearer < JWT‑TOKEN>
118118 ` ` `
119119 - Body:
120120 ` ` ` json
121- { " value" : " mydata " }
121+ { " value" : { ... } }
122122 ` ` `
123123 - Success:
124124 • ` 201 Created`
125125 • Body (VersionedValue):
126126 ` ` ` json
127127 {
128- " value" : " mydata " ,
128+ " value" : { ... } ,
129129 " version" : 1,
130130 " timestamp" : 1618880821123,
131131 " owner" : " alice"
@@ -134,25 +134,52 @@ All operations except **GET** require a valid JWT in the `Authorization: Bearer
134134 - Errors:
135135 • ` 401 Unauthorized` if missing/invalid JWT or not owner on update
136136
137- 3. ** 🔍 Retrieve a Value (HTTP GET)**
137+ 3. ** 🛠️ Partially Update a Value (HTTP PATCH)**
138+ Merge updates into an existing value under ` {table}/{key}` . Only the owner can patch.
139+ - URL: ` /{table}/key/{key}`
140+ - Headers:
141+ ` ` `
142+ Content-Type: application/json
143+ Authorization: Bearer < JWT‑TOKEN>
144+ ` ` `
145+ - Body:
146+ ` ` ` json
147+ { " new_field" : " updated_data" }
148+ ` ` `
149+ - Success:
150+ • ` 200 OK`
151+ • Body (Updated VersionedValue):
152+ ` ` ` json
153+ {
154+ " value" : { " original_field" : " ..." , " new_field" : " updated_data" },
155+ " version" : 2,
156+ " timestamp" : 1618880825000,
157+ " owner" : " alice"
158+ }
159+ ` ` `
160+ - Errors:
161+ • ` 401 Unauthorized` if missing/invalid JWT or not owner
162+ • ` 404 Not Found` if key/table missing
163+
164+ 4. ** 🔍 Retrieve a Value (HTTP GET)**
138165 Anyone can fetch a key’s latest value.
139- - URL: ` /default /key/mykey `
166+ - URL: ` /{table} /key/{key} `
140167 - Success:
141168 • ` 200 OK`
142169 • Body:
143170 ` ` ` json
144171 {
145- " value" : " mydata " ,
172+ " value" : { ... } ,
146173 " version" : 1,
147174 " timestamp" : 1618880821123,
148175 " owner" : " alice"
149176 }
150177 ` ` `
151178 • ` 404 Not Found` if key/table missing
152179
153- 4 . ** 🗑️ Delete a Value (HTTP DELETE)**
180+ 5 . ** 🗑️ Delete a Value (HTTP DELETE)**
154181 Only the owner may delete.
155- - URL: ` /default /key/mykey `
182+ - URL: ` /{table} /key/{key} `
156183 - Header:
157184 ` ` `
158185 Authorization: Bearer < JWT‑TOKEN>
@@ -167,46 +194,46 @@ All operations except **GET** require a valid JWT in the `Authorization: Bearer
167194 • ` 401 Unauthorized` if no JWT or not owner
168195 • ` 404 Not Found` if key/table missing
169196
170- 5 . ** 📚 Fetch Entire Table Store (HTTP GET)**
197+ 6 . ** 📚 Fetch Entire Table Store (HTTP GET)**
171198 List all key→VersionedValue pairs in a table.
172- - URL: ` /default /store`
199+ - URL: ` /{table} /store`
173200 - Success:
174201 • ` 200 OK`
175202 • Body:
176203 ` ` ` json
177204 {
178- " key1" : { " value" :" v1 " ," version" :2,…," owner" :" bob" },
205+ " key1" : { " value" :{...} ," version" :2,…," owner" :" bob" },
179206 " key2" : { … }
180207 }
181208 ` ` `
182209 - ` 404 Not Found` if table missing
183210
184- 6 . ** 🔑 List or Batch‑Fetch Keys**
185- 6 .1 ** GET** ` /default /keys`
211+ 7 . ** 🔑 List or Batch‑Fetch Keys**
212+ 7 .1 ** GET** ` /{table} /keys`
186213 • ` 200 OK` →
187214 ` ` ` json
188215 [" key1" ," key2" ,…]
189216 ` ` `
190- 6 .2 ** POST** ` /default /keys`
217+ 7 .2 ** POST** ` /{table} /keys`
191218 - Body:
192219 ` ` ` json
193220 [" key1" ," key2" ," key3" ]
194221 ` ` `
195222 - ` 200 OK` →
196223 ` ` ` json
197224 {
198- " key1" : { " value" :" v1 " ," version" :… },
225+ " key1" : { " value" :{...} ," version" :… },
199226 " key3" : { … }
200227 }
201228 ` ` `
202229 (non‑existent keys are omitted)
203230
204- 7 . ** 🔔 Subscribe to Real‑Time Updates (SSE)**
231+ 8 . ** 🔔 Subscribe to Real‑Time Updates (SSE)**
205232 Instant updates on a single key.
206- - URL: ` /default /subscribe/mykey `
233+ - URL: ` /{table} /subscribe/{key} `
207234 - Usage:
208235 ` ` ` bash
209- curl -N http://localhost:6660/default /subscribe/mykey
236+ curl -N http://localhost:6660/{table} /subscribe/{key}
210237 ` ` `
211238 - Each update is a JSON event:
212239 ` ` ` json
@@ -232,22 +259,26 @@ TOKEN=$(curl -s -X POST http://localhost:6660/auth/alice \
232259curl -i -X PUT http://localhost:6660/default/key/foo \
233260 -H " Content-Type: application/json" \
234261 -H " Authorization: Bearer $TOKEN " \
235- -d ' {"value":"hello"}'
262+ -d ' {"value": {"name": "bar"}}'
263+
264+ # 4) PATCH (partially update)
265+ curl -i -X PATCH http://localhost:6660/default/key/foo \
266+ -H " Content-Type: application/json" \
267+ -H " Authorization: Bearer $TOKEN " \
268+ -d ' {"age": 30}'
236269
237- # 4 ) GET
270+ # 5 ) GET
238271curl -i http://localhost:6660/default/key/foo
239272
240- # 5 ) DELETE (owner only)
273+ # 6 ) DELETE (owner only)
241274curl -i -X DELETE http://localhost:6660/default/key/foo \
242275 -H " Authorization: Bearer $TOKEN "
243276
244- # 6 ) Node stats
277+ # 7 ) Node stats
245278curl http://localhost:6660/stats
246- Response:
247- {" tables" :{" auth" :2," test" :20088," default" :1}," total_keys" :20091," total_requests" :5," average_latency_ms" :0.4171416," active_sse_connections" :0}
248279` ` `
249280
250- > ⚠️ PUT/DELETE without a valid JWT → ** 401 Unauthorized**
281+ > ⚠️ PUT/PATCH/ DELETE without a valid JWT → ** 401 Unauthorized**
251282> 🔍 GET is always open (no auth needed).
252283---
253284
0 commit comments