npm.io
0.2.1 • Published 5 years agoCLI

@h0me/tp-server

Licence
MIT
Version
0.2.1
Deps
8
Size
23 kB
Vulns
0
Weekly
0

tp-server

A Thermal Printer server and MQTT client providing a markup-like api interface around the `escpos' library.

An example HTTP request would look like...

POST /job HTTP/1.1
Host: 192.168.1.23:3000
Content-Type: text/plain

font "a"
size "2" "2"
align "ct"
style "bu"
text "Hi!"
size "0" "0"
text "A little test print for you!"
text "Have a barcode"
barcode "1234567" "EAN8"
cut

More commands can be found at the escpos repo.

Run the server

To start the server, you can install globally, or use npx

npm install -g @h0me/tp-server
tp-server examples/config.js
npx @h0me/tp-server examples/config.js

Print!

HTTP
curl --location --request POST 'http://192.168.1.23:3000/job' \
--header 'Content-Type: text/plain' \
--data-raw 'font "a"
size "2" "2"
text "Hi!"
cut'
MQTT
mqtt pub -t "h0me/tp-server" -m 'font "a"
size "2" "2"
text "Hi!"
cut'