Coder Social home page Coder Social logo

star-wars-api's Introduction

Star Wars API integration

The tutorial assumes that the user's OS is UNIX based, if not make the appropriate changes and select the correct OS in the documentation. If running on Windows remember to enable Hyper-V and virtual environments.

Pre Requirements

sudo apt-get install python3-pip

Create docker group, you'll need to reboot after this.

sudo groupadd docker
sudo usermod -aG docker $USER

Git clone

cd ~/path/to/project/
git clone https://github.com/RenatoAAraujo/Star-Wars-API.git
cd Star-Wars-API

Deploy

First deploy

docker-compose up --build

Regular Deploy

docker-compose up

You're ready to go!

Live Deployment

The local variables are contained in the .env file, when readying to production deployment make the appropriate changes.

Make sure that the "APP_ENV" variable is set to "production".

Code Linting

The black, isort and pylint libs are installed in the development env, use the after every commit.

python3 clean_code.py

Unit Testing

The pytest lib is used forr unit testing.

python3 run_tests.py

API Doc (Swagger)

The API will be documented using flask-restx which has Swagger integration builtin. To access it, run in your browser the fallowing link:

http://localhost:5000/doc

Database

The database is versioned using flask-migrate, all database changes must be done using it.

migrations

After making the appropriates changes to the view.py, schema.py and models.py files, make a migration by running:

docker-compose exec api flask db migrate -m"your message"

If your column has a default, make sure to add the server_default parameter to the column in the migration file, like the example below (remember that it has to be a string):

from alembic import op
import sqlalchemy as sa

def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('email_verified', sa.Boolean(), nullable=True, server_default="0"))
migrations head conflict

When migrations head conflict is encountered run the command bellow, it will make a new migration file resolving the conflict.

python3 db-merge.py
updating the database

Sometimes a change or a database registry will be made that needs to be reflected in the application dump file, to make a new dump run:

python3 db-dump.py

star-wars-api's People

Contributors

renatoaaraujo 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.