Skip to content

sometimes-youwin/ywkv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YWKV

Pronounced Yuu-Kiv. A simple key-value server that uses redb for persistence.

Usage

  • --port: The port to listen on. Defaults to 9958 (YWKV via T9 keyboard).
  • --table-name: The name of the redb table to use. Defaults to main.
  • --db-file-name: The name of the redb file to read/write on disk. Defaults to ywkv.redb.
  • token: The bearer auth token to check GET/POST requests against. Required.
ywkv [--port value] [--table-name value] [--db-file-name value] <token>

All requests should be in format address/:key. Value payloads are passed as text.

Writing a value

Request:

curl -X POST -H "Authorization: Bearer hello" localhost:9958/hello -d "world" | jq -C

Response (200):

{
  "value": "",
  "status": "SuccessNew"
}

Reading a value

Request:

curl -X GET -H "Authorization: Bearer hello" localhost:9958/hello | jq -C

Response (200):

{
  "value": "world",
  "status": "Found"
}

Reading a value from an empty table

Request:

curl -X GET -H "Authorization: Bearer hello" localhost:9958/hello | jq -C

Response (500):

{
  "value": "Table 'main' does not exist",
  "status": "Failure"
}

Overwriting a value

Request:

curl -X POST -H "Authorization: Bearer hello" localhost:9958/hello -d "world" | jq -C

Response (200):

{
  "value": "world",
  "status": "SuccessOverwrite"
}

Reading a missing value

Request:

curl -X GET -H "Authorization: Bearer hello" localhost:9958/missing | jq -C

Response (404):

{
  "value": "",
  "status": "Missing"
}