Metadata-Version: 2.1
Name: trpc-core
Version: 0.1.0
Summary: A toolkit for implementing tRPC servers in python
Author-email: Rafał Pitoń <rafio.xudb@gmail.com>
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Description-Content-Type: text/markdown

`trpc-core`
===========

Toolkit for implementing tRPC servers in python

> `trpc-core` is currently in prototype stage. You are welcome to play with the code or drop feedback in issues, just don't expect anything usable or functional yet.


### Example tRPC API with Flask:

```python
import trpc
from flask import Flask, jsonify, request


class Router(trpc.Router):
    @trpc.query(name="helloWorld")
    def hello_world(context) -> str:
        return "Hello world"

    @trpc.mutation(name="sum")
    def sum(context, *, a: int, b: int) -> int:
        return a + b


server = trpc.Server(Router)


app = Flask(__name__)


@app.route("/trpc/<path:path>", methods=["GET"])
def trpc_query(path):
    result = server.query(path)
    return jsonify(result)


@app.route("/trpc/<path:path>", methods=["POST"])
def trpc_mutation(path):
    result = server.mutation(path)
    return jsonify(result)
```