/redis-express

(college project) Express backend for redis

Primary LanguageJavaScript

Installation

  1. install Node.js 18 or newer
  2. clone repository or download code
  3. run install.sh or install.bat
  4. run start.sh or start.bat

Usage

GET

POST your_address/get

JSON parameters:

  1. array of requested keys

Example:

curl -X POST \
  -H "Accept: application/json" \
  -H "Content-type: application/json" \
  -d '["test", "Hello World"]' \
  "http://127.0.0.1/get"

Example response (assuming both "test" and "Hello World" keys exist):

{
	"test": "123",
	"Hello World": "Hello world!",
}

SET

POST your_address/set

JSON parameters:

  1. object of keys and values

Example:

curl -X POST \
  -H "Accept: application/json" \
  -H "Content-type: application/json" \
  -d '{"test":"123","Hello World": "Hello world!"}' \
  "http://127.0.0.1/set"

Example response

{
	"test": "Set",
	"Hello World": "Set"
}

DEL

DELETE your_address/del

JSON parameters:

  1. array of keys

Example:

curl -X POST \
  -H "Accept: application/json" \
  -H "Content-type: application/json" \
  -d '["test"]' \
  "http://127.0.0.1/del"

Example response

{
	"test": "Deleted"
}

Authorization

  1. create .env file in root folder
  2. set keyRequired inside config.json to true

Now every request will require Key header with valid key

Example:

curl -X POST \
  -H "Accept: application/json" \
  -H "Content-type: application/json" \
  -H "Key: MY_SECRET_KEY" \
  -d '["test", "Hello World"]' \
  "http://127.0.0.1/get"

TODO

  • Other redis operations
    • Lists
    • Sets
    • Hashes