-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from thiagojacinto/support/initial-structure
Support - initial structure
- Loading branch information
Showing
16 changed files
with
400 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Description | ||
|
||
Brief description to explain the porpuse of this Pull Request. | ||
|
||
## Fixes | ||
|
||
- [x] Any issues to link here? Remember [GitHub way](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls) to auto linked references. | ||
|
||
## Checklist | ||
|
||
- [ ] Tests included | ||
- [ ] Tests passing | ||
- [ ] Dependencies updated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/python | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=python | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
FROM python:3.10 | ||
|
||
# | ||
WORKDIR /app | ||
|
||
# | ||
COPY ./prod-requirements.txt /app/requirements.txt | ||
|
||
# | ||
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt | ||
|
||
# | ||
COPY ./testglossary /app/testglossary | ||
|
||
# | ||
CMD ["uvicorn", "testglossary.main:app", "--host", "0.0.0.0", "--port", "80"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# docker hub user | ||
DOCKER_HUB_USERNAME=thiagojacinto | ||
DOCKER_HUB_REPOSITORY=test-glossary-api | ||
|
||
# shell colors | ||
COLOUR_GREEN=\033[0;32m | ||
COLOUR_RED=\033[0;31m | ||
COLOUR_BLUE=\033[0;34m | ||
COLOUR_END=\033[0m | ||
|
||
# setting source code directory | ||
APP_SOURCE_CODE_DIR='./testglossary' | ||
|
||
install: # install project dependencies from requirements.txt file | ||
@echo "$(COLOUR_RED)Start installing process ...$(COLOUR_END)" | ||
pip install -r ./requirements.txt | ||
|
||
test: # execute all tests | ||
@echo "$(COLOUR_GREEN)Executing tests ...$(COLOUR_END)" | ||
python -m pytest | ||
|
||
lint: # use linter | ||
@echo "$(COLOUR_GREEN)Running lint process ...$(COLOUR_END)" | ||
python -m black $(APP_SOURCE_CODE_DIR) ; \ | ||
python -m isort --profile black $(APP_SOURCE_CODE_DIR) ; \ | ||
python -m autopep8 --in-place --recursive --verbose $(APP_SOURCE_CODE_DIR) | ||
|
||
help: # list all Makefile commands | ||
@echo "$(COLOUR_BLUE)These are all the avalaible commands ...$(COLOUR_END)" | ||
grep ':' Makefile | ||
|
||
docker-build: GET_NOW := $(shell date +%s) | ||
docker-build: # builds a new container image | ||
@echo "$(COLOUR_RED)Building a Docker image ...$(COLOUR_END)" | ||
TAG_NAME="$(DOCKER_HUB_USERNAME)/$(DOCKER_HUB_REPOSITORY):$(GET_NOW)" ; \ | ||
docker build -t $${TAG_NAME} . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Welcome to TestGlossary projects | ||
|
||
This project uses mkdocs. For full documentation how-to visit [mkdocs.org](https://www.mkdocs.org). | ||
|
||
## Commands | ||
|
||
* `make install` - install project dependencies from requirements.txt file | ||
* `make test` - execute all tests | ||
* `make lint` - use linter | ||
* `make help` - lists all Makefile commands | ||
|
||
## Project layout | ||
|
||
Makefile # Makefile with simplifications for project maintenance | ||
mkdocs.yml # MkDocs configuration file. | ||
docs/ | ||
index.md # The documentation homepage. | ||
... # Other markdown pages, images and other documentation related files. | ||
tests/ | ||
... # Test related files should be here | ||
testglossary/ | ||
... # Main application files must be placed under this directory, following futher structure. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
site_name: TestGlossary | ||
theme: readthedocs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
anyio==3.5.0 | ||
asgiref==3.5.0 | ||
|
||
fastapi==0.75.0 | ||
|
||
h11==0.13.0 | ||
httptools==0.3.0 | ||
idna==3.3 | ||
|
||
pydantic==1.9.0 | ||
|
||
python-dotenv==0.19.2 | ||
|
||
sniffio==1.2.0 | ||
starlette==0.17.1 | ||
|
||
typing_extensions==4.1.1 | ||
uvicorn==0.17.5 | ||
uvloop==0.16.0 | ||
|
||
watchgod==0.7 | ||
websockets==10.2 | ||
zipp==3.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
anyio==3.5.0 | ||
asgiref==3.5.0 | ||
attrs==21.4.0 | ||
autopep8==1.6.0 | ||
black==22.1.0 | ||
click==8.0.4 | ||
fastapi==0.75.0 | ||
ghp-import==2.0.2 | ||
h11==0.13.0 | ||
httptools==0.3.0 | ||
idna==3.3 | ||
importlib-metadata==4.11.2 | ||
iniconfig==1.1.1 | ||
isort==5.10.1 | ||
Jinja2==3.0.3 | ||
Markdown==3.3.6 | ||
MarkupSafe==2.1.0 | ||
mergedeep==1.3.4 | ||
mkdocs==1.2.3 | ||
mypy-extensions==0.4.3 | ||
packaging==21.3 | ||
pathspec==0.9.0 | ||
platformdirs==2.5.1 | ||
pluggy==1.0.0 | ||
py==1.11.0 | ||
pycodestyle==2.8.0 | ||
pydantic==1.9.0 | ||
pyparsing==3.0.7 | ||
pytest==7.0.1 | ||
python-dateutil==2.8.2 | ||
python-dotenv==0.19.2 | ||
PyYAML==6.0 | ||
pyyaml_env_tag==0.1 | ||
six==1.16.0 | ||
sniffio==1.2.0 | ||
starlette==0.17.1 | ||
toml==0.10.2 | ||
tomli==2.0.1 | ||
typing_extensions==4.1.1 | ||
uvicorn==0.17.5 | ||
uvloop==0.16.0 | ||
watchdog==2.1.6 | ||
watchgod==0.7 | ||
websockets==10.2 | ||
zipp==3.7.0 |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from enum import Enum | ||
|
||
|
||
class API_versions(Enum): | ||
""" | ||
API verions enum | ||
""" | ||
|
||
v1 = "v1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from fastapi import APIRouter, status | ||
|
||
router = APIRouter( | ||
prefix="/healthcheck", | ||
tags=["logs"], | ||
responses={500: {"description": "Internal server error"}}, | ||
) | ||
|
||
|
||
@router.get(path="/", status_code=status.HTTP_200_OK) | ||
async def retrieve_check(): | ||
""" | ||
returns an OK if server is up | ||
""" | ||
return {"status": "OK"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from sys import prefix | ||
|
||
from fastapi import APIRouter, FastAPI, status | ||
from fastapi.responses import RedirectResponse | ||
|
||
from .internal import health_check | ||
from .internal.api_versions import API_versions | ||
from .routers import terms | ||
|
||
app = FastAPI( | ||
title="TestGlossary API", | ||
description="API service that retrieve information about test concepts as a glossary.", | ||
contact={ | ||
"name": "Thiago Jacinto", | ||
"url": "https://www.linkedin.com/in/thiago-jacinto/", | ||
}, | ||
docs_url="/api/docs", | ||
redoc_url="/api/redocs", | ||
) | ||
active_API_version = API_versions.v1.value | ||
active_API_version_router = APIRouter(prefix="/{}".format(active_API_version)) | ||
|
||
active_API_version_router.include_router(terms.router) | ||
active_API_version_router.include_router(health_check.router) | ||
|
||
app.include_router(active_API_version_router, prefix="/api") | ||
|
||
|
||
@app.get(path="/") | ||
async def redirect_root_to(): | ||
path_redirect = "/api/{}/healthcheck".format(active_API_version) | ||
return RedirectResponse( | ||
url=path_redirect, status_code=status.HTTP_308_PERMANENT_REDIRECT | ||
) |
Empty file.
Oops, something went wrong.