/fastapi-rest-api

basic template of REST API developped with FastAPI

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

REST API build with FastAPI

Small project to develop REST API using FastAPI.

Development

Generate secret key (random)

$ openssl rand -hex 32

Use fastapi_healthcheck module to implement /health path.

Docker Compose (dev and testing only)

Stack:

  • FastAPI app
  • Postgres server
  • Mongodb server
  • Traefik proxy

Access Swagger UI of FastAPI app: http://fastapi.localhost:8000/docs

Access Traefik dashboard: http://fastapi.localhost:8081/dashboard/#/

For further details refer to: this blog.

Setup Mongodb (WIP)

Create User:

# inside mongodb container 
$ docker compose exec mongodb /bin/sh

root@d6c8bd94bb9c:/#  mongosh -u admin -p admin --authenticationDatabase admin
test> db.createUser({user: 'restapp', pwd: 'restapppassword', roles: [{role: 'readWrite', db: 'docdb', }, ],});
test > use docdb
docdb>