Skip to content

The inspirational quotes for the Kontr 2.0 developed in Go.

License

Notifications You must be signed in to change notification settings

pestanko/kinispiration

Repository files navigation

KInspiration

The inspirational quotes for the Kontr developed in Go.

Maintainability

Installation

Here are the installation instactions how to install and build from scratch

$ go get github.com/pestanko/kinspiration

Running

Here are the instructions how to run the project

Configuration

Environment variables that can be configured

QUOTES_TOKEN=<admin_token>
QUOTES_FILE=<path_to_file>
QUOTES_HOST=<host:port>
  • QUOTES_TOKEN - If it is set, the POST and DELETE methods are secured and the Authorization header is required. Authorization header should be in the format: Authorization: Bearer <QUOTES_TOKEN>

  • QUOTES_FILE - Location where the file with quotes are stored. If not provided, the "default path" is used. Default path is the quotes.json

  • QUOTES_HOST - Sets host and port for the router, default is the :3000

Run the server

Run the server using the command

$ kinspiration

Example DB

There is a directory - examples that contains quotes.json that you can be used.

File format

Example format:

[
  {
    "id": "b4a1936e-37af-4860-8c49-f39ab1e6c907",
    "quote": "Life isn’t about getting and having, it’s about giving and being.",
    "author": "Kevin Kruse"
  },
  {
    "id": "acca7060-1f1d-4d0f-b9e3-40783255d4b6",
    "quote": "Whatever the mind of man can conceive and believe, it can achieve.",
    "author": "Napoleon Hill"
  },
  ...
]

Where:

  • id is autogenerated UUID4 id
  • quote is the quote itself
  • author is the author of the quote

API

Here are described the endpoints

Endpoints

Format is the [HTTP_METHOD] /path - Description

  • [GET] /quotes - List of all quotes (No Authorization required)
  • [GET] /quote/{id} - Get one quote by it's id (No Authorization required)
  • [GET] /random - Get one random quote (No Authorization required)
  • [POST] /quotes - Create a quote (Authorization required), required params are quote and author
  • [DELETE] /quote/{id} - Delete quote by id

Add the quote format

To add new quote you need to send a JSON to the /quotes endpoint using the POST method

Request body:

{
    "quote": "I'd like a dinner reservation for twelve.",
    "author": "John Wick"
}

Releases

No releases published

Packages

No packages published