fastapi-prime-2.0 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 M-an-o-j
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastapi-prime-2.0
3
+ Version: 0.1.0
4
+ Summary: A generator for FastAPI projects.
5
+ Author-email: M-an-o-j <mmanoj20037@gmail.com>
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.8
8
+ Requires-Dist: typer>=0.9.0
9
+ Description-Content-Type: text/markdown
10
+
11
+ # FastAPI Prime
12
+
13
+ A generator for FastAPI microservices.
@@ -0,0 +1,3 @@
1
+ # FastAPI Prime
2
+
3
+ A generator for FastAPI microservices.
File without changes
@@ -0,0 +1,24 @@
1
+ import typer
2
+ from fastapi_prime.generators.gateway import create_api_gateway
3
+ from fastapi_prime.generators.service import create_service
4
+
5
+ app = typer.Typer()
6
+
7
+ create_app = typer.Typer()
8
+ app.add_typer(create_app, name="create")
9
+
10
+
11
+ @app.command()
12
+ def init(project_name: str):
13
+ create_api_gateway()
14
+ print(f"Project {project_name} created")
15
+
16
+
17
+ @create_app.command("service")
18
+ def service(service_name: str):
19
+ create_service(service_name)
20
+ print(f"{service_name}_service created")
21
+
22
+
23
+ if __name__ == "__main__":
24
+ app()
@@ -0,0 +1,71 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def create_api_gateway():
5
+ gateway_root = Path("api_gateway")
6
+
7
+ folders = [
8
+ "app/api/gateway",
9
+ "app/clients",
10
+ "app/services",
11
+ "app/configuration",
12
+ "app/utils",
13
+ "tests",
14
+ ]
15
+
16
+ files = {
17
+ "app/main.py": "",
18
+ "app/api/__init__.py": "",
19
+ "app/api/gateway/__init__.py": "",
20
+ "app/api/gateway/routes.py": "",
21
+ "app/clients/__init__.py": "",
22
+ "app/services/__init__.py": "",
23
+ "app/configuration/__init__.py": "",
24
+ "app/configuration/settings.py": """from pydantic_settings import BaseSettings
25
+
26
+
27
+ class Settings(BaseSettings):
28
+ model_config = {
29
+ "env_file": ".env"
30
+ }
31
+
32
+
33
+ settings = Settings()
34
+ """,
35
+ "app/utils/__init__.py": "",
36
+ "tests/__init__.py": "",
37
+ ".env": "",
38
+ "requirements.txt": """fastapi
39
+ uvicorn
40
+ httpx
41
+ pydantic-settings
42
+ """,
43
+ "Dockerfile": """FROM python:3.12-slim
44
+
45
+ WORKDIR /app
46
+
47
+ COPY requirements.txt .
48
+ RUN pip install -r requirements.txt
49
+
50
+ COPY . .
51
+
52
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
53
+ """,
54
+ }
55
+
56
+ # Create folders
57
+ for folder in folders:
58
+ (gateway_root / folder).mkdir(parents=True, exist_ok=True)
59
+
60
+ # Create files
61
+ for file_path, content in files.items():
62
+ full_path = gateway_root / file_path
63
+
64
+ with open(full_path, "w", encoding="utf-8") as f:
65
+ f.write(content)
66
+
67
+ print("API Gateway created successfully.")
68
+
69
+
70
+ if __name__ == "__main__":
71
+ create_api_gateway()
@@ -0,0 +1,44 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def create_service(service_name: str):
5
+ service_root = Path(f"{service_name}_service")
6
+
7
+ folders = [
8
+ "app/api",
9
+ "app/services",
10
+ "app/repositories",
11
+ "app/models",
12
+ "app/schemas",
13
+ "app/configuration",
14
+ "app/utils",
15
+ "tests",
16
+ ]
17
+
18
+ files = [
19
+ "app/main.py",
20
+ "app/api/__init__.py",
21
+ "app/services/__init__.py",
22
+ "app/repositories/__init__.py",
23
+ "app/models/__init__.py",
24
+ "app/schemas/__init__.py",
25
+ "app/configuration/__init__.py",
26
+ "app/utils/__init__.py",
27
+ "tests/__init__.py",
28
+ ]
29
+
30
+ # Create folders
31
+ for folder in folders:
32
+ (service_root / folder).mkdir(parents=True, exist_ok=True)
33
+
34
+ # Create files
35
+ for file in files:
36
+ file_path = service_root / file
37
+ file_path.touch(exist_ok=True)
38
+
39
+ print(f"Created {service_name}_service successfully.")
40
+
41
+
42
+ if __name__ == "__main__":
43
+ service_name = input("Service name: ").strip()
44
+ create_service(service_name)
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "fastapi-prime-2.0"
7
+ version = "0.1.0"
8
+ description = "A generator for FastAPI projects."
9
+ authors = [
10
+ { name = "M-an-o-j", email = "mmanoj20037@gmail.com" }
11
+ ]
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ dependencies = [
15
+ "typer>=0.9.0",
16
+ ]
17
+
18
+ [project.scripts]
19
+ fastapi-prime = "fastapi_prime.cli:app"
20
+
21
+ [tool.hatch.build.targets.wheel]
22
+ packages = ["fastapi_prime"]