/karma-api

An API for Karma

Primary LanguageJavaScript

Karma API

About

The Karma API is a way to give users karma!

Getting Started

Prerequisites

  1. Docker
  2. Docker Compose
  3. Port 8080 is available

Running the API locally

Simply run export POSTGRES_DB=karma && export POSTGRES_PASSWORD=admin && POSTGRES_USER=admin && docker-compose up, the API should then be available at localhost:8080.

Note

Please update these environment variable values with a database user and not the superuser.

API

POST api/v1/user

Adds a user

REQUEST BODY:

  {
    "email": "example@example.com"
  }

RESPONSE BODY:

{
  "user_id": "e799061c-ce77-4082-9d05-8a9dde8a96c4",
  "created_at": "TIMESTAMP",
  "email": "example@example.com"
}

GET api/v1/user/${user_id}

Retrieves the user

RESPONSE BODY:

{
  "user_id": "e799061c-ce77-4082-9d05-8a9dde8a96c4",
  "created_at": "TIMESTAMP",
  "email": "example@example.com"
}

POST api/v1/group

Adds a group

REQUEST BODY

{
 "name": "My Group"
}

RESPONSE BODY

"e799061c-ce77-4082-9d05-8a9dde8a96c4"

GET api/v1/group/${group_id}

RESPONSE BODY

{
    "group_id": "2a62f4bd-7a81-429c-8b93-7fe9d2fdd5b6",
    "group_name": "cool",
    "created_at": "2020-06-02T21:03:14.982Z"
}

GET api/v1/user/${user_id}/karma

Retrieves the users karma

RESPONSE BODY:

[{}, {}]

POST api/v1/karma

Adds an entry to the users Karma

REQUEST BODY:

{
  "from_user_id": "e799061c-ce77-4082-9d05-8a9dde8a96c4",
  "to_user_id": "f799061c-de77-7082-5e05-2a9ffe4a91c5",
  "group_id": "g799061c-de77-9082-6q90-4v9nnq4e91c5",
  "message": "some string here"
}

RESPONSE BODY:

{
  "from_user_id": "e799061c-ce77-4082-9d05-8a9dde8a96c4",
  "to_user_id": "f799061c-de77-7082-5e05-2a9ffe4a91c5",
  "group_id": "g799061c-de77-9082-6q90-4v9nnq4e91c5",
  "message": "some string here"
}