Backend & API
Backend and API work: HTTP calls, timing, JWT, ports, keys, certs.
File aliases/api.sh. Disable: export ALIASX_DISABLE="api"
HTTP calls
| Name | Runs | What it does | |
|---|---|---|---|
hget URL [curl options] | GET, JSON pretty-printedexample$ hget localhost:8080/users/1
{
"id": 1,
"name": "Ali"
} | ||
hpost URL JSON | POST JSON body (use @file.json for a file)example$ hpost localhost:8080/users '{"name":"Vali"}'
{
"id": 2,
"name": "Vali"
} | ||
hput URL JSON | PUT JSON bodyexample$ hput localhost:8080/users/2 '{"name":"Vali B"}'
{
"id": 2,
"name": "Vali B"
} | ||
hpatch URL JSON | PATCH JSON bodyexample$ hpatch localhost:8080/users/2 '{"active":false}'
{
"id": 2,
"active": false
} | ||
hdelete URL | DELETE after y/Nexample$ hdelete localhost:8080/users/2
DELETE localhost:8080/users/2 ? [y/N] y | ||
timing URL | DNS, connect, TLS, first byte and total timeexample$ timing https://example.com
status: 200
dns: 0.012s
connect: 0.045s
tls: 0.110s
first: 0.230s
total: 0.241s
size: 1256 bytes | ||
watchurl URL [SEC] | print status code every SEC seconds (default 2)example$ watchurl localhost:8080/health
10:31:02 200 0.004s
10:31:04 200 0.003s
10:31:06 502 0.001s |
Tokens and keys
| Name | Runs | What it does | |
|---|---|---|---|
jwt TOKEN | decode JWT header and payload (no signature check)example$ jwt eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjMifQ.sig
{
"alg": "HS256"
}
{
"sub": "123"
} | ||
hexkey [BYTES] | random hex secret (default 32 bytes)example$ hexkey 16
9f2c4e1a7b3d8c05e6f1a2b3c4d5e6f7 | ||
selfcert DOMAIN | self-signed cert DOMAIN.crt + DOMAIN.key for local dev (1 year)example$ selfcert dev.local
dev.local.crt dev.local.key |
Services
| Name | Runs | What it does | |
|---|---|---|---|
waitport HOST PORT [SEC] | wait until PORT accepts connections (default 30s)example$ waitport localhost 5432
localhost:5432 is up |
Logs
| Name | Runs | What it does | |
|---|---|---|---|
jl | jq -R 'fromjson? // .' | readable JSON log lines | needs jq |