Designed for rapid development of serverless APIs.
- Docker
- Python 3.7
- serverless-cli
- An AWS profile with valid credentials on your local machine
-
Get setup:
make init
-
Run local API (binds to localhost:5000):
make start
-
Reset local database (completely):
make reset
-
Dump local database (data not structure):
make flush
-
Dump production database (data not structure):
make flush-live
-
Generate new migrations after changing a model:
make migrations
-
Running migrations locally:
make migrate
-
Running migrations in production:
make migrate-live
-
Deploy to lambda in dev:
make deploy-dev
-
Deploy to lambda in prod:
make deploy-prod
- Create a new folder in
functions
with the name of your endpoint. - Add the new endpoint and HTTP method to
serverless.yaml
. - Update
./sls_django/settings.py
with the name of your new endpoint. - Write your business logic to a file in the
./logic
directory. - If creating a new model, duplicate one of the existing folders in
sls_django
, and rename with the name of your Entity. - Add Models or Serializers accordingly.
- If you made changes to a model, run
make migrations
followed bymake migrate
. Then, you're ready to run your endpoint locally. Restart your local server, runningmake start
. - Enjoy your endpoint, and proceed to develop subsequent APIs faster than ever.
Run python -m functions.functionName.handler
Write your tests in the ./tests
folder. Then:
- Create a virtual environment in
./tests
:virtualenv -p python3 venv
- Source it:
source venv/bin/activate
- Install requirements:
pip install -U requirements.txt
Finally, to run tests: python -m pytest tests
from the root directory.