// Sends a sample ESC/POS receipt (with a GS V cut) to the proxy listener. // Useful to verify logging + forwarding. import net from "node:net"; const host = process.env.LISTEN_HOST || "127.0.0.1"; const port = Number(process.env.LISTEN_PORT || 9100); const ESC = 0x1b; const GS = 0x1d; const lines = [ Buffer.from([ESC, 0x40]), // init Buffer.from([ESC, 0x61, 0x01]), // center Buffer.from("KASSENBON\n", "latin1"), Buffer.from([ESC, 0x61, 0x00]), // left Buffer.from("Artikel 1 3.50 EUR\n", "latin1"), Buffer.from("Artikel 2 1.20 EUR\n", "latin1"), Buffer.from("--------------------------------\n", "latin1"), Buffer.from("Summe 4.70 EUR\n", "latin1"), Buffer.from([GS, 0x56, 0x00]), // cut (bladecut) -> job delimiter // second job in same connection: Buffer.from([ESC, 0x40]), Buffer.from("TAGESABSCHLUSS\n", "latin1"), Buffer.from([GS, 0x56, 0x01]), // another cut ]; const client = net.createConnection({ host, port }, () => { console.log(`[test] connected to ${host}:${port}`); for (const l of lines) client.write(l); console.log("[test] sent sample jobs"); client.end(); }); client.on("error", (err) => { console.error("[test] error:", err.message); process.exit(1); }); client.on("close", () => { console.log("[test] done"); process.exit(0); });