Metadata-Version: 2.3
Name: fastmicroservices
Version: 0.1.49
Summary: Connect FastAPI microservices easily.
Author: Miles Copeland Luce
Requires-Python: >=3.13,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: fastapi (>=0.116.1,<0.117.0)
Requires-Dist: fastj2 (>=0.1.11,<0.2.0)
Requires-Dist: loguru (>=0.7.3,<0.8.0)
Requires-Dist: starlette (>=0.47.2,<0.48.0)
Requires-Dist: toomanyconfigs (>=0.2.865,<0.3.0)
Requires-Dist: toomanyports (>=0.1.11,<0.2.0)
Requires-Dist: toomanysessions (>=0.1.9960,<0.2.0)
Requires-Dist: toomanythreads (>=0.2.75,<0.3.0)
Description-Content-Type: text/markdown

## Install

```bash
pip install fastmicroservices
```

## Usage

```python
import time

from toomanythreads import ThreadedServer

from fastmicroservices import Macroservice
from fastmicroservices import Microservice


class Dummy(ThreadedServer, Microservice):
    def __init__(self, macroservice: Macroservice):
        ThreadedServer.__init__(self)
        Microservice.__init__(self, macroservice)

        @self.get("/")
        def foobar():
            return "foobar"


if __name__ == "__main__":
    m = Macroservice()
    serv = Dummy(m)
    m.thread.start()
    time.sleep(100)
```

## How it works

The core routing engine uses `/page/{page_name}/{path:path}`:

- **Automatic Directory Construction**: The backend uses TooManyConfigs and FastJ2 to automatically provision a templates folder and render from it.
- **Service Discovery**: Macroservice finds your service by `page_name`, which is the lowercase class' name. In the above instance, it would be http://localhost:{port}/page/dummy
- **Internal Routing**: Your service handles its own routes via the `forward()` method. You can code your own forwarding method, but ThreadedServer already provides this. See https://pypi.org/project/toomanythreads/

Example: `/page/dummy/api/users` → finds "dummy" service → calls `dummy.forward("/api/users")`
Static HTML files in `templates/static_pages/` work the same way but just render templates.

Licensed under MIT.
