Keys List API - GET, POST, DELETE - /api/keys/

Use this endpoint to:
  • retrieve all keys in the database
  • create an individual key
  • delete all keys

GET /api/keys/

This endpoint will:
  • return an array of all the keys in the database.
Request:
GET https://nifty-dogs-api.herokuapp.com/api/keys/
Response:
[
    {
        "id": 1,
        "key": "testing",
        "int_value": 1,
        "slug": "testing",
        "created_at": "2022-12-11T02:05:53.290299Z",
        "updated_at": "2022-12-11T02:05:53.290380Z"
    },
    {
        "id": 2,
        "key": "testing2",
        "int_value": 1,
        "slug": "testing2",
        "created_at": "2022-12-11T03:09:02.465273Z",
        "updated_at": "2022-12-11T03:09:02.465290Z"
    },
    {
        "id": 3,
        "key": "testing 2 and 3",
        "int_value": 3,
        "slug": "testing-2-and-3",
        "created_at": "2022-12-11T03:09:18.198690Z",
        "updated_at": "2022-12-11T21:00:43.580932Z"
    }
]

POST /api/keys/

This endpoint will:
  • create a new key in the database
  • only need to submit the name of the key
  • create a slug based on your key value
  • the slug will allow you to increment the value of your key in the future
  • Your key can contain spaces, letters, numbers, underscores or hyphens
  • created instance will be returned upon completion
Request:
POST https://nifty-dogs-api.herokuapp.com/api/keys/
Body:
{ "key": "test test test" }
Response: returns created database entry

{
    "id": 4,
    "key": "test test test",
    "int_value": 1,
    "slug": "test-test-test",
    "created_at": "2022-12-11T02:05:53.290299Z",
    "updated_at": "2022-12-11T02:05:53.290380Z"
}

DELETE /api/keys/

This endpoint will:
  • delete all the keys in the database
Request:
DELETE https://nifty-dogs-api.herokuapp.com/api/keys/
Response:
{ "message": "All keys were deleted successfully!" }