barbarcode
v0.1.1
Published
[](https://www.npmjs.com/package/barbarcode)
Downloads
25
Readme
Barbarcode
Barbarcode is a simple, open-source barcode scanning service with a server and a mobile client, both implemented in JavaScript.
Demo
https://github.com/user-attachments/assets/6905fc00-624b-4bd9-932c-54c056b6a9ef
Usage
Get started with Barbarcode in four simple steps:
- Install the server:
npm install -g barbarcode
# or use npx without installing- Create a
config.tomlfile with your keystroke mappings:
[sessions]
inventory_input = "{barcode}{enter}"
price_check = "{key:F4}{barcode}{enter}"- Start the server with your desired session:
barbarcode -p 8080 -s inventory_input
# or with npx:
npx barbarcode -p 8080 -s inventory_input- Scan the QR code displayed by the server using your mobile device to start scanning barcodes!
Server
The server component handles:
- Running a WebSocket server for client connections
- Converting scanned barcodes into keystrokes
- Managing scanning sessions via CLI
Configuration
The config.toml file defines how barcodes are processed using keystroke patterns:
[sessions]
# Press Enter after the barcode
inventory_input = "{barcode}{enter}"
# Press F4, then type barcode, then Enter
price_check = "{key:F4}{barcode}{enter}"
# Type SKU:, the barcode, Tab, then Quantity:
data_entry = "SKU:{barcode}{tab}Quantity:"
# Wait 500ms, press F5, type barcode, Tab, 1, Enter
complex_input = "{delay:500}{key:F5}{barcode}{tab}1{enter}"Keystroke Pattern Syntax
{barcode}: The scanned barcode value{enter},{tab},{esc}: Special keys{delay:ms}: Add delay in milliseconds{up},{down},{left},{right}: Arrow keys{key:X}: Any other key (X)- Regular text: Typed as-is
Client
A mobile-first web client that:
- Automatically opens when scanning the server's QR code
- Handles barcode scanning through your device's camera
Libraries Used
Server:
- ws: WebSocket server
- toml: TOML configuration parsing
- commander: CLI interface
- qr: QR code generation
- robotjs: Keystroke emulation
- ngrok: Public URL tunneling
Client:
- html5-qrcode: QR code scanning
- quaggaJS: Barcode scanning
License
Barbarcode is open-source and available under the MIT License.
Contributing
Contributions to Barbarcode are welcome! Please feel free to submit a Pull Request.
Support
If you encounter any problems or have any questions, please open an issue on the GitHub repository.
