https://github.com/veeso-dev/tokyo-draft
A webservice to render HTML templates from API data
https://github.com/veeso-dev/tokyo-draft
Last synced: about 1 year ago
JSON representation
A webservice to render HTML templates from API data
- Host: GitHub
- URL: https://github.com/veeso-dev/tokyo-draft
- Owner: veeso-dev
- License: mit
- Created: 2023-07-21T20:06:01.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-31T15:57:42.000Z (over 2 years ago)
- Last Synced: 2025-02-14T16:41:43.703Z (over 1 year ago)
- Language: Rust
- Size: 69.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# tokyo-draft
~ A webservice to render HTML templates from API data ~
Developed by @veeso
Current version: 0.1.2 (25/07/2023)
---
- [tokyo-draft](#tokyo-draft)
- [About tokyo-draft](#about-tokyo-draft)
- [Get started](#get-started)
- [Run](#run)
- [tokyo-draft API](#tokyo-draft-api)
- [Check](#check)
- [Render](#render)
- [Errors](#errors)
- [Hook API](#hook-api)
- [Support the developer](#support-the-developer)
- [Contributing and issues](#contributing-and-issues)
- [Changelog](#changelog)
- [License](#license)
---
## About tokyo-draft
tokyo-draft is a Rust web service which renders HTML templates starting from incoming data from API. The API allows you to render any template you've pre-configured in the service configuration.
The rendered template is then sent via a POST request to a configurable hook.
---
## Get started
### Run
First configure the environment file as you wish, then source .env and run tokyo-draft with
```sh
./tokyo-draft.sh start /var/run/tokyo-draft.pid
```
At this point tokyo-draft will be served on the specified port in the `.env` (or `.env.override`) file. (Default: `3011`)
## tokyo-draft API
### Check
Check web service status:
```txt
GET /check
```
Response:
```json
{
"status": "ok"
}
```
### Render
Render a template with provided data:
```txt
POST /render
```
payload:
```json
{
"template": "my-template",
"data": {
"key1": "value",
"key2": 123,
},
"hookMetadata": {
/* custom data to be passed to hook */
}
}
```
Response (HTML):
(rendered template)
#### Errors
- In case of missing keys or unknown template returns 400.
## Hook API
It is possible to configure in the environment the key `RENDER_HOOK` to an URL which will receive the rendered template as parameter as follows:
```json
{
"body": "RENDERED TEMPLATE HTML SYNTAX BASE64 ENCODED",
"metadata": {
/* data passed as hookMetadata to /render */
}
}
```
---
## Support the developer
If you like tokyo-draft and you're grateful for the work I've done, please consider a little donation ๐ฅณ
You can make a donation with one of these platforms:
[](https://ko-fi.com/veeso)
[](https://www.paypal.me/chrisintin)
---
## Contributing and issues
Contributions, bug reports, new features and questions are welcome! ๐
If you have any question or concern, or you want to suggest a new feature, or you want just want to improve pavao, feel free to open an issue or a PR.
Please follow [our contributing guidelines](CONTRIBUTING.md)
---
## Changelog
View tokyo-draft's changelog [HERE](CHANGELOG.md)
---
## License
tokyo-draft is licensed under the MIT license.
You can read the entire license [HERE](LICENSE)