Features
- SQL + SqlAlchemy
- Supports both HTTP / 2.0 and HTTP / 1.0
- Upload to Local S3 Storage
- Auto Generation of client libraries
- CRUD classes should only communicate with the database, do not add any FastAPI elements therein.
- Tes your services and crud implementations by writing test cases for them, not via routers.
- python3.9
- Docker
- makefile
- Please install makefile if you are not using Linux.
- MinIO: High Performance Object Storage (already dockerized)
- Better Comments Visual Studio Plugin
- Black Python Formatter
Open the makefile and understand the file before running the makefile commands.
# Run this first, Create Network for the containers
make create-network
# Build or rebuild the API image
make build-local
# Run at the root of the project
make run
# Follow docker compose logs
make follow-logs
# Kill the API
make kill-local
# Run local alembic migrations
make run-local-migrations
# Run all the tests in the project
make run-tests
# Run all the tests in the users module
make run-test-users
Ensure you have these saved in the environment variables
USE_SSL
= TrueUSE_TCP
= TrueTCP_PORT
should be the port to listen on (e.g. 80 or 8100)SSL_PORT
should be the port to listen on (e.g. 443 or 8101)MAX_WORKERS
to the number of workers the system has.
For local development
- HTTP 2.0 is serve on
https://localhost:8101/docs
- HTTP 1.1 is serve on
http://localhost:8100/docs
- The
hypercorn/cert.pem
andhypercorn/key.pem
can be generated with this commandopenssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
For Production
- Save the file path of the mounted
key.pem
to environment variableKEYFILE
- Save the file path of the mounted
cert.pem
to environment variableCERTFILE
Ensure you have .env in the root folder of the project. See the .env.copy for the expected variables needed.
# This will run all head() of all revisions
alembic upgrade head
# This will create a revision file
alembic revision -m "create account table"
Alembic can help you automatically generate your alembic version files rather than writing them out.
When you make changes to or add a new SqlAlchmey model, indicate the name of the file of the model in the env.py
file in almebic
folders,
as the target_metadata as shown below
target_metadata = [User.metadata]
After that run the alembic auto generation command below:
alembic revision --autogenerate -m "updated users and user_roles table"
# Then run upgrade head
alembic upgrade head
- Clone the repository into your project.
- Run this line in the library's folder:
npm install && npx parcel build
- Include in your project's package.json like this
"@dbulletin/dbulletin-api-ts-client": "file:./dbulletin-api-ts-client",
- Run
npm install
in the root of your project.
Initialized the package
npm init
Install Parcel
npm install --save-dev parcel
Add the following to the package.json
{
"name": "@dbulletin/dbulletin-api-ts-client",
"version": "1.0.0",
"description": "",
"source": "index.ts",
"main": "dist/main.js",
"module": "dist/module.js",
"types": "dist/types.d.ts"
}
Install axios
npm i axios
Build the files. Building will be required from time to time when the package is updated.
npx parcel build