runapi 0.1.3__tar.gz → 0.2.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.
Files changed (30) hide show
  1. {runapi-0.1.3 → runapi-0.2.0}/.gitignore +3 -0
  2. {runapi-0.1.3 → runapi-0.2.0}/PKG-INFO +137 -105
  3. {runapi-0.1.3 → runapi-0.2.0}/README.md +115 -89
  4. runapi-0.2.0/examples/basic/README.md +15 -0
  5. {runapi-0.1.3 → runapi-0.2.0}/pyproject.toml +39 -18
  6. runapi-0.2.0/release-notes/README.md +7 -0
  7. {runapi-0.1.3 → runapi-0.2.0}/runapi/__init__.py +13 -1
  8. runapi-0.2.0/runapi/_version.py +24 -0
  9. {runapi-0.1.3 → runapi-0.2.0}/runapi/auth.py +97 -19
  10. {runapi-0.1.3 → runapi-0.2.0}/runapi/cli.py +156 -15
  11. {runapi-0.1.3 → runapi-0.2.0}/runapi/core.py +60 -24
  12. runapi-0.2.0/runapi/py.typed +0 -0
  13. {runapi-0.1.3 → runapi-0.2.0}/runapi/service.py +2 -1
  14. runapi-0.1.3/.github/ISSUE_TEMPLATE/bug_report.md +0 -27
  15. runapi-0.1.3/.github/ISSUE_TEMPLATE/documentation.md +0 -14
  16. runapi-0.1.3/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  17. runapi-0.1.3/.github/PULL_REQUEST_TEMPLATE.md +0 -24
  18. runapi-0.1.3/.github/workflows/publish.yml +0 -196
  19. runapi-0.1.3/CONTRIBUTING.md +0 -216
  20. runapi-0.1.3/MANIFEST.in +0 -18
  21. runapi-0.1.3/tests/final_test.py +0 -377
  22. runapi-0.1.3/tests/simple_test.py +0 -188
  23. runapi-0.1.3/tests/test_runapi.py +0 -1080
  24. runapi-0.1.3/tests/test_runapi_installation.py +0 -374
  25. {runapi-0.1.3 → runapi-0.2.0}/LICENSE +0 -0
  26. {runapi-0.1.3 → runapi-0.2.0}/runapi/config.py +0 -0
  27. {runapi-0.1.3 → runapi-0.2.0}/runapi/errors.py +0 -0
  28. {runapi-0.1.3 → runapi-0.2.0}/runapi/middleware.py +0 -0
  29. {runapi-0.1.3 → runapi-0.2.0}/runapi/repository.py +0 -0
  30. {runapi-0.1.3 → runapi-0.2.0}/runapi/schemas.py +0 -0
@@ -104,3 +104,6 @@ temp/
104
104
  *.key
105
105
  secrets.json
106
106
  credentials.json
107
+
108
+ # Generated by hatch-vcs at build time
109
+ runapi/_version.py
@@ -1,12 +1,12 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: runapi
3
- Version: 0.1.3
3
+ Version: 0.2.0
4
4
  Summary: A Next.js-inspired file-based routing framework built on FastAPI
5
5
  Project-URL: Homepage, https://github.com/Amanbig/runapi
6
6
  Project-URL: Repository, https://github.com/Amanbig/runapi
7
- Project-URL: Documentation, https://github.com/Amanbig/runapi#readme
7
+ Project-URL: Documentation, https://github.com/Amanbig/runapi/tree/main/docs
8
8
  Project-URL: Issues, https://github.com/Amanbig/runapi/issues
9
- Project-URL: Changelog, https://github.com/Amanbig/runapi/releases
9
+ Project-URL: Changelog, https://github.com/Amanbig/runapi/tree/main/release-notes
10
10
  Author-email: Amanpreet Singh <amanpreetsinghjhiwant7@gmail.com>
11
11
  License: MIT License
12
12
 
@@ -38,31 +38,37 @@ Classifier: Intended Audience :: Developers
38
38
  Classifier: License :: OSI Approved :: MIT License
39
39
  Classifier: Operating System :: OS Independent
40
40
  Classifier: Programming Language :: Python :: 3
41
- Classifier: Programming Language :: Python :: 3.8
42
- Classifier: Programming Language :: Python :: 3.9
43
41
  Classifier: Programming Language :: Python :: 3.10
44
42
  Classifier: Programming Language :: Python :: 3.11
45
43
  Classifier: Programming Language :: Python :: 3.12
44
+ Classifier: Programming Language :: Python :: 3.13
46
45
  Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
47
46
  Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
48
47
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
49
48
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
50
49
  Classifier: Typing :: Typed
51
- Requires-Python: >=3.8
52
- Requires-Dist: aiofiles>=23.0.0
53
- Requires-Dist: fastapi>=0.103.0
54
- Requires-Dist: passlib[bcrypt]>=1.7.4
55
- Requires-Dist: psutil>=5.9.0
56
- Requires-Dist: python-jose[cryptography]>=3.3.0
57
- Requires-Dist: python-multipart>=0.0.6
58
- Requires-Dist: rich>=13.0.0
59
- Requires-Dist: typer>=0.9.0
60
- Requires-Dist: uvicorn>=0.23.0
50
+ Requires-Python: >=3.10
51
+ Requires-Dist: aiofiles>=23.2.1
52
+ Requires-Dist: bcrypt>=4.0.1
53
+ Requires-Dist: fastapi>=0.115.6
54
+ Requires-Dist: psutil>=6.0.0
55
+ Requires-Dist: pyjwt>=2.10.1
56
+ Requires-Dist: python-multipart>=0.0.18
57
+ Requires-Dist: rich>=13.7.0
58
+ Requires-Dist: typer>=0.12.0
59
+ Requires-Dist: uvicorn>=0.30.0
60
+ Provides-Extra: db
61
+ Requires-Dist: aiosqlite>=0.19; extra == 'db'
62
+ Requires-Dist: alembic>=1.13; extra == 'db'
63
+ Requires-Dist: sqlalchemy[asyncio]>=2.0; extra == 'db'
61
64
  Provides-Extra: dev
62
65
  Requires-Dist: httpx>=0.24.0; extra == 'dev'
63
66
  Requires-Dist: mypy>=1.0.0; extra == 'dev'
64
67
  Requires-Dist: pytest>=7.0.0; extra == 'dev'
65
68
  Requires-Dist: ruff>=0.1.0; extra == 'dev'
69
+ Provides-Extra: docs
70
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
71
+ Requires-Dist: mkdocs>=1.6; extra == 'docs'
66
72
  Provides-Extra: lint
67
73
  Requires-Dist: mypy>=1.0.0; extra == 'lint'
68
74
  Requires-Dist: ruff>=0.1.0; extra == 'lint'
@@ -76,18 +82,56 @@ Description-Content-Type: text/markdown
76
82
  # Runapi 🚀
77
83
 
78
84
  [![PyPI version](https://badge.fury.io/py/runapi.svg)](https://badge.fury.io/py/runapi)
79
- [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
85
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
80
86
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
81
87
 
82
88
  A Next.js-inspired file-based routing framework built on FastAPI for Python backend development. runapi makes building robust APIs as intuitive as creating files and folders.
83
89
 
84
- ## Why Runapi?
90
+ ## Why runapi?
91
+
92
+ - **Enhanced Developer Experience**: Inspired by Next.js, runapi provides an intuitive environment for backend development.
93
+ - **High Performance**: Built upon FastAPI, leveraging one of the most efficient Python web frameworks available.
94
+ - **Production-Ready Core**: Includes integrated security, middleware, and standardized error handling.
95
+ - **Strict Type Safety**: Comprehensive typing support with automated Pydantic validation.
96
+ - **Intuitive Routing**: Implements file-based routing where the directory structure defines the API surface.
97
+
98
+ ## Comparative Analysis: FastAPI vs. runapi
99
+
100
+ runapi is an extension of the FastAPI framework, introducing standardized architectural patterns and conventions to streamline the development lifecycle.
101
+
102
+ | Feature | FastAPI | runapi |
103
+ | :--- | :--- | :--- |
104
+ | **Routing Mechanism** | Explicit registration via decorators | **Automated file-based routing** |
105
+ | **Architectural Pattern** | Unopinionated / Custom | **Opinionated (Service-Repository)** |
106
+ | **Initialization** | Manual configuration | **Automated discovery** and CLI-driven generation |
107
+ | **Boilerplate Requirements** | Higher in enterprise-scale applications | **Significantly reduced** through convention |
108
+ | **Abstraction Level** | Low-level / Direct access | High-level with underlying FastAPI access |
109
+ | **Primary Use Case** | Bespoke or highly specialized architectures | **Rapid application development** and team consistency |
110
+
111
+ ### Architectural Trade-offs: Choosing runapi over Vanilla FastAPI
112
+
113
+ Adopting runapi instead of standard FastAPI involves a strategic exchange of granular control for architectural standardization and development speed.
114
+
115
+ | Feature | The runapi Advantage | The FastAPI Trade-off |
116
+ | :--- | :--- | :--- |
117
+ | **Development Speed vs. Granular Control** | **Accelerated Time-to-Market**: Automates route discovery and boilerplate generation, allowing developers to focus on business logic immediately. | **Reduced Configuration Control**: Developers relinquish explicit control over how and where individual routes are instantiated and registered within the application lifecycle. |
118
+ | **Standardization vs. Flexibility** | **Enforced Best Practices**: Implements a consistent Service-Repository pattern that ensures codebase maintainability and simplifies onboarding in team environments. | **Constrained Architectural Freedom**: The framework requires strict adherence to its directory structure (`routes/`, `services/`, etc.), which may conflict with highly customized or legacy architectural requirements. |
119
+ | **Abstraction vs. Transparency** | **High-Level Productivity**: Hides complex FastAPI and Pydantic configurations behind simplified interfaces (e.g., `CRUDService`, `BaseSchema`). | **Increased Debugging Complexity**: The additional abstraction layer can obscure the underlying FastAPI behavior, potentially complicating the diagnostic process for edge-case bugs or performance tuning. |
120
+ | **Ecosystem Integration** | **Seamless Defaults**: Provides pre-configured, production-ready middleware (CORS, JWT, Rate Limiting) that follows industry standards. | **Compatibility Considerations**: While built on FastAPI, some highly specialized third-party FastAPI plugins may require manual adaptation to integrate with runapi's automated lifecycle. |
121
+
122
+ ### Strategic Implementation Criteria
123
+
124
+ #### Criteria for Selecting runapi
125
+ - Requirement for accelerated development cycles with minimal configuration overhead.
126
+ - Preference for **file-based routing** over manual route registration.
127
+ - Necessity for a **standardized architectural framework** (Services, Repositories, Schemas).
128
+ - Objective to minimize repetitive code for standard operations such as Authentication and CRUD.
129
+
130
+ #### Criteria for Selecting Plain FastAPI
131
+ - Requirement for absolute control over every aspect of the system architecture.
132
+ - Development of highly specialized or non-standard systems.
133
+ - Preference for explicit route registration and manual configuration over system conventions.
85
134
 
86
- - 🚀 **Developer Experience**: Just like Next.js for React, runapi makes backend development intuitive
87
- - ⚡ **Performance**: Built on FastAPI, one of the fastest Python frameworks
88
- - 🛡️ **Production Ready**: Security, middleware, and error handling built-in
89
- - 🎯 **Type Safe**: Full typing support with automatic validation
90
- - 📁 **Intuitive**: File-based routing means your folder structure IS your API
91
135
 
92
136
  ## Features
93
137
 
@@ -112,7 +156,7 @@ pip install runapi
112
156
 
113
157
  ## Requirements
114
158
 
115
- - Python 3.8+
159
+ - Python 3.10+
116
160
  - FastAPI
117
161
  - Uvicorn (for development server)
118
162
 
@@ -175,6 +219,7 @@ Routes are created by adding Python files in the `routes/` directory:
175
219
  ```python
176
220
  from runapi import JSONResponse
177
221
 
222
+
178
223
  async def get():
179
224
  return JSONResponse({"message": "Hello runapi!"})
180
225
  ```
@@ -183,9 +228,11 @@ async def get():
183
228
  ```python
184
229
  from runapi import JSONResponse, Request
185
230
 
231
+
186
232
  async def get():
187
233
  return JSONResponse({"users": []})
188
234
 
235
+
189
236
  async def post(request: Request):
190
237
  body = await request.json()
191
238
  return JSONResponse({"created": body})
@@ -195,15 +242,18 @@ async def post(request: Request):
195
242
  ```python
196
243
  from runapi import JSONResponse, Request
197
244
 
245
+
198
246
  async def get(request: Request):
199
247
  user_id = request.path_params["id"]
200
248
  return JSONResponse({"user_id": user_id})
201
249
 
250
+
202
251
  async def put(request: Request):
203
252
  user_id = request.path_params["id"]
204
253
  body = await request.json()
205
254
  return JSONResponse({"user_id": user_id, "updated": body})
206
255
 
256
+
207
257
  async def delete(request: Request):
208
258
  user_id = request.path_params["id"]
209
259
  return JSONResponse({"user_id": user_id, "deleted": True})
@@ -275,20 +325,24 @@ from runapi import BaseSchema, IDMixin, TimestampMixin
275
325
  from pydantic import Field
276
326
  from typing import Optional
277
327
 
328
+
278
329
  # Base schema with ORM support and validation
279
330
  class UserBase(BaseSchema):
280
331
  email: str = Field(..., description="User email")
281
332
  name: str = Field(..., min_length=1, max_length=100)
282
333
 
334
+
283
335
  # Schema for creating (no ID, no timestamps)
284
336
  class UserCreate(UserBase):
285
337
  password: str = Field(..., min_length=8)
286
338
 
339
+
287
340
  # Schema for updating (all fields optional)
288
341
  class UserUpdate(BaseSchema):
289
342
  email: Optional[str] = None
290
343
  name: Optional[str] = None
291
344
 
345
+
292
346
  # Schema for responses (includes ID and timestamps)
293
347
  class UserResponse(UserBase, IDMixin, TimestampMixin):
294
348
  pass
@@ -298,28 +352,23 @@ class UserResponse(UserBase, IDMixin, TimestampMixin):
298
352
 
299
353
  ```python
300
354
  from runapi import (
301
- BaseSchema, # Base with ORM mode, validation
302
- IDMixin, # Adds 'id: int' field
303
- TimestampMixin, # Adds 'created_at', 'updated_at'
304
- MessageResponse, # Simple {"message": str, "success": bool}
305
- PaginatedResponse, # Generic paginated list wrapper
306
- PaginationParams, # Query params with offset/limit
355
+ BaseSchema, # Base with ORM mode, validation
356
+ IDMixin, # Adds 'id: int' field
357
+ TimestampMixin, # Adds 'created_at', 'updated_at'
358
+ MessageResponse, # Simple {"message": str, "success": bool}
359
+ PaginatedResponse, # Generic paginated list wrapper
360
+ PaginationParams, # Query params with offset/limit
307
361
  )
308
362
 
309
363
  # Pagination example
310
364
  from runapi import PaginatedResponse, PaginationParams
311
365
 
366
+
312
367
  async def get_users(params: PaginationParams):
313
- users = await user_service.get_all(
314
- skip=params.offset,
315
- limit=params.limit
316
- )
368
+ users = await user_service.get_all(skip=params.offset, limit=params.limit)
317
369
  total = await user_service.count()
318
370
  return PaginatedResponse.create(
319
- items=users,
320
- total=total,
321
- page=params.page,
322
- page_size=params.page_size
371
+ items=users, total=total, page=params.page, page_size=params.page_size
323
372
  )
324
373
  ```
325
374
 
@@ -330,6 +379,7 @@ async def get_users(params: PaginationParams):
330
379
  from runapi import JSONResponse, Request
331
380
  from schemas.user import UserCreate, UserResponse
332
381
 
382
+
333
383
  async def post(request: Request):
334
384
  body = await request.json()
335
385
  user_data = UserCreate(**body) # Validates input
@@ -352,6 +402,7 @@ runapi generate repository user
352
402
  ```python
353
403
  from runapi import InMemoryRepository
354
404
 
405
+
355
406
  class UserRepository(InMemoryRepository):
356
407
  """In-memory storage - great for development/testing."""
357
408
 
@@ -361,6 +412,7 @@ class UserRepository(InMemoryRepository):
361
412
  async def find_active_users(self):
362
413
  return await self.get_many_by(is_active=True)
363
414
 
415
+
364
416
  # Usage
365
417
  repo = UserRepository()
366
418
  user = await repo.create({"name": "John", "email": "john@example.com"})
@@ -375,6 +427,7 @@ await repo.delete(1)
375
427
  from runapi import TypedInMemoryRepository
376
428
  from schemas.user import UserResponse
377
429
 
430
+
378
431
  class UserRepository(TypedInMemoryRepository[UserResponse]):
379
432
  def __init__(self):
380
433
  super().__init__(UserResponse)
@@ -382,6 +435,7 @@ class UserRepository(TypedInMemoryRepository[UserResponse]):
382
435
  async def find_by_email(self, email: str):
383
436
  return await self.get_by(email=email)
384
437
 
438
+
385
439
  # Returns UserResponse instances, not dicts
386
440
  user = await repo.create({"name": "John", "email": "john@example.com"})
387
441
  assert isinstance(user, UserResponse)
@@ -394,6 +448,7 @@ from runapi import SQLAlchemyRepository, SQLALCHEMY_AVAILABLE
394
448
  from sqlalchemy.ext.asyncio import AsyncSession
395
449
 
396
450
  if SQLALCHEMY_AVAILABLE:
451
+
397
452
  class UserRepository(SQLAlchemyRepository[UserModel, int]):
398
453
  def __init__(self, session: AsyncSession):
399
454
  super().__init__(session, UserModel)
@@ -432,6 +487,7 @@ runapi generate service user
432
487
  ```python
433
488
  from runapi import CRUDService, InMemoryRepository
434
489
 
490
+
435
491
  class UserService(CRUDService):
436
492
  """Inherits all CRUD operations with error handling."""
437
493
 
@@ -445,6 +501,7 @@ class UserService(CRUDService):
445
501
  async def deactivate(self, user_id: int):
446
502
  return await self.update(user_id, {"is_active": False})
447
503
 
504
+
448
505
  # Usage
449
506
  user_repo = UserRepository()
450
507
  user_service = UserService(user_repo, entity_name="User")
@@ -463,16 +520,16 @@ await user_service.delete(1) # Raises NotFoundError if missing
463
520
  from runapi import ValidatedService
464
521
  from schemas.user import UserCreate, UserUpdate
465
522
 
523
+
466
524
  class UserService(ValidatedService):
467
525
  create_schema = UserCreate # Auto-validates on create
468
526
  update_schema = UserUpdate # Auto-validates on update
469
527
 
528
+
470
529
  # Input is validated against schemas automatically
471
- user = await user_service.create({
472
- "name": "John",
473
- "email": "john@example.com",
474
- "password": "secure123"
475
- })
530
+ user = await user_service.create(
531
+ {"name": "John", "email": "john@example.com", "password": "secure123"}
532
+ )
476
533
  ```
477
534
 
478
535
  ### Complete Example: Routes + Service + Repository
@@ -481,19 +538,23 @@ user = await user_service.create({
481
538
  # repositories/user.py
482
539
  from runapi import InMemoryRepository
483
540
 
541
+
484
542
  class UserRepository(InMemoryRepository):
485
543
  async def find_by_email(self, email: str):
486
544
  return await self.get_by(email=email)
487
545
 
546
+
488
547
  # services/user.py
489
548
  from runapi import CRUDService, ValidationError
490
549
 
550
+
491
551
  class UserService(CRUDService):
492
552
  async def register(self, data: dict):
493
553
  if await self.repository.get_by(email=data["email"]):
494
554
  raise ValidationError("Email exists")
495
555
  return await self.create(data)
496
556
 
557
+
497
558
  # routes/api/users.py
498
559
  from runapi import JSONResponse, Request
499
560
  from repositories.user import UserRepository
@@ -502,10 +563,12 @@ from services.user import UserService
502
563
  user_repo = UserRepository()
503
564
  user_service = UserService(user_repo, "User")
504
565
 
566
+
505
567
  async def get():
506
568
  users = await user_service.get_all()
507
569
  return JSONResponse(users)
508
570
 
571
+
509
572
  async def post(request: Request):
510
573
  body = await request.json()
511
574
  user = await user_service.register(body)
@@ -518,8 +581,8 @@ async def post(request: Request):
518
581
  from runapi import validate_input, require_exists, log_operation
519
582
  from schemas.user import UserCreate
520
583
 
521
- class UserService(CRUDService):
522
584
 
585
+ class UserService(CRUDService):
523
586
  @validate_input(UserCreate)
524
587
  async def create(self, data: dict):
525
588
  return await self.repository.create(data)
@@ -602,8 +665,7 @@ app = create_runapi_app()
602
665
 
603
666
  # Protect specific routes
604
667
  app.add_auth_middleware(
605
- protected_paths=["/api/protected"],
606
- excluded_paths=["/api/auth/login", "/docs"]
668
+ protected_paths=["/api/protected"], excluded_paths=["/api/auth/login", "/docs"]
607
669
  )
608
670
  ```
609
671
 
@@ -613,17 +675,18 @@ app.add_auth_middleware(
613
675
  ```python
614
676
  from runapi import JSONResponse, Request, create_token_response, verify_password
615
677
 
678
+
616
679
  async def post(request: Request):
617
680
  body = await request.json()
618
681
  username = body.get("username")
619
682
  password = body.get("password")
620
-
683
+
621
684
  # Verify credentials (implement your logic)
622
685
  if verify_credentials(username, password):
623
686
  user_data = {"sub": "user_id", "username": username}
624
687
  tokens = create_token_response(user_data)
625
688
  return JSONResponse(tokens.dict())
626
-
689
+
627
690
  return JSONResponse({"error": "Invalid credentials"}, status_code=401)
628
691
  ```
629
692
 
@@ -633,11 +696,9 @@ async def post(request: Request):
633
696
  ```python
634
697
  from runapi import JSONResponse, get_current_user, Depends
635
698
 
699
+
636
700
  async def get(current_user: dict = Depends(get_current_user())):
637
- return JSONResponse({
638
- "message": "This is protected!",
639
- "user": current_user
640
- })
701
+ return JSONResponse({"message": "This is protected!", "user": current_user})
641
702
  ```
642
703
 
643
704
  ## Middleware
@@ -651,7 +712,7 @@ app = create_runapi_app()
651
712
 
652
713
  # Built-in middleware (automatically configured via .env)
653
714
  # - CORS
654
- # - Rate limiting
715
+ # - Rate limiting
655
716
  # - Security headers
656
717
  # - Request logging
657
718
  # - Compression
@@ -659,6 +720,7 @@ app = create_runapi_app()
659
720
  # Add custom middleware
660
721
  from runapi import RunApiMiddleware
661
722
 
723
+
662
724
  class CustomMiddleware(RunApiMiddleware):
663
725
  async def dispatch(self, request, call_next):
664
726
  # Pre-processing
@@ -666,6 +728,7 @@ class CustomMiddleware(RunApiMiddleware):
666
728
  # Post-processing
667
729
  return response
668
730
 
731
+
669
732
  app.add_middleware(CustomMiddleware)
670
733
  ```
671
734
 
@@ -676,14 +739,15 @@ runapi provides comprehensive error handling:
676
739
  ```python
677
740
  from runapi import ValidationError, NotFoundError, raise_not_found
678
741
 
742
+
679
743
  async def get_user(user_id: str):
680
744
  if not user_id:
681
745
  raise ValidationError("User ID is required")
682
-
746
+
683
747
  user = find_user(user_id)
684
748
  if not user:
685
749
  raise_not_found("User not found")
686
-
750
+
687
751
  return user
688
752
  ```
689
753
 
@@ -743,20 +807,18 @@ from runapi import create_runapi_app, get_config
743
807
  config = get_config()
744
808
 
745
809
  # Create app with custom settings
746
- app = create_runapi_app(
747
- title="My API",
748
- description="Built with runapi",
749
- version="1.0.0"
750
- )
810
+ app = create_runapi_app(title="My API", description="Built with runapi", version="1.0.0")
751
811
 
752
812
  # Add custom middleware
753
813
  app.add_auth_middleware()
754
814
 
815
+
755
816
  # Add custom startup/shutdown events
756
817
  @app.get_app().on_event("startup")
757
818
  async def startup():
758
819
  print("Starting up!")
759
820
 
821
+
760
822
  # Get underlying FastAPI app
761
823
  fastapi_app = app.get_app()
762
824
  ```
@@ -771,6 +833,7 @@ from runapi import get_config
771
833
  config = get_config()
772
834
  engine = create_engine(config.database_url)
773
835
 
836
+
774
837
  # Use in routes
775
838
  async def get_users():
776
839
  # Your database logic here
@@ -783,10 +846,12 @@ async def get_users():
783
846
  from fastapi import BackgroundTasks
784
847
  from runapi import JSONResponse
785
848
 
849
+
786
850
  async def send_email(email: str):
787
851
  # Send email logic
788
852
  pass
789
853
 
854
+
790
855
  async def post(request: Request, background_tasks: BackgroundTasks):
791
856
  body = await request.json()
792
857
  background_tasks.add_task(send_email, body["email"])
@@ -807,6 +872,7 @@ runapi supports dynamic route parameters:
807
872
  from fastapi import UploadFile, File
808
873
  from runapi import JSONResponse
809
874
 
875
+
810
876
  async def post(file: UploadFile = File(...)):
811
877
  contents = await file.read()
812
878
  # Process file
@@ -821,6 +887,7 @@ from main import app
821
887
 
822
888
  client = TestClient(app.get_app())
823
889
 
890
+
824
891
  def test_read_main():
825
892
  response = client.get("/")
826
893
  assert response.status_code == 200
@@ -833,7 +900,7 @@ def test_read_main():
833
900
 
834
901
  **Dockerfile**
835
902
  ```dockerfile
836
- FROM python:3.9-slim
903
+ FROM python:3.12-slim
837
904
 
838
905
  WORKDIR /app
839
906
  COPY requirements.txt .
@@ -863,6 +930,7 @@ from runapi import get_app
863
930
 
864
931
  app = get_app()
865
932
 
933
+
866
934
  @app.websocket("/ws/chat")
867
935
  async def websocket_endpoint(websocket: WebSocket):
868
936
  await websocket.accept()
@@ -993,19 +1061,20 @@ async def patch(): # PATCH request
993
1061
  ```python
994
1062
  from runapi import Request, JSONResponse
995
1063
 
1064
+
996
1065
  async def post(request: Request):
997
1066
  # Get JSON body
998
1067
  body = await request.json()
999
-
1068
+
1000
1069
  # Get path parameters
1001
1070
  user_id = request.path_params.get("id")
1002
-
1071
+
1003
1072
  # Get query parameters
1004
1073
  limit = request.query_params.get("limit", 10)
1005
-
1074
+
1006
1075
  # Get headers
1007
1076
  auth_header = request.headers.get("authorization")
1008
-
1077
+
1009
1078
  return JSONResponse({"status": "success"})
1010
1079
  ```
1011
1080
 
@@ -1140,44 +1209,7 @@ Please include:
1140
1209
 
1141
1210
  ## Changelog
1142
1211
 
1143
- ### v0.1.3 (Latest)
1144
- - **New Feature**: Schema layer with auto-discovery from `schemas/` directory
1145
- - **New Feature**: `BaseSchema`, `IDMixin`, `TimestampMixin` for consistent model definitions
1146
- - **New Feature**: `PaginatedResponse` and `PaginationParams` for pagination support
1147
- - **New Feature**: Repository pattern with `BaseRepository`, `InMemoryRepository`, `TypedInMemoryRepository`
1148
- - **New Feature**: Optional `SQLAlchemyRepository` for async database support
1149
- - **New Feature**: Service layer with `CRUDService`, `ValidatedService`
1150
- - **New Feature**: Service decorators: `@validate_input`, `@require_exists`, `@log_operation`
1151
- - **New Feature**: `ServiceFactory` and `RepositoryFactory` for dependency injection
1152
- - **CLI**: Added `runapi generate schema <name>` command
1153
- - **CLI**: Added `runapi generate repository <name>` command
1154
- - **CLI**: Added `runapi generate service <name>` command
1155
- - **CLI**: Added `runapi schemas` command to list all schemas
1156
- - **CLI**: Updated `runapi init` to create schemas/, repositories/, services/ directories
1157
- - **Tests**: Added 20 comprehensive tests covering all new features
1158
-
1159
- ### v0.1.2
1160
- - **New Feature**: Added `runapi start` command for production deployments (no-reload, multi-worker support)
1161
- - **Performance**: Optimized startup time by ignoring irrelevant directories during route discovery
1162
- - **Performance**: Replaced O(N) rate limiting with O(1) Fixed Window Counter algorithm
1163
- - **Performance**: Implemented streaming compression using `GZipMiddleware` for lower TTFB and memory usage
1164
- - **Security**: Refactored authentication to use standard `python-jose` library instead of manual implementation
1165
- - **CLI**: Optimized `runapi dev` startup speed and `runapi routes` robustness
1166
-
1167
- ### v0.1.1
1168
- - **Bug Fix**: Fixed `runapi dev` command failing to import main module
1169
- - **Enhancement**: Improved CLI error handling and validation
1170
- - **Enhancement**: Better Python path management for uvicorn integration
1171
- - **Enhancement**: Added pre-validation of main.py before server startup
1172
-
1173
- ### v0.1.0
1174
- - Initial release
1175
- - File-based routing system
1176
- - JWT authentication
1177
- - Middleware stack
1178
- - CLI tools
1179
- - Configuration management
1180
- - Error handling system
1212
+ Per-version notes live in [`release-notes/`](release-notes/) and on the [GitHub Releases](https://github.com/Amanbig/runapi/releases) page. Latest: [`RELEASE_NOTES.md`](RELEASE_NOTES.md).
1181
1213
 
1182
1214
  ## License
1183
1215
 
@@ -1195,7 +1227,7 @@ This project is licensed under the MIT License - see the LICENSE file for detail
1195
1227
  - Built on top of [FastAPI](https://fastapi.tiangolo.com/) by Sebastián Ramirez
1196
1228
  - Inspired by [Next.js](https://nextjs.org/) file-based routing by Vercel
1197
1229
  - Uses [Typer](https://typer.tiangolo.com/) for CLI by Sebastián Ramirez
1198
- - Password hashing with [Passlib](https://passlib.readthedocs.io/)
1230
+ - Password hashing with [bcrypt](https://pypi.org/project/bcrypt/)
1199
1231
  - Testing with [pytest](https://pytest.org/) and [httpx](https://www.python-httpx.org/)
1200
1232
 
1201
1233
  ## Related Projects
@@ -1220,6 +1252,6 @@ If runapi has been helpful to your project:
1220
1252
 
1221
1253
  **runapi** - Making Python backend development as intuitive as frontend development! 🚀
1222
1254
 
1223
- [Get Started](https://github.com/Amanbig/runapi) | [Documentation](https://github.com/Amanbig/runapi) | [Examples](https://github.com/Amanbig/runapi/tree/main/example)
1255
+ [Get Started](https://github.com/Amanbig/runapi) | [Documentation](https://github.com/Amanbig/runapi/tree/main/docs) | [Examples](https://github.com/Amanbig/runapi/tree/main/examples)
1224
1256
 
1225
1257
  </div>