epos-bridge-client
v1.0.0
Published
A client for the Epson ePOS Bridge application.
Downloads
14
Readme
@soshosai/epos-bridge-client
A simple JavaScript client for communicating with the Epson ePOS Bridge application, allowing you to print receipts using ePOS-Print XML.
Installation
npm install @soshosai/epos-bridge-clientUsage
import ePOSBridgeClient from '@soshosai/epos-bridge-client';
const client = new ePOSBridgeClient();
async function checkPrinter() {
try {
await client.checkConnection();
console.log('ePOS Bridge is running.');
// Configure your printer's IP address
await client.configurePrinter('192.168.1.100');
console.log('Printer configured.');
} catch (error) {
console.error(error.message);
}
}
async function printSomething() {
const receiptXml = `
<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">
<text>Hello World!</text>
<cut/>
</epos-print>
`;
try {
const result = await client.printDirect(receiptXml);
console.log('Print successful:', result);
} catch (error) {
console.error('Print failed:', error.message);
}
}
checkPrinter();
printSomething();API
new ePOSBridgeClient()
Creates a new client instance.
async checkConnection()
Checks if the ePOS Bridge application is running and accessible at http://localhost:15888/health. Throws an error if the connection fails.
async configurePrinter(ipAddress, useSsl = false)
Sets the target printer for the ePOS Bridge.
ipAddress(string): The IP address of the Epson receipt printer.useSsl(boolean): Whether to use a secure connection to the printer. Defaults tofalse.
async printDirect(xmlContent)
Sends a raw ePOS-Print XML string to the configured printer.
xmlContent(string): The XML content to be printed.
License
ISC
