Giter VIP home page Giter VIP logo

digitalmarketplace-api's Introduction

digitalmarketplace-api

Build Status Coverage Status Requirements Status

API tier for Digital Marketplace.

Quickstart

Install Virtualenv

sudo easy_install virtualenv

Bootstrap the database

make bootstrap

Install dependencies, run migrations and run the app

make run-all

Full setup

Install Virtualenv

sudo easy_install virtualenv

Ensure you have Postgres running locally, and then bootstrap your development environment

make bootstrap

On Debian Jessie, the following packages are required for bootstrapping to work:

apt-get install gcc virtualenv python-dev libffi-dev libpq-dev

Activate the virtual environment

source ./venv/bin/activate

Upgrade database schema

When new database migrations are added you can bring your local database schema up to date by running upgrade.

make run-migrations

Upgrade dependencies

Install new Python dependencies with pip

make requirements-dev

Run the tests

This will run the linter, validate the migrations and run the unit tests.

make test

To test individual parts of the test stack use the test-flake8, test-migrations or test-unit targets.

Run the development server

Run the API with environment variables required for local development set. This will install requirements, run database migrations and run the app.

make run-all

To just run the application use the run-app target.

Using the API locally

By default the API runs on port 5000. Calls to the API require a valid bearer token. Tokens to be accepted can be set using the DM_AUTH_TOKENS environment variable (a colon-separated list), e.g.:

export DM_API_AUTH_TOKENS=myToken1:myToken2

If DM_API_AUTH_TOKENS is not explicitly set then the run script sets it to myToken. You should include a valid token in your request headers, e.g.:

curl -i -H "Authorization: Bearer myToken" 127.0.0.1:5000/services

Updating application dependencies

requirements.txt file is generated from the requirements-app.txt in order to pin versions of all nested dependencies. If requirements-app.txt has been changed (or we want to update the unpinned nested dependencies) requirements.txt should be regenerated with

make freeze-requirements

requirements.txt should be commited alongside requirements-app.txt changes.

Creating a new database migration

After editing models.py to add/edit/remove models for the database, you'll need to generate a new migration script. The easiest way to do this is to run python application.py db migrate --rev-id <revision_id> -m '<description'>. Our revision IDs increment by 10 each time; check the output of python application.py db show to find the current revision. Until you run the migration to update the database state, you can delete the generated revision and re-generate it as you need to.

Using FeatureFlags

To use feature flags, check out the documentation in (the README of) digitalmarketplace-utils.

Utility scripts

Getting a list of migration versions

./scripts/list_migrations.py checks that there are no branches in the DB migrations and prints a list of migration versions

Getting a list of application URLs

python application.py list_routes prints a full list of registered application URLs with supported HTTP methods

digitalmarketplace-api's People

Contributors

thedoublek avatar robyoung avatar allait avatar wynndow avatar risicle avatar idavidmcdonald avatar benvand avatar pcraig3 avatar katstevens avatar samuelhwilliams avatar quis avatar galund avatar tombye avatar crystalpea avatar murilodalri avatar lfdebrux avatar tommorris avatar danielknell avatar brenetic avatar bandesz avatar dilwoarh avatar andrewchong avatar bjshort avatar

Watchers

James Cloos 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.