seal-short-id

0.1.6 • Public • Published

seal-short-id

CircleCI AppVeyor

Create a short human readable id of type string. This is done by concatenating two hash values. The first hash value is a static prefix build of the current data center name determined via seal-consul module. The second hash is build of a counter read from MongoDB by seal-counter-storage module.

Installation

$ npm install seal-short-id

Quick start

First you need to integrate seal-short-id into your application.

const shortId = require('seal-short-id');

Get A Handler Object

Use the required function to get a short id handler. The first parameter of shortId is an options object which has to contain already connected seal-consul and seal-counter-storage objects as properties. The second parameter is a callback with error and handler object as parameter.

shortId({
  consul,
  counterStorage
}, (err, shortIdHandler) => {
...
});

Get Id's

Call the handlers next function for each id you want. Only parameter is a callback function with error and the next id as parameter.

shortIdHandler.next((err, id) => {
...
});

Running the build

To build this module use roboter.

$ bot

Readme

Keywords

none

Package Sidebar

Install

npm i seal-short-id

Weekly Downloads

0

Version

0.1.6

License

MIT

Last publish

Collaborators

  • manni19682