New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@magneds/hapi-plugin-barcode

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magneds/hapi-plugin-barcode

Bar-/QRCode creation endpoints for Hapi

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Hapi Barcode Plugin

Generate bar-/QR codes on the fly from a webserver running Hapi

Installation

$ npm install --save @magneds/hapi-plugin-barcode

Usage

As the name might have suggested already, this package is a plugin for the Hapi framework, simply registering the package as plugin will suffice.

Using @magneds/hapi-server

const HapiServer = require('@magneds/node-hapi-server');
const HapiPluginBarcode = require('@magneds/hapi-plugin-barcode');

new HapiServer()
	.configure({ host: 'localhost', port: 3000 })
	.plugin(HapiPluginBarcode)
	.start()
	.then(() => console.log(`Running @${server.info.uri}`));

Using hapi

const Hapi = require('hapi');
const HapiPluginBarcode = require('@magneds/hapi-plugin-barcode');

const server = Hapi.server({ host: 'localhost', port: 3000 });

const init = async () => {
	await server.register(HapiPluginBarcode);
	await server.start();

	console.log(`Running @${server.info.uri}`);
};

init();

API

The barcode plugin registers two routes to do all the heavy lifting, for the examples below we'll assume the routes are not prefixed to reside in another location.

/barcode/qr/{content}

Generate a QR code with the data provided in {content}. Note that as the content is part of the path, the data must be properly url encoded (e.g. using JavaScript encodeURIComponent, PHP urlencode, or the equivalent in your favorite language)

http://localhost:3000/barcode/qr/hello%20world
Parameters

There are several settings that can be overridden, all of these can be provided as query parameters.

http://localhost:3000/barcode/qr/hello%20world?background=%23f90&color=red&width=1000&ecl=Q
optiondefaultdescriptionnote
padding4white space padding0 for no padding
width256width in pixelsif no height is specified, it will be set to width
height256height in pixelsif no width is specified, it will be set to height
colorcurrentColorforeground colorany valid CSS color value (remember # has a special meaning in URLs so it must be escaped (%23))
backgroundtransparentbackground colorany valid CSS color value (remember # has a special meaning in URLs so it must be escaped (%23))
eclHerror correction levelL, M, H, Q

/barcode/{type}/{content}

Generate a barcode of {type} with the specified data provided in {content}

Valid types
typedescription
codabarCodabar
code11Code 11
code39Code 39
code93Code 93
code128Code 128
ean8EAN 8
ean13EAN 13 (International Article Number)
std25Standard 2 of 5 (Industrial 2 of 5)
int25Interleaved 2 of 5

Specifying any invalid type will result in a 404 - Type "${type}" not found response

Parameters

There are several settings that can be overridden, all of these can be provided as query parameters.

http://localhost:3000/barcode/code39/123456789098?height=30&color=red
optiondefaultdescriptionnote
width160width in pixels
height50(bar) height in pixels
colorcurrentColorforeground colorany valid CSS color value (remember # has a special meaning in URLs so it must be escaped (%23))
backgroundtransparentbackground colorany valid CSS color value (remember # has a special meaning in URLs so it must be escaped (%23))
textfalseinclude the code as textnot as pretty as one might expect

FAQs

Package last updated on 28 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc