faster-app 0.0.10__py3-none-any.whl → 0.0.12__py3-none-any.whl

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,23 @@
1
+ # 项目配置示例文件
2
+ # 复制此文件为 .env 并根据需要修改配置
3
+
4
+ # 项目基本信息
5
+ PROJECT_NAME=Faster APP
6
+ DEBUG=true
7
+
8
+ # 服务器配置
9
+ HOST=0.0.0.0
10
+ PORT=8000
11
+
12
+ # 数据库配置
13
+ DB_TYPE=sqlite
14
+ DB_HOST=localhost
15
+ DB_PORT=3306
16
+ DB_USER=
17
+ DB_PASSWORD=
18
+ DB_DATABASE=faster_app
19
+
20
+ # 安全配置
21
+ SECRET_KEY=your-secret-key-here-please-change-in-production
22
+ ALGORITHM=HS256
23
+ ACCESS_TOKEN_EXPIRE_MINUTES=30
faster_app/__init__.py CHANGED
@@ -9,7 +9,7 @@ Faster APP - 一个轻量级的 Python Web 框架
9
9
  - 数据库连接管理 (tortoise_init)
10
10
  """
11
11
 
12
- __version__ = "0.0.10"
12
+ __version__ = "0.0.12"
13
13
  __author__ = "peizhenfei"
14
14
  __email__ = "peizhenfei@hotmail.com"
15
15
 
@@ -60,7 +60,7 @@ class CommandBase(object):
60
60
  return attr
61
61
 
62
62
  @classmethod
63
- def get_command_name(cls, class_name: str = None, suffixes: list = None) -> str:
63
+ def _get_command_name(cls, class_name: str = None, suffixes: list = None) -> str:
64
64
  """
65
65
  自动去除类名中的常见后缀,生成简洁的命令名
66
66
 
@@ -9,18 +9,14 @@ console = Console()
9
9
  class AppCommand(CommandBase):
10
10
  """App Command"""
11
11
 
12
- async def init(self):
13
- """Run Init App"""
14
- # 拷贝项目根路径下的 main.py 文件到项目根路径
15
- shutil.copy(f"{self.BASE_PATH}/main.py", "main.py")
16
- console.print("✅ main.py created successfully")
17
-
12
+ async def env(self):
13
+ """Create .env file"""
18
14
  # 拷贝项目根路径下的 .env.example 文件到项目根路径
19
15
  shutil.copy(f"{self.BASE_PATH}/.env.example", ".env")
20
16
  console.print("✅ .env created successfully")
21
17
 
22
18
  async def demo(self):
23
- """Run Demo"""
19
+ """create demo app"""
24
20
  # 项目根路径下创建 apps 目录,如果存在则跳过
25
21
  if not os.path.exists("apps"):
26
22
  os.makedirs("apps")
@@ -28,11 +24,6 @@ class AppCommand(CommandBase):
28
24
  shutil.copytree(f"{self.BASE_PATH}/templates/apps/demo", "apps/demo")
29
25
 
30
26
  async def config(self):
31
- """Run Config"""
32
- # 项目根路径下创建 config 目录,如果存在则跳过
33
- if not os.path.exists("config"):
34
- os.makedirs("config")
35
- # 拷贝 templates/config/settings.py 到 config 目录
36
- shutil.copytree(
37
- f"{self.BASE_PATH}/templates/config/settings.py", "config/settings.py"
38
- )
27
+ """create config"""
28
+ # 拷贝 templates/config 到 . 目录
29
+ shutil.copytree(f"{self.BASE_PATH}/templates/config", ".")
@@ -13,7 +13,7 @@ console = Console()
13
13
 
14
14
 
15
15
  class DBOperations(CommandBase):
16
- """数据库操作命令 - 使用Aerich管理数据库迁移"""
16
+ """DB Operations - 使用 Aerich 管理数据库迁移"""
17
17
 
18
18
  def __init__(self, fake: bool = False):
19
19
  self.fake = fake
@@ -69,7 +69,9 @@ class FastAPIAppSingleton:
69
69
  app = FastAPIAppSingleton()
70
70
 
71
71
 
72
- class FastApiOperations(CommandBase):
72
+ class ServerOperations(CommandBase):
73
+ """FastAPI Server Operations"""
74
+
73
75
  def __init__(self, host: str = None, port: int = None):
74
76
  configs = DefaultSettings()
75
77
  self.host = host or configs.HOST
@@ -2,6 +2,7 @@
2
2
  自动发现 apps 目录下的 commands 模块和内置命令
3
3
  """
4
4
 
5
+ from typing import Dict
5
6
  from faster_app.commands.base import CommandBase
6
7
  from faster_app.base import DiscoverBase
7
8
 
@@ -22,3 +23,15 @@ class CommandDiscover(DiscoverBase):
22
23
  "skip_files": [],
23
24
  },
24
25
  ]
26
+
27
+ def collect(self) -> Dict[str, CommandBase]:
28
+ commands = {}
29
+ command_instances = self.discover()
30
+
31
+ # 将命令实例转换为字典,使用类名作为键
32
+ for instance in command_instances:
33
+ # 使用 CommandBase 的 _get_command_name 方法自动去除后缀
34
+ command_name = instance._get_command_name()
35
+ commands[command_name] = instance
36
+
37
+ return commands
faster_app/main.py CHANGED
@@ -10,16 +10,7 @@ def main():
10
10
  """
11
11
  Faster APP 命令行入口点
12
12
  """
13
- command_instances = CommandDiscover().discover()
14
-
15
- # 将命令实例转换为字典,使用类名作为键
16
- commands = {}
17
- for instance in command_instances:
18
- # 使用 CommandBase 的 get_command_name 方法自动去除后缀
19
- command_name = instance.get_command_name()
20
- commands[command_name] = instance
21
-
22
- # 直接传递命令字典给 Fire
13
+ commands = CommandDiscover().collect()
23
14
  fire.Fire(commands)
24
15
 
25
16
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: faster_app
3
- Version: 0.0.10
3
+ Version: 0.0.12
4
4
  Summary: 一个轻量级的 Python Web 框架,提供自动发现、模型基类、命令行工具等功能
5
5
  Author-email: peizhenfei <peizhenfei@hotmail.com>
6
6
  Maintainer-email: peizhenfei <peizhenfei@hotmail.com>
@@ -1,14 +1,15 @@
1
- faster_app/__init__.py,sha256=ZvBK3Al85B5r_lmpYPpD-EE7syIo8hPndMdSurhCLqM,1426
1
+ faster_app/.env.example,sha256=XMTXjcdM6hWwQiK9gSkWM9NxkryCCgWAVXvEEZRXCZk,413
2
+ faster_app/__init__.py,sha256=FyUe9NYdfIrBCAIurJ_V2KjCLZJemJXECPMIxIVwGY0,1426
2
3
  faster_app/base.py,sha256=8350gBg_GkW_ww_lDvIOODFOJ71_yowQ5gd_tMTPrQ8,4035
3
4
  faster_app/db.py,sha256=uG4k_eSy5C2MP7DF-senxI10sLAGrLkgmBRFfH_91kY,994
4
- faster_app/main.py,sha256=En5hYXB-wbcnEFmQ6mmMlwnO1y-SM5nFcLsMN9dZk4s,613
5
+ faster_app/main.py,sha256=WVFz5k1bjfnij87JDvT-rXQyd_ufDh25msikSA6TbLs,276
5
6
  faster_app/commands/__init__.py,sha256=AgjI6NmKpdzNTH93XvXsvh54F7PiRX-MJq6emITw7K4,258
6
- faster_app/commands/base.py,sha256=c5wRPxIBEyJLgBTrFGGDUs4Xh4h9gMxFHlNOf6MgcMo,2544
7
- faster_app/commands/discover.py,sha256=7pWETGJmRi6KDj-LcBLbmusKIvPElGFU6T92WvdRTew,620
7
+ faster_app/commands/base.py,sha256=mt0sictBXZdnkwQC9x4_MrOS-Z8msFyC72_mFzQ2Zfs,2545
8
+ faster_app/commands/discover.py,sha256=o6X83vjq3A0rvKnQ6Y1G68tYd9qcVhoYMlYen9zOiK4,1076
8
9
  faster_app/commands/builtins/__init__.py,sha256=Wi3YfjUhZ45VNh7SoLdtCATjAPbWjSwv0gpmFZGJMHA,27
9
- faster_app/commands/builtins/app.py,sha256=LIcFuk4Xy19dhNn2DpFS6Zd5tjmLCBszprpI9iUjTI0,1332
10
- faster_app/commands/builtins/db.py,sha256=cGxa98VC-h1Wl725GUvcu1XYAtAwY6n3t_0pNa-fbho,4741
11
- faster_app/commands/builtins/fastapi.py,sha256=QOdnt63V0PHRgjZvVLeZXbE94YaOc5uN39e4SmwPtwY,2392
10
+ faster_app/commands/builtins/app.py,sha256=FZpiaz9EpsdAVFAhUaHMR6medhyjW3X28HtkJ0XyAZE,939
11
+ faster_app/commands/builtins/db.py,sha256=jrHOngEQw4Xuwf1uW4rZALfQX3M7SzsVTgzYrIVJaes,4735
12
+ faster_app/commands/builtins/fastapi.py,sha256=o1rj11dUy5b_yoCGDfGX_zor-JPABKbotnvJpT-De3g,2428
12
13
  faster_app/models/__init__.py,sha256=6Mn6zjxF0JJfhDik4LNaXDNLxGgdgl5ECBbqLvgkpxs,334
13
14
  faster_app/models/base.py,sha256=XdWpXQTQDQWwBae8GVhKxwQIAIRwsHRBJ30gQr6ynCQ,2738
14
15
  faster_app/models/discover.py,sha256=fN9yUlVemoqtnXpA-wmHHG_zSX78y2z649Ix-v1oN7E,1640
@@ -27,9 +28,9 @@ faster_app/templates/apps/demo/commands.py,sha256=KECFqPzxn46qpveRARoxyyYk_ZVZ-R
27
28
  faster_app/templates/apps/demo/models.py,sha256=RfodpzyDfhwbfxfRg_qMwTVFjV7n8uLfJTFsCaWUNHs,328
28
29
  faster_app/templates/apps/demo/routes.py,sha256=Ye1IsU-xDox33IETZQ4K2LLIWkeby9whzVmQqB9JaFY,270
29
30
  faster_app/templates/config/settings.py,sha256=2Q58pumllN5a09mem3bPy-z65Jy5NTTicN4KjGJ-sY8,182
30
- faster_app-0.0.10.dist-info/licenses/LICENSE,sha256=VlZLv92YNpRecXnQ92BsEhMZK0zX453xnBFta4eGPRE,1073
31
- faster_app-0.0.10.dist-info/METADATA,sha256=ImyK7hoY47ZjmWgGNZYknqxjxBiLullFj5Kr-tXKaGE,7383
32
- faster_app-0.0.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- faster_app-0.0.10.dist-info/entry_points.txt,sha256=7PnCc_r0NYS1RU2OKbdod2sJBdUt8-JpmCCQSt0OLPs,52
34
- faster_app-0.0.10.dist-info/top_level.txt,sha256=Ah5KB3gcZwXCVsxO8kQtaC0Y7Uy__QFm1p_RJGo5UIU,11
35
- faster_app-0.0.10.dist-info/RECORD,,
31
+ faster_app-0.0.12.dist-info/licenses/LICENSE,sha256=VlZLv92YNpRecXnQ92BsEhMZK0zX453xnBFta4eGPRE,1073
32
+ faster_app-0.0.12.dist-info/METADATA,sha256=Ye1XpFVFEchIqBanMOG0mob5ZKO8fk2cmdzKD5s1wg4,7383
33
+ faster_app-0.0.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ faster_app-0.0.12.dist-info/entry_points.txt,sha256=7PnCc_r0NYS1RU2OKbdod2sJBdUt8-JpmCCQSt0OLPs,52
35
+ faster_app-0.0.12.dist-info/top_level.txt,sha256=Ah5KB3gcZwXCVsxO8kQtaC0Y7Uy__QFm1p_RJGo5UIU,11
36
+ faster_app-0.0.12.dist-info/RECORD,,