seal-short-id

Creates short human readable job id.

Usage no npm install needed!

<script type="module">
  import sealShortId from 'https://cdn.skypack.dev/seal-short-id';
</script>

README

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