From baf6456356a28b98a383bc1d6dfc4a96dad09498 Mon Sep 17 00:00:00 2001 From: israelias Date: Sun, 29 Aug 2021 00:48:01 +0800 Subject: [PATCH 1/3] Remove heroku deploy files from root --- Procfile | 1 - requirements.txt | 50 ------------------------------------------------ 2 files changed, 51 deletions(-) delete mode 100644 Procfile delete mode 100644 requirements.txt diff --git a/Procfile b/Procfile deleted file mode 100644 index fe41074..0000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: gunicorn backend.app:app \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9f7bea9..0000000 --- a/requirements.txt +++ /dev/null @@ -1,50 +0,0 @@ -aniso8601==7.0.0 -appdirs==1.4.4 -astroid==2.5.6 -bcrypt==3.2.0 -black==20.8b1 -blinker==1.4 -cffi==1.14.5 -click==7.1.2 -dnspython==2.1.0 -email-validator==1.1.3 -Flask==1.1.2 -Flask-Admin==1.5.8 -Flask-BasicAuth==0.2.0 -Flask-Bcrypt==0.7.1 -Flask-Cors==3.0.10 -Flask-JWT-Extended==4.1.0 -Flask-Mail==0.9.1 -flask-mongoengine==1.0.0 -Flask-RESTful==0.3.8 -Flask-WTF==0.14.3 -idna==3.1 -install==1.3.4 -iso8601==0.1.14 -isort==5.8.0 -itsdangerous==1.1.0 -Jinja2==2.11.3 -lazy-object-proxy==1.6.0 -MarkupSafe==1.1.1 -mccabe==0.6.1 -mongoengine==0.23.0 -mypy-extensions==0.4.3 -pathspec==0.8.1 -promise==2.3 -pycparser==2.20 -PyJWT==2.0.1 -pylint==2.8.3 -pymongo==3.11.3 -pytz==2021.1 -regex==2021.4.4 -Rx==1.6.1 -sentinels==1.0.0 -singledispatch==3.6.1 -six==1.15.0 -toml==0.10.2 -typed-ast==1.4.2 -typing-extensions==3.7.4.3 -Werkzeug==1.0.1 -wrapt==1.12.1 -WTForms==2.3.3 -gunicorn \ No newline at end of file From 952c0bffb37350e38f453c667ccc30c8c35ace66 Mon Sep 17 00:00:00 2001 From: israelias Date: Sun, 29 Aug 2021 22:34:34 +0800 Subject: [PATCH 2/3] Add basic auth env vars to documentation --- backend/README.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/backend/README.md b/backend/README.md index 83207bd..8893361 100644 --- a/backend/README.md +++ b/backend/README.md @@ -4,6 +4,8 @@ The restful API is deployed at [cheathub-backend.herokuapp.com/](https://cheathub-backend.herokuapp.com/) +> *Note:* Open API spec is forthcoming. Please see `database/models.py` to preview the snippet, collection and user document models. + ## Heroku Deployment ```bash #create new git repository and add everything @@ -47,9 +49,9 @@ In this half of the monorepo, you can run: Serves the Databse backend.\ Runs the backend app in the development mode.\ -Open [http://localhost:5000/admin](http://localhost:5000/admin) to view the admin panel in the browser. +Open [http://localhost:5000/admin](http://localhost:5000/admin) to view the admin panel in the browser (ensure `BASIC_AUTH` variables are set). -Open [http://localhost:5000/api/snippets](http://localhost:5000/api/snippets) to view the JSON response format of all public snippets. +Open [http://localhost:5000/api/snippets](http://localhost:5000/api/snippets) to view the JSON response format of all public snippets -- assuming `snippet` objects have been created. Otherwise, use Postman to create documents locally (API spec is forthcoming!). The page will reload if you make edits.\ You will also see any errors in the console. @@ -103,6 +105,33 @@ Set the variable to this key: # env.py os.environ.setdefault("JWT_SECRET_KEY", "") ``` +### `BASIC_AUTH_USERNAME` + +Superuser username to access admin panel at `/admin` + +Set the variable to this key: +```python +# env.py +os.environ.setdefault("BASIC_AUTH_USERNAME", "") +``` + +### `BASIC_AUTH_PASSWORD` + +Superuser password to access admin panel at `/admin` + +Set the variable to this key: +```python +# env.py +os.environ.setdefault("BASIC_AUTH_USERNAME", "") +``` +### Flask Mail Option +> See [Flask Mail](https://pythonhosted.org/Flask-Mail/) +Similarly, apply the same logic to: +- `MAIL_SERVER` +- `MAIL_PORT` +- `MAIL_USERNAME` +- `MAIL_PASSWORD` +- `MAIL_DEFAULT_SENDER` ## Database Server @@ -139,6 +168,7 @@ You can add documents via Postman or Mongo Compass. - [Flask Admin](https://flask-admin.readthedocs.io/en/latest/) - [Flask Session](https://flask-session.readthedocs.io/en/latest/) - [Flask Restful](https://flask-restful.readthedocs.io/en/latest/) +- [Flask Mail](https://pythonhosted.org/Flask-Mail/) ## Resources - [Heroku Deployment](https://stackoverflow.com/questions/7539382/how-can-i-deploy-push-only-a-subdirectory-of-my-git-repo-to-heroku) From f176aa8c23e88593a6460ce025ba7996905c8374 Mon Sep 17 00:00:00 2001 From: israelias Date: Sun, 29 Aug 2021 22:35:29 +0800 Subject: [PATCH 3/3] Add node_modules to exclusions in case local package runs yarn --- backend/.gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/.gitignore b/backend/.gitignore index f749f52..322acd2 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1,2 +1,3 @@ .DS_Store -__pycache__ \ No newline at end of file +__pycache__ +node_modules/ \ No newline at end of file