Metadata-Version: 2.4
Name: ci-cd-apier
Version: 3.0.0
Summary: ci-cd-APIer -- Flask-like API framework for GitLab CI/CD pipelines
Author-email: Adam Hlavacek <git@adamhlavacek.com>
Project-URL: Homepage, https://github.com/esoadamo/ci-cd-apier
Project-URL: Issues, https://github.com/esoadamo/ci-cd-apier/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: ssage==1.5.1
Requires-Dist: jinja2==3.1.6
Provides-Extra: client
Requires-Dist: aiohttp>=3.8.0; extra == "client"
Dynamic: license-file

# ci-cd-APIer

APIer is a library that allows you to launch its backend code with Flask-like syntax using GitLab CI/CD.
All the requests and responses are processed with e2e encryption using [age](https://age-encryption.org/),
so nobody has access to the data except the sender (web page) and the receiver (GitLab job in memory).

## Installation

This project uses uv for dependency management and local development.

```bash
uv sync
```

If you want to run a one-off command inside the project environment:

```bash
uv run python -c "import ci_cd_apier; print('ci-cd-apier ready')"
```

To include Python client dependencies in the local development environment:

```bash
uv sync --group client
```

For PyPI installs, use the `client` extra:

```bash
pip install "ci-cd-apier[client]"
```

## Usage example

**To see the full example, take a look at the [example repository](https://gitlab.com/esoadamo/ci-cd-apier-example/).**

Whenever the client calls a backend via APIer script, e.g.:

```js
const APIer = new APIer(
    '$AGE_PUBLIC_KEY$',
    '$GITLAB_PIPELINE_ENDPOINT$',
    '$GITLAB_TOKEN$'
);

const totalSum = await APIer.sendRequest('sumNumbers', [1, 2, 3, 4, 5]);
```

A pipeline is triggered. Example code that handles the request in the pipeline may be:

```python
app = APIER(environ["AGE_SECRET_KEY"])

@app.route("echo")
def endpoint_echo(data: any) -> str:
    return f"You said: {data}. Enjoy :)"
    
@app.route("sumNumbers")
def endpoint_sum(data: list[int]) -> str:
    return str(sum(data))

app.process_requests()
```

There also exists Python client for APIer in `ci_cd_apier.client` package.
