Um pacote para gerar projetos FastAPI com estrutura básica.
Project description
Fast Hard
Fast Hard is a Python package that generates a FastAPI project with a basic structure, similar to create-react-app for React. It sets up a ready-to-use FastAPI application with essential dependencies, folder structure, and configurations.
Features
- Generates a FastAPI project with a standard folder structure.
- Installs essential dependencies:
- FastAPI
- Uvicorn
- SQLAlchemy
- Pytest
- Email-validator
- Alembic (for database migrations)
- Includes a basic
.envfile for environment variables. - Sets up Alembic for database migrations.
- Provides a simple
main.pywith a "Hello World" endpoint. - New commands for flexible folder structure:
fast-hard create_mvc <project_name>: Creates a project and adds an MVC folder structure.fast-hard create_use_cases <project_name>: Creates a project and adds a folder structure for use cases.
- Choose your database:
- SQLite
- MySQL
- PostgreSQL
- MongoDB
Installation
You can install fast_hard via pip:
pip install fast_hard
Usage
Create a New Project
To create a new project, use the following command:
fast-hard create_project <project_name> --structure <structure> --database <database>
<project_name>: The name of your new project.--structure: Choose the folder structure (mvcoruse_cases).--database: Choose the database (sqlite,mysql,postgresql, ormongodb).
Example:
fast-hard create_project my_new_project --structure mvc --database mysql
This will generate a new FastAPI project with the following structure:
my_new_project/
├── app/
│ ├── __init__.py
│ ├── main.py
│ ├── models/
│ ├── schemas/
│ ├── routes/
│ ├── tests/
│ ├── config/
│ └── alembic/
│ ├── env.py
│ ├── script.py.mako
│ └── versions/
├── requirements.txt
├── .env
├── .gitignore
├── alembic.ini
└── README.md
Add an MVC Structure
To add an MVC structure to an existing project (or create a new one if it doesn't exist), use:
fast-hard create_mvc <project_name>
This will add the following folders under the app directory:
my_new_project/
├── app/
│ ├── controllers/
│ ├── views/
│ └── models/
Add a Use Case Structure
To add a use case structure to an existing project (or create a new one if it doesn't exist), use:
fast-hard create_use_cases <project_name>
This will add the following folder under the app directory:
my_new_project/
├── app/
│ ├── use_cases/
Run the Project
To run the project, navigate to the project directory and start the FastAPI server:
cd my_new_project
pip install -r requirements.txt
cd app
uvicorn main:app --reload
Open your browser at:
http://127.0.0.1:8000/
You should see the message:
{
"Hello": "World"
}
Database Configuration
The .env file will be configured based on the chosen database:
SQLite
DATABASE_URL=sqlite:///./test.db
MySQL
DATABASE_URL=mysql+pymysql://user:password@localhost/dbname
PostgreSQL
DATABASE_URL=postgresql://user:password@localhost/dbname
MongoDB
DATABASE_URL=mongodb://localhost:27017/
Make sure to update the .env file with your actual database credentials.
Link PyPI
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast_hard-0.1.3.tar.gz.
File metadata
- Download URL: fast_hard-0.1.3.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3df6457ec6fab0830b651af799ecf3a20410c41c57763ad6bba620e89d9320f0
|
|
| MD5 |
6824e647d6258d8494b9da936e160548
|
|
| BLAKE2b-256 |
b3ee23ba729b0401345a157e2bdfa001a505e48a122a3414bb8a3f38a82ce78f
|
File details
Details for the file fast_hard-0.1.3-py3-none-any.whl.
File metadata
- Download URL: fast_hard-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
befdad49e61584322cf537f842ec281b24444887e5550c8694cb30b50272739a
|
|
| MD5 |
3d5197538629b5fa2cd8fdfb997926c8
|
|
| BLAKE2b-256 |
3ee4436f96b1ba12540f0f0c78bdf737ca06dc028654286cc3ebedd8b481c79a
|