Giter VIP home page Giter VIP logo

cp2a-bucketlist-application's Introduction

Build Status Coverage Status Code Issues Codacy Badge Packagist state badge pep 8

BucketList API โœ

Create an API for an online Bucket List service using Flask.

Bucket list can also be refered to as things/something to do before you die. It is possibly derived from the English idiom to kick the bucket. It is used as an informal way or as a slang and it is believed that the idiom comes from method of execution such as hanging. The origin of the word remains unclear. Read more here. ๐Ÿค”

  • API

This App exposes endpoints that allows clients/Users to manage a bucketlist of their choise.

  • Available Resource Endpoints

Method Endpoint Usage
POST /api/v1.0/register Register a user.
POST /api/v1.0/login Login user.
POST /api/v1.0/bucketlists/ Create a new bucket list.
GET /api/v1.0/bucketlists/ Get all the created bucket lists.
GET /api/v1.0/bucketlists/<bucket_id> Get a single bucket list.
PUT /api/v1.0/bucketlists/<bucket_id> Update a single bucket list.
DELETE /api/v1.0/bucketlists/<bucket_id> Delete single bucket list.
POST /api/v1.0/bucketlists/<bucket_id>/items Add a new item to this bucket list.
GET /api/v1.0/bucketlists/<bucket_id>/items/<item_id> Get an item from this bucket list.
PUT /api/v1.0/bucketlists/<bucket_id>/items/<item_id> Update an item in this bucket list.
PATCH /api/v1.0/bucketlists/<bucket_id>/items/<item_id> Patch an item in this bucket list.
DELETE /api/v1.0/bucketlists/<bucket_id>/items/<item_id> Delete this single bucket list.
GET /api/v1.0/bucketlists?limit=10&page=1 Pagination to get 10 bucket list records.
GET /api/v1.0/bucketlists?q=travelling bucket Search for bucket lists with name like travelling bucket.

Getting Started ๐Ÿ•ต

  • To run on local machine git clone this project :
 $ git clone https://github.com/georgreen/CP2A-BucketList-Application.git

Copy and paste the above command in your terminal, the project will be downloaded to your local machine.

  • To consume API in client of choice navigate to:
https://cp2-bucketlist-prd.herokuapp.com/api/

post man

This link will open up a running version of the project on heroku, a detailed documentation is provided on the site.

Prerequisites

The application is built using python: flask framework.

Flask is a microframework for the Python programming language.

To Install python checkout:

https://www.python.org/

Installing

For this section I will assume you have python3 and it's configured on your machine.
Navigate to the folder you cloned and run:

  • Install Requirements
$ pip install -r requirements.txt
  • Configure Environment.
$ export APP_SETTINGS="default"
$ export DEV_DATABASE="path to your database"
$ export SECRET="Secret Key Here"

Note replace the value for DEV_DATABASE with real database path and SECRET with a strong string value

  • Configure database
$ python manage.py database init
$ python manage.py database migrate
$ python manage.py database upgrade
  • Run App ๐Ÿƒ๐Ÿƒโ€
$ python manage.py runserver

The app should be accessiable via : http://127.0.0.1:5000/

Session Examples

To Follow along with this examples get postman : A powerful GUI platform to make your API requests. READ MORE HERE

  • Set up postman post man

  • Signup/ register post man

    • Post data in the format below to the register endpoint: /api/v1.0/register
    {
        "username":"geogreen ngunga",
        "email":"[email protected]",
        "password":"demoPassword12#"
    }
    
  • Login post man

    • Post data in the format below to the login endpoint : /api/v1.0/login
    {
        "email":"[email protected]",
        "password":"demoPassword12#"
    }
    
  • Copy the token returned and add it into the headers as a key pair value of Authorization : Bearer [put token here]

    post man

  • Create BucketList post man

    • Post data in the format below to the bucketlist endpoint: /api/v1.0/bucketlists/
    {
        "name":"new bucketlist name"
    }
    
  • Get BucketList post man

    • Get data from the bucketlist endpoint: /api/v1.0/bucketlists/
  • Get one BucketList post man

    • Get data from the bucketlist endpoint: /api/v1.0/bucketlists/bucket_id
  • Update BucketList post man

    • Put data to the endpoint :/api/v1.0/bucketlists/bucket_id
    {
        "name":"new name"
    }
    
  • Delete BucketList post man

    • Delete data at an endpoint:/api/v1.0/bucketlists/bucket_id
  • Add Item to BucketList post man

    • Post data to /api/v1.0/bucketlists/<bucket_id>/items in the format:
    {
        "name":"Item name",
        "description":"Item description"
    }
    
  • Get Item from BucketList post man

    • Get data from the endpoint:/api/v1.0/bucketlists/<bucket_id>/items/<item_id>
  • Update Item from BucketList post man

    • Put data to /api/v1.0/bucketlists/<bucket_id>/items/<item_id> in the format:
    {
        "name":"This will update name",
        "description":"This will update description"
    }
    
  • Patch Item from BucketList post man

    • Patch item endpoint /api/v1.0/bucketlists/<bucket_id>/items/<item_id> data format:
    {
        "done":"True"
    }
    
  • Delete Item from BucketLists post man

    • Delete item at the endpoint /api/v1.0/bucketlists/<bucket_id>/items/<item_id>
  • Search for BucketLists post man

    • Get bucketlist by searching /api/v1.0/bucketlists/<bucket_id>/?q=search
      Search can be any sub string to be queried from the resource
  • Paginate BucketLists post man

    • Get paginated buckets /api/v1.0/bucketlists/<bucket_id>/?limit=2&page=1
      This will get two bucketlists per page, limit can be set to any number of bucketlist required per page; page is the required page 1st, 2nd , 3rd ....etc

Running the tests

$ python manage.py test
  • With Coverage
 $ nosetests --rednose --with-coverage --cover-package=app -v
  • Coding style tests

Pep8 standards are followed in project.

$ pep8 app --count

Deployment ๐Ÿš€

Built With ๐Ÿ— ๐Ÿ”จโš’

  • Flask - The web framework used
  • Flaskrestplus - Extension for Flask that adds support for quickly building REST APIs.
  • webargs - webargs is a Python library for parsing HTTP request arguments
  • Flask JWT Extended - Extension for Flask that adds support for tokken authentication

Contributing ๐Ÿ‘

  • Please Fork me! :-)

Versioning โš™

Authors ๐Ÿ“š

  • Georgreen Mamboleo - Initial work - Dojo

License ๐Ÿค

  • This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments ๐Ÿ‘Š ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿ™

cp2a-bucketlist-application's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

hun3 larrykarani

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.