Backend & API

Backend and API work: HTTP calls, timing, JWT, ports, keys, certs.

File aliases/api.sh. Disable: export ALIASX_DISABLE="api"

HTTP calls

NameRunsWhat it does
hget URL [curl options]GET, JSON pretty-printed
example
$ hget localhost:8080/users/1
{
  "id": 1,
  "name": "Ali"
}
hpost URL JSONPOST JSON body (use @file.json for a file)
example
$ hpost localhost:8080/users '{"name":"Vali"}'
{
  "id": 2,
  "name": "Vali"
}
hput URL JSONPUT JSON body
example
$ hput localhost:8080/users/2 '{"name":"Vali B"}'
{
  "id": 2,
  "name": "Vali B"
}
hpatch URL JSONPATCH JSON body
example
$ hpatch localhost:8080/users/2 '{"active":false}'
{
  "id": 2,
  "active": false
}
hdelete URLDELETE after y/N
example
$ hdelete localhost:8080/users/2
DELETE localhost:8080/users/2 ? [y/N] y
timing URLDNS, connect, TLS, first byte and total time
example
$ 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

NameRunsWhat it does
jwt TOKENdecode 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 DOMAINself-signed cert DOMAIN.crt + DOMAIN.key for local dev (1 year)
example
$ selfcert dev.local
dev.local.crt dev.local.key

Services

NameRunsWhat it does
waitport HOST PORT [SEC]wait until PORT accepts connections (default 30s)
example
$ waitport localhost 5432
localhost:5432 is up

Logs

NameRunsWhat it does
jljq -R 'fromjson? // .'readable JSON log linesneeds jq