Giter VIP home page Giter VIP logo

userdata_api's Introduction

api configuration (config.ini)

not used anymore

api configuration (.env)

apps can work without this file, as there are default values in .env.default (that is copied inside image) and docker-compose.yml (for build-time required vars), but I highly recommend to configure mysql :) IF YOU WILL CONFIGURE .env.default OR/AND docker-compose.yml, BE AWARE OF DEFAULT ENV VARS, SOME ARE DUPLICATED IN THERE FILES, AND SHOULD BE THE SAME (USERDATA_API_LISTEN_PORT, USERDATA_API_CREDS_DIR, PHOTOS_API_LISTEN_PORT, PHOTOS_API_CREDS_DIR) example (the default values are shown here):

DB_ADDRESS=mysql+pymysql://userdata_user:UsErdAtAPaSSW0RD@db:7770/userdata_db
MYSQL_ROOT_PASSWORD=N0pAssw0rd
MYSQL_DATABASE=userdata_db
MYSQL_USER=userdata_user
MYSQL_PASSWORD=UsErdAtAPaSSW0RD
MYSQL_PORT=7770  # same port for outside container and for inside container

USERDATA_API_LISTEN_HOST=0.0.0.0
USERDATA_API_LISTEN_PORT=7772  # same port for outside container and for inside container
USERDATA_API_CREDS_DIR=/.userdata_api/shadow/

PHOTOS_API_LISTEN_HOST=0.0.0.0
PHOTOS_API_LISTEN_PORT=7771 # same port for outside container and for inside container
PHOTOS_API_PUBLIC_URL_BASE=http://127.0.0.1
PHOTOS_API_CREDS_DIR=/.photos_api/shadow/

DEBUG=0

additional required steps

don't forget to run docker exec <container> python generate_userdata_api_key.py for userdata_api container and docker exec <container> python generate_photos_api_key.py for photos_api container, this steps are required for generating unique api keys for apis the first key is for /api/users/ requests, the seconds one is for /photos/ requests well, it isn't actually required, but you won't be able of using apis without keys

moving from first version to second

in first version, SQLAlchemy models didn't support mysql, so in second version, if you want to stay on sqlite, you will need to create table in your sqlite db:

CREATE TABLE IF NOT EXISTS alembic_version (
	version_num VARCHAR(32) PRIMARY KEY
);
INSERT INTO alembic_version (version_num) VALUES ('6313e1cb41c9');

install and launch

if you didn't read steps above, please read them and only then continue to here get the docker-compose.prod.yml in any place run docker-compose up -f docker-compose.prod.yml -d

Methods docs

All methods take api_key in query args

POST /api/users takes multipart/data as parameters

data["user_data"]: json str

{
    "first_name": str,
    (optional) "last_name": str,
    (optional) "email_address": str,
    (optional) "user_pass": {
        "number": str,
        "country": str,
        "issue_date": int,  # ordinal value
        "expiration_date": int  # ordinal value
    }
}

files["photo"]: file structure (optional)

returns {"user_id": int} or success

GET /api/users/{user_id: int} takes no specific parameters returns:

{
    "id": int,
    "first_name": str,
    (optional) "last_name": str,
    (optional) "email_address": str,
    (optional) "photo_path": str,  # relative path
    (optional) "user_pass": {
        "id": int,
        "user_id": int,
        "number": str,
        "country": str,
        "issue_date": int,  # ordinal value
        "expiration_date": int  # ordinal value
    },
    (optional) "photo": str  # url withou api_key, to access -> you need api_key
}

DELETE /api/users/{user_id: int} deletes user from db, and his pass data, and his photo returns 204

GET /photos/{filename} static files

userdata_api's People

Contributors

drforse avatar

Watchers

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