Extended with examples & api query options

This commit is contained in:
2022-11-02 21:31:17 +01:00
parent c8f87ade58
commit 35760c2da2

View File

@@ -20,10 +20,23 @@ yarn start
## Examples ## Examples
Generate Larry 3D ascii response from text: Generate Larry 3D figlet response from text:
```bash ```bash
curl localhost:3000/ascii\?text\=ragnhild curl localhost:3000/figlet\?text\=ragnhild
```
Outputs:
```
__ ___ __
/\ \ __ /\_ \ /\ \
_ __ __ __ ___\ \ \___ /\_\\//\ \ \_\ \
/\`'__\/'__`\ /'_ `\ /' _ `\ \ _ `\/\ \ \ \ \ /'_` \
\ \ \//\ \L\.\_/\ \L\ \/\ \/\ \ \ \ \ \ \ \ \_\ \_/\ \L\ \
\ \_\\ \__/.\_\ \____ \ \_\ \_\ \_\ \_\ \_\/\____\ \___,_\
\/_/ \/__/\/_/\/___L\ \/_/\/_/\/_/\/_/\/_/\/____/\/__,_ /
/\____/
\_/__/
``` ```
Generate motd executable with text and save to file: Generate motd executable with text and save to file:
@@ -32,6 +45,15 @@ Generate motd executable with text and save to file:
curl localhost:3000/motd\?text\=ragnhild > 20-hostname curl localhost:3000/motd\?text\=ragnhild > 20-hostname
``` ```
### Options
Api endpoints `/text` & `/motd` have the following query options:
| query param | type | description | required |
|-------------|--------|--------------------------------------|----------|
| text | string | text to generate | yes |
| font | string | select font, get list from /fonts | no |
| width | number | max character width before linebreak | no |
## Docker install ## Docker install
Run as a docker container using: Run as a docker container using:
@@ -47,20 +69,25 @@ docker run -d \
Example systemd config for running http server. Example systemd config for running http server.
Clone repo to: `/opt/figlet-http`
`/etc/systemd/system/figlet-http.service`
``` ```
[Unit] [Unit]
Description=Http server for running homename-larry Description=Http server for running figlet-http
[Service] [Service]
WorkingDirectory=/opt/hostname-larry WorkingDirectory=/opt/figlet-http
ExecStart=/usr/bin/node index.js ExecStart=/usr/bin/yarn start
Restart=always Restart=always
# Restart service after 10 seconds if node service crashes # Restart service after 10 seconds if node service crashes
RestartSec=10 RestartSec=10
# Output to syslog # Output to syslog
StandardOutput=syslog StandardOutput=syslog
StandardError=syslog StandardError=syslog
SyslogIdentifier=hostname-larry SyslogIdentifier=figlet-http
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target