Skip to content

Latest commit

 

History

History
274 lines (196 loc) · 3.49 KB

DOCUMENTATION.md

File metadata and controls

274 lines (196 loc) · 3.49 KB

📔 Documentation

Concept

🔏 Create a private store

  • You will save all the data in the store.
  • On creating the store, you will get a store key.
  • This will prevent other users to get access to your store.
  • Save the key securely as it will be the first and last time you can see the key
  • The key will be required to perform operations on the store (like adding the data to it, updating it and so on...)

📁 Create Data

  • To save the data you will require the store id and store key.
  • The data to be saved should be a String.

API Usage

📎 Index

  1. Create store
  2. Create data
  3. Update data
  4. Get data
  5. Delete data
  6. Get store
  7. Delete Store

1. Create store

Endpoint: /api/store

Request Type: POST

Body:

{
  "name": "Store name"
}

Success Response:

{
  "message": "Store created!",
  "success": true,
  "storeKey": "uuid v4 key",
  "storeId": "store id"
}

Errors:

  • Store already exists
    Try using a different name

2. Create Data

Endpoint: /api/data

Request Type: POST

Body:

{
  "storeId": "store id",
  "storeKey": "uuid v4 key",
  "value": "string value"
}

Success Response:

{
  "message": "Data created successfully",
  "success": true,
  "data": {
    "id": "data id",
    "value": "string value",
    "storeId": "store id"
  },
  "store": {
    "id": "store id",
    "name": "store name"
  }
}

Errors:

  • Store not found
  • Invalid store key

3. Update data

Endpoint: /api/data/{{ dataId }}

Request Type: PUT

Body:

{
  "storeKey": "uuid v4 key",
  "value": "string value"
}

Success Response:

{
  "message": "Data updated successfully",
  "success": true,
  "data": {
    "id": "data id",
    "value": "string value"
  },
  "store": {
    "name": "store name",
    "id": "store id"
  }
}

Errors:

  • Data not found
  • Data is same
  • Invalid store key

4. Get Data

Endpoint: /api/data/{{ dataId }}

Request Type: POST

Body:

{
  "storeKey": "uuid v4 store key"
}

Success Response:

{
  "message": "Data fetched successfully",
  "success": true,
  "data": {
    "id": "data id",
    "value": "string value"
  },
  "store": {
    "name": "store name",
    "id": "store id"
  }
}

Errors:

  • Data not found
  • Invalid store key

5. Delete Data

Endpoint: /api/data/{{ dataId }}?delete=true

Request Type: POST

Body:

{
  "storeKey": "uuid v4 store key"
}

Success Response:

{
  "message": "Data deleted successfully",
  "success": true
}

Errors:

  • Data not found
  • Invalid store key

6. Get Store

Endpoint: /api/store/{{ storeId }}

Request Type: POST

Body:

{
  "storeKey": "uuid v4 store key"
}

Success Response:

{
  "message": "Store found!",
  "success": true,
  "store": {
    "id": "store id",
    "name": "store name",
    "data": []
  }
}

Errors:

  • Store not found
  • Invalid store key

7. Delete Store

Endpoint: /api/store/{{ storeId }}?delete=true

Request Type: POST

Body:

{
  "storeKey": "uuid v4 store key"
}

Success Response:

{
  "message": "Store deleted!",
  "success": true
}

Errors:

  • Store not found
  • Invalid store key