Node.js application for printing TODO tickets on thermal receipt printers.
- 🎫 Print todo tickets with title, assignee, and description
- 🖨️ Support for USB and network thermal printers
- 📋 RESTful API endpoints
- 🐳 Docker support (recommended for network printers)
- 📱 Easy to integrate with other applications
-
Configure your printer:
cp .env.example .env
-
Edit
.envfor your printer:For Network Printer (recommended):
PRINTER_NETWORK_IP=10.0.0.237 # Your printer's IP PRINTER_NETWORK_PORT=9100 # Usually 9100
For USB Printer (Linux only):
# Find your printer's USB IDs with: lsusb PRINTER_VENDOR_ID=0x20d1 PRINTER_PRODUCT_ID=0x7008 -
Run with Docker Compose:
docker-compose up -d
-
Test the API:
curl -X POST http://localhost:3000/print-todo \ -H "Content-Type: application/json" \ -d '{ "title": "Test the printer setup", "assignee": "John Doe", "description": "Make sure the printer is working correctly" }'
-
Install dependencies:
npm install
-
Configure environment:
cp .env.example .env # Edit .env with your printer settings -
Run the server:
npm run todo-server
Print a TODO ticket.
Request Body:
{
"title": "Fix the login bug", // Required: Main task title
"assignee": "John Doe", // Optional: Person assigned
"description": "Users cannot login..." // Optional: Task details
}Response:
{
"success": true,
"message": "Todo ticket printed successfully",
"ticket": {
"title": "Fix the login bug",
"assignee": "John Doe",
"description": "Users cannot login...",
"timestamp": "2024-01-15T10:30:00.000Z"
}
}Check server and printer status.
Get detailed printer connection information.
API documentation and usage examples
Configure your printer in the .env file. Choose either USB or Network mode:
PRINTER_VENDOR_ID: USB Vendor ID (hex format, e.g.,0x20d1)PRINTER_PRODUCT_ID: USB Product ID (hex format, e.g.,0x7008)
PRINTER_NETWORK_IP: Network printer IP addressPRINTER_NETWORK_PORT: Network printer port (default: 9100)
# Simple ticket with just a title
curl -X POST http://localhost:3000/print-todo \
-H "Content-Type: application/json" \
-d '{"title":"Review pull request #123"}'
# Full ticket with assignee and description
curl -X POST http://localhost:3000/print-todo \
-H "Content-Type: application/json" \
-d '{
"title": "Fix login bug",
"assignee": "John Doe",
"description": "Users are unable to login with special characters in their passwords"
}'# Simple ticket
node test-client.js "Fix login bug"
# With assignee
node test-client.js "Fix login bug" "John Doe"
# Full ticket
node test-client.js "Fix login bug" "John Doe" "Users cannot login with special chars"const response = await fetch("http://localhost:3000/print-todo", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
title: "Update documentation",
assignee: "Alice Smith",
description: "Add API documentation for the new endpoints",
}),
});
const result = await response.json();
console.log(result);For best compatibility across all platforms, use network-connected printers:
- Configure your printer for network access
- Set
PRINTER_NETWORK_IPin your.envfile - Run with Docker:
docker-compose up -d
- Linux: Full USB support with privileged mode
- macOS/Windows: USB passthrough not supported with Docker Desktop due to virtualization
For USB printers on macOS/Windows:
- Run natively:
npm run todo-server - Use a Linux host for Docker deployment
- Convert to network printer (recommended)
- Ensure printer is powered on and connected
- For USB: Check USB IDs with
lsusb - For Network: Verify IP address is reachable
- Check your
.envconfiguration
- Ensure printer has paper loaded
- Check paper width matches expectations
todo-printer-server.js- Main server fileprinter.js- Simple print test utilitytest-client.js- Test client for trying the API