npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@magneds/hapi-plugin-barcode

v1.0.6

Published

Bar-/QRCode creation endpoints for Hapi

Downloads

7

Readme

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

| option | default | description | note | | ---------- | ------------ | ---------------------- | -------------------------------------------------------------------------------------------------- | | padding | 4 | white space padding | 0 for no padding | | width | 256 | width in pixels | if no height is specified, it will be set to width | | height | 256 | height in pixels | if no width is specified, it will be set to height | | color | currentColor | foreground color | any valid CSS color value (remember # has a special meaning in URLs so it must be escaped (%23)) | | background | transparent | background color | any valid CSS color value (remember # has a special meaning in URLs so it must be escaped (%23)) | | ecl | H | error correction level | L, M, H, Q |

/barcode/{type}/{content}

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

Valid types

| type | description | | ------- | --------------------------------------------------------------------------------------------------- | | codabar | Codabar | | code11 | Code 11 | | code39 | Code 39 | | code93 | Code 93 | | code128 | Code 128 | | ean8 | EAN 8 | | ean13 | EAN 13 (International Article Number) | | std25 | Standard 2 of 5 (Industrial 2 of 5) | | int25 | Interleaved 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

| option | default | description | note | | ---------- | ------------ | ------------------------ | -------------------------------------------------------------------------------------------------- | | width | 160 | width in pixels | | height | 50 | (bar) height in pixels | | color | currentColor | foreground color | any valid CSS color value (remember # has a special meaning in URLs so it must be escaped (%23)) | | background | transparent | background color | any valid CSS color value (remember # has a special meaning in URLs so it must be escaped (%23)) | | text | false | include the code as text | not as pretty as one might expect |