Skip to main content

Create fastapi in a warp speed

Project description

Warp FastApi Documentation

Introduction

Warp-FastApi is a versatile Python library that serves as your navigational beacon through the intricate cosmos of FastAPI development. The library's core feature is the generation of well-structured, efficient code tailored to FastAPI, SQLAlchemy, and Pydantic. This means you can focus on crafting your application's unique logic, secure in the knowledge that the foundational code is expertly generated. Begin your FastAPI project with Warp-FastApi, where exploration and efficiency converge.

Installation

Begin your journey by installing Warp-FastApi using pip:

pip install warp-fastapi

Getting Started

Prepare for liftoff into the Warp-FastApi universe by following these simple steps:

Beam Up Your Crew:

Assemble the core components of Warp-FastApi.

from warp_fastapi import AppObject, AppProject, ProjectCreator
from warp_fastapi.attributes import StringAttribute, IntAttribute, NameAttribute
from warp_fastapi.app_object import BasicUser

Warp-Define Attributes:

# Engage attributes
a1 = StringAttribute("planet_name")
a2 = IntAttribute("distance")
ship_name = StringAttribute("ship_name")

Define attributes with the precision of a star cartographer – each attribute corresponds to a specific celestial aspect. For more attribute types, refer to the SQL Types and Types documentation.

Launch Your App Spaceships:

# Launch app spaceships
planet = AppObject("planet", a1, a2)
starship = AppObject("starship", ship_name)

Initiate AppObjects, the very vessels of your application – give them designations, program their functional cores (attributes), and propel them into the coding cosmos!

You can also establish an AppObject with attributes directly:

alien = AppObject(
    "alien",
    NameAttribute(),
    StringAttribute("species"),
    StringAttribute("status", optional=True),
)
gadget = AppObject("gadget", 
                   StringAttribute("name"))

And don't forget to pack the optional "status" attribute for those unpredictable extraterrestrial encounters.

Navigate the Star Systems – Add Starship Relations:

planet.add_one_to_many_rel(starship, "inhabited_by", "planet")
starship.add_one_to_many_rel(alien, "crew", "starship")

Much like celestial systems gravitate towards one another, your app objects require meaningful connections. Forge these connections by signaling the objects, inputting coordinates, and assigning distinctive identifiers.

The function to add realtionship follows this structure:

main_obj.add_<side_of_main_obj>_to_<side_of_related_object>_rel(
    related_object, name_of_rel_in_main_obj, name_of_rel_in_related_object)

Potential relationship types encompass:

  • one_to_one: A one-to-one relationship, present in both the main and related objects.
  • one_to_many: A one-to-many relationship, with the main object as one and the related object as many. This configures the main object to hold a list of related objects. The foreign key is situated in the related object (typically the "many" side).
  • many_to_one: The reverse of one_to_many, resulting in the main object as many and the related object as one. The related object is equipped with a list of main objects.
  • many_to_many: A mutual relationship where both objects feature lists of the other. This intricate linkage is managed through an association table in SQLAlchemy.

Secure your mission:

mission = AppObject("mission", NameAttribute(), StringAttribute("desc"), secure=True)
user = BasicUser()

With secure=True we assign that this resource can only be accessed with authorized user. BasicUser ensures that we have simple user for authorization (user with username and password).

Commence Warp Drive:

# Set coordinates – AppObjects ready for warp
project = AppProject(
    "galactic_app", planet, starship, alien, gadget, mission, auth_object=user
)

# Engage the ProjectCreator, the command bridge of coding
creator = ProjectCreator(project, project_dir=".")
creator.create_project()

Explore New Discovery:

In your shell go to the folder where your code was generated (folder "galactic_app" inside your curent working folder). You need to run startup script which will create virutal enviroment, install requirments, refactor code with black and ruff, run pytest and mypy check, create initial database migration with alembic and run your app.

Run the startup script from bash command line (use gitbash or linuxbash).

source startup.sh

You can go on and open your project at http://127.0.0.1:8000/docs. Also check input in your shell to see coverage of the tests and passing of the mypy lint test.

Conclusion

Warp-FastApi: Embark on a voyage of FastAPI exploration, akin to the most exhilarating space odysseys. Bid farewell to repetitive code warp cores and allow Warp-FastApi to be your steadfast warp drive. Set your course now and let your code traverse new frontiers!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

warp_fastapi-0.1.1a1.tar.gz (33.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

warp_fastapi-0.1.1a1-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file warp_fastapi-0.1.1a1.tar.gz.

File metadata

  • Download URL: warp_fastapi-0.1.1a1.tar.gz
  • Upload date:
  • Size: 33.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Windows/10

File hashes

Hashes for warp_fastapi-0.1.1a1.tar.gz
Algorithm Hash digest
SHA256 7afb71add233756c49dbb23d5161ffe6fa8923c1d79d9887a2732bc99ed0cf1f
MD5 52951b91e7353e211ae93c4c722416dc
BLAKE2b-256 124e05b03bdf3cb1022f0addd9374a40698b20ebbd6f18a9f1e71461a8d851d3

See more details on using hashes here.

File details

Details for the file warp_fastapi-0.1.1a1-py3-none-any.whl.

File metadata

  • Download URL: warp_fastapi-0.1.1a1-py3-none-any.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Windows/10

File hashes

Hashes for warp_fastapi-0.1.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ca34a577f9db1f28b050b4ce2e65bf1f3b3b9dec1a1713489df79c8601c6c11
MD5 0b58ccc688356df8dbff6313794d2a84
BLAKE2b-256 6502dfca92d85fb2d70a9107aeed6c1e2673461d6f7802c981be95a15479c539

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page