@sealsystems/short-id

Creates short human readable job id.

Usage no npm install needed!

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

README

@sealsystems/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 @sealsystems/consul module. The second hash is built of a counter read from MongoDB by the @sealsystems/counter-storage module.

Installation

$ npm install @sealsystems/short-id

Quick start

First you need to integrate @sealsystems/short-id into your application:

const shortId = require('@sealsystems/short-id');

Get a handler object

Use the required function to get a short id handler. As parameter of shortId provide an options object which has to contain already connected @sealsystems/consul and @sealsystems/counter-storage objects as properties:

const shortIdHandler = await shortId({ consul, counterStorage });

Get ids

Call the handler's next function for each id you want:

const id = await shortIdHandler.next();

Running the build

To build this module use roboter.

$ bot