Code Monkey home page Code Monkey logo

kinispiration's Introduction

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"
}

kinispiration's People

Contributors

pestanko avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.