Giter Site home page Giter Site logo

zearkiatos / codesquad-blacklist-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 58 KB

This is an python ๐Ÿ with flask ๐ŸŒถ๏ธ api to management the blacklist for a company

Dockerfile 8.37% Python 81.70% Shell 5.38% Makefile 3.11% JavaScript 1.44%

codesquad-blacklist-api's Introduction

Description

This is an python ๐Ÿ with flask ๐ŸŒถ๏ธ api to management the blacklist for a company

Made with

Python Flask

Postman documentation ๐Ÿง‘๐Ÿปโ€๐Ÿš€๐Ÿš€

You can check the postman documentation make a clic in the next

POSTMAN

URL: https://documenter.getpostman.com/view/1347256/2sA3Bj7Z4w

Prerequirements

  • Python ๐Ÿ
  • Docker & docker-compose ๐Ÿณ (Optional).
  • For Linux ๐Ÿง and mac ๐ŸŽ you can use makefile.
  • For Windows ๐ŸชŸ you can use bash function.

How to execute

If you want execute without docker then you must execute the next commands in your terminal. Note: firstable is important that you have your python virtual environmente created.

  1. Firstly, you should have the .env please follow the file .env.example you should have something like this
FLASK_APP=flaskr/app
FLASK_ENV=development
APP_NAME=codesquad-blacklist-api
SECRET_KEY=[SECRET_KEY]
JWT_SECRET_KEY=[SECRET_KEY]
DATA_BASE_URI=[DATA_BASE_URL]

The .env.dev for your local environment

FLASK_APP=flaskr/app
FLASK_ENV=development
APP_NAME=codesquad-blacklist-api
SECRET_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbnZpcm9ubWVudCI6ImRldmVsb3BtZW50IiwiYXBwbGljYXRpb24iOiJjb2Rlc3F1YWQtYmxhY2tsaXN0LWFwaSJ9.yJu4GXzVheB7U4VNFAEc2iElgUYf3UtQErhHDDK2vgo
JWT_SECRET_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbnZpcm9ubWVudCI6ImRldmVsb3BtZW50IiwiYXBwbGljYXRpb24iOiJjb2Rlc3F1YWQtYmxhY2tsaXN0LWFwaSJ9.yJu4GXzVheB7U4VNFAEc2iElgUYf3UtQErhHDDK2vgo
DATA_BASE_URI=postgresql://postgres:postgres@db:5432/blacklist

The .env.db for your local db environment

POSTGRES_DB=blacklist
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_PORT=5432
PGPORT=5432
  1. First step you should activate the python environment
# With Linux ๐Ÿง or Mac ๐ŸŽ
make activate

# With Windows ๐ŸชŸ
source run.sh; activate

# With python flask ๐Ÿ ๐ŸŒถ๏ธ
python3 -m venv venv
source venv/bin/activate
  1. Second step you should install all the dependencies and python ๐Ÿ packages ๐Ÿ“ฆ
# With Linux ๐Ÿง or Mac ๐ŸŽ
make install

# With Windows ๐ŸชŸ
source run.sh; install

# With python flask ๐Ÿ ๐ŸŒถ๏ธ
pip install -r requirements.txt
  1. Finally, into directory flaskr execute
# With Linux ๐Ÿง or Mac ๐ŸŽ you can send a specific port with port=5000 param
make run
#or
make run port=5000

# With Windows ๐ŸชŸ you can send a specific port with 5000 param
source run.sh; run
# or
source run.sh; run 5000

# With python flask ๐Ÿ ๐ŸŒถ๏ธ
flask run

How to execute with docker ๐Ÿณ

  1. Step one locate in the root of the project
cd codsquad-backlist-api
  1. Run in docker ๐Ÿณ
# With Linux ๐Ÿง or Mac ๐ŸŽ
make docker-dev-up

# Command to run with nginx  and proxy reverse 
make docker-up

# With Windows ๐ŸชŸ
source run.sh; docker_dev_up

# Command to run with nginx  and proxy reverse 
source run.sh; docker_up

# With docker compose for all Operative Systems

docker compose -f=docker-compose.develop.yml up --build

# Command to run with nginx  and proxy reverse

docker compose up --build
  1. Make sure that all microservices are running
  • Executing this command
    docker ps

Validate API health

You can call the health check, for example:

$ curl -X GET --location 'http://localhost:5000/health'

You must receive a request like next:

{
    "environment": "development",
    "application": "codesquad-blacklist-api",
    "status": 200
}

Postman important configuration

  1. You should have the collection inside a postman folder

  2. You should have the postman collection and environment imported in your postman application

  3. For endpoint POST blacklist, you should have configured the next pre request script

Important

You could find this in the postman folder as pre-script.js

const uuid = require('uuid');
const generatedUUID = uuid.v4();

const jsonData = JSON.parse(pm.request.body);
const email = jsonData.email;

pm.environment.set("CODESQUAD_BLACKLIST_UUID", generatedUUID);
pm.environment.set("CODESQUAD_BLACKLIST_EMAIL", email);

codesquad-blacklist-api's People

Contributors

zearkiatos avatar fabiocastagnola avatar mvegaruniandes avatar

Watchers

 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.