0.2.0 • Published 7 years ago

@sealsystems/short-id v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

@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