-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
121 changed files
with
840 additions
and
2,593 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
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
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
include README.md | ||
include LICENSE | ||
include common_config.py | ||
include config.py | ||
include name.py | ||
graft migrations | ||
graft alembic | ||
graft tests | ||
graft freenit/project | ||
graft freenit/static | ||
graft freenit/templates |
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 |
---|---|---|
@@ -1,18 +1 @@ | ||
# Backend Startkit | ||
Template to get my favourite SQL stack up and running | ||
|
||
|
||
 | ||
|
||
## Forking | ||
The `name.py` is special! Although it ends with .py, it is read by shell scripts and CBSD/Reggae `Makefile` (if you're using it). Because it's not regular Python file, it has some limitations. It should consist of one line: | ||
|
||
``` | ||
app_name="application" # noqa: E225 | ||
``` | ||
|
||
There must be no space around `=` in the previous example, otherwise shell scripts won't work. The `noqa` part prevents `flake8` failing the test, because it normally requires spaces around `=`. | ||
|
||
On fork, edit `name.py` and rename `application` directory acordingly. | ||
|
||
[Backend Tutorial](https://github.com/freenit-framework/backend-tutorial) | ||
# fastapi-playground |
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,89 @@ | ||
# A generic, single database configuration. | ||
|
||
[alembic] | ||
# path to migration scripts | ||
script_location = alembic | ||
|
||
# template used to generate migration files | ||
# file_template = %%(rev)s_%%(slug)s | ||
|
||
# sys.path path, will be prepended to sys.path if present. | ||
# defaults to the current working directory. | ||
prepend_sys_path = . | ||
|
||
# timezone to use when rendering the date | ||
# within the migration file as well as the filename. | ||
# string value is passed to dateutil.tz.gettz() | ||
# leave blank for localtime | ||
# timezone = | ||
|
||
# max length of characters to apply to the | ||
# "slug" field | ||
# truncate_slug_length = 40 | ||
|
||
# set to 'true' to run the environment during | ||
# the 'revision' command, regardless of autogenerate | ||
# revision_environment = false | ||
|
||
# set to 'true' to allow .pyc and .pyo files without | ||
# a source .py file to be detected as revisions in the | ||
# versions/ directory | ||
# sourceless = false | ||
|
||
# version location specification; this defaults | ||
# to alembic/versions. When using multiple version | ||
# directories, initial revisions must be specified with --version-path | ||
# version_locations = %(here)s/bar %(here)s/bat alembic/versions | ||
|
||
# the output encoding used when revision files | ||
# are written from script.py.mako | ||
# output_encoding = utf-8 | ||
|
||
sqlalchemy.url = sqlite:///db.sqlite | ||
|
||
|
||
[post_write_hooks] | ||
# post_write_hooks defines scripts or Python functions that are run | ||
# on newly generated revision scripts. See the documentation for further | ||
# detail and examples | ||
|
||
# format using "black" - use the console_scripts runner, against the "black" entrypoint | ||
# hooks = black | ||
# black.type = console_scripts | ||
# black.entrypoint = black | ||
# black.options = -l 79 REVISION_SCRIPT_FILENAME | ||
|
||
# Logging configuration | ||
[loggers] | ||
keys = root,sqlalchemy,alembic | ||
|
||
[handlers] | ||
keys = console | ||
|
||
[formatters] | ||
keys = generic | ||
|
||
[logger_root] | ||
level = WARN | ||
handlers = console | ||
qualname = | ||
|
||
[logger_sqlalchemy] | ||
level = WARN | ||
handlers = | ||
qualname = sqlalchemy.engine | ||
|
||
[logger_alembic] | ||
level = INFO | ||
handlers = | ||
qualname = alembic | ||
|
||
[handler_console] | ||
class = StreamHandler | ||
args = (sys.stderr,) | ||
level = NOTSET | ||
formatter = generic | ||
|
||
[formatter_generic] | ||
format = %(levelname)-5.5s [%(name)s] %(message)s | ||
datefmt = %H:%M:%S |
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 @@ | ||
Generic single-database configuration. |
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 @@ | ||
import os | ||
import sys | ||
|
||
import freenit.app | ||
from alembic import context | ||
from freenit.migration import run_migrations_offline, run_migrations_online | ||
|
||
|
||
sys.path.append(os.getcwd()) | ||
|
||
|
||
if context.is_offline_mode(): | ||
run_migrations_offline() | ||
else: | ||
run_migrations_online() |
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,24 @@ | ||
"""${message} | ||
|
||
Revision ID: ${up_revision} | ||
Revises: ${down_revision | comma,n} | ||
Create Date: ${create_date} | ||
|
||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
${imports if imports else ""} | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = ${repr(up_revision)} | ||
down_revision = ${repr(down_revision)} | ||
branch_labels = ${repr(branch_labels)} | ||
depends_on = ${repr(depends_on)} | ||
|
||
|
||
def upgrade(): | ||
${upgrades if upgrades else "pass"} | ||
|
||
|
||
def downgrade(): | ||
${downgrades if downgrades else "pass"} |
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,39 @@ | ||
"""initial | ||
Revision ID: 14eb8b6e464c | ||
Revises: | ||
Create Date: 2021-07-18 12:28:52.118800 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "14eb8b6e464c" | ||
down_revision = None | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"users", | ||
sa.Column("id", sa.CHAR(36), nullable=False), | ||
sa.Column("email", sa.String(length=255), nullable=False), | ||
sa.Column("hashed_password", sa.String(length=255), nullable=False), | ||
sa.Column("is_active", sa.Boolean(), nullable=False), | ||
sa.Column("is_superuser", sa.Boolean(), nullable=False), | ||
sa.Column("is_verified", sa.Boolean(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_index(op.f("ix_users_email"), "users", ["email"], unique=True) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f("ix_users_email"), table_name="users") | ||
op.drop_table("users") | ||
# ### end Alembic commands ### |
File renamed without changes.
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
--- | ||
- name: install devel packages | ||
with_items: "{{ devel_packages }}" | ||
pkgng: | ||
package: | ||
name: "{{ item.name }}" |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,18 +1,15 @@ | ||
#!/bin/sh | ||
|
||
|
||
set -e | ||
|
||
export BIN_DIR=`dirname $0` | ||
export PROJECT_ROOT="${BIN_DIR}/.." | ||
BIN_DIR=`dirname $0` | ||
PROJECT_DIR="${BIN_DIR}" | ||
. ${BIN_DIR}/common.sh | ||
setup | ||
|
||
|
||
if [ "${OFFLINE}" != "yes" ]; then | ||
pip install -U --upgrade-strategy eager -e '.[dev]' | ||
fi | ||
setup no | ||
pip install -U pip | ||
pip install -U wheel | ||
pip install -U --upgrade-strategy eager -e ".[build]" | ||
|
||
|
||
cd ${PROJECT_ROOT} | ||
rm -rf *.egg-info build dist | ||
python setup.py sdist bdist_wheel |
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
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 |
---|---|---|
@@ -1,23 +1,19 @@ | ||
#!/bin/sh | ||
|
||
|
||
BIN_DIR=`dirname $0` | ||
export FLASK_PORT=${FLASK_PORT:=5000} | ||
export FLASK_ENV="development" | ||
export FREENIT_ENV="dev" | ||
export OFFLINE=${OFFLINE:="no"} | ||
export SYSPKG="no" | ||
|
||
|
||
. ${BIN_DIR}/common.sh | ||
setup no | ||
|
||
if [ "${SYSPKG}" = "no" ]; then | ||
if [ "${OFFLINE}" != "yes" ]; then | ||
pip install -U --upgrade-strategy eager -e '.[dev]' | ||
fi | ||
if [ ! -e "alembic/versions" ]; then | ||
mkdir alembic/versions | ||
alembic revision --autogenerate -m initial | ||
alembic upgrade head | ||
fi | ||
|
||
|
||
echo "Backend" | ||
echo "===============" | ||
uwsgi --master --http 0.0.0.0:${FLASK_PORT} ${WEBSOCKET_FLAGS} --python-auto-reload 1 --honour-stdin --wsgi-file devel.py | ||
uvicorn main:app --host 0.0.0.0 --port 5000 --reload |
Oops, something went wrong.