Database API - food-fox/foody GitHub Wiki

For the communication between the website and the database we will use an api. The api will always and only accecpt post calls. As a return it will always give back a json container with either an error + description or the wanted data. The api will have the following functions:

  • authorize(username[string],password[string]) returns: error or a token, this token will expire after an hour and you will have to re-authorize

  • listTypes(token[string]) returns: error or a list of all types you can work with

  • description(token[string],type) returns: error or a detailed description of the type you want

  • search(token[string],type[string],field[string],value[string]) returns: error or a list of objects (empty list if none matched)

  • add(token[string],type[string],data[json]) returns: error or the newly added object`s id

  • update(token[string],type[string],data[json]) returns: error or true if the object was updated

  • delete(token[string],type[string],id[int]) return: error or true if object was successfully deleted