@flatfile/id
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Flatfile's Public ID Generator

This package provides a re-useable @flatfile/id generator that should be used in all places where a public id is provided. This ensures that we can evolve our ID standard over time with consistency.

process.env.REGION will be prepended to the ID if it's available.

Structure

[{region}_]{model}_{id}

Usage

// default usage
makeId('acc') // => acc_G23hs0hd90Ij6D4f

// with a region
process.env.REGION = 'us0'
makeId('acc') // => us0_acc_ijsS89072Es0hd90

// modifying the environment variable describing default length
process.env.DEFAULT_ID_LENGTH = '32'
makeId('acc') // => acc_yBcGHc61lGdWjgnEtZqSvWDpQdqaN9tu

// passing a custom id length
makeId('acc', 8) // => acc_4hkFm3CJ

// passing a length under 8
makeId('acc', 5) // => throw Error("The length passed to makeId() must be >= 8")

Readme

Keywords

none

Package Sidebar

Install

npm i @flatfile/id

Weekly Downloads

721

Version

1.0.0

License

ISC

Unpacked Size

7.13 kB

Total Files

10

Last publish

Collaborators

  • sambarrowclough
  • carlbrugger
  • hansjhoffman
  • haleymt
  • mmccooyyy
  • ahollenbeck
  • maerf0x0
  • rjhyde
  • mpoythress
  • flatderek
  • ashleygmulligan
  • alnoor
  • flatfilecolin
  • bigcountrycrane
  • flatfileinfra
  • bangarang
  • madmandrit
  • roberto-alcantara-ffile
  • mairechew
  • jmmander
  • srmotter
  • driscollrp
  • sarocu
  • dboskovic
  • brentkulwicki
  • nate.ferrero
  • jaredwalters