Skip to content

server to generate uniq-id with twitter-snowflake arithmetic

License

Notifications You must be signed in to change notification settings

yeliex/snowflake

Repository files navigation

snowflake

server to generate uniq-id with twitter-snowflake arithmetic

https://hub.docker.com/r/yeliex/snowflake/ https://hub.docker.com/r/yeliex/snowflake/ https://npmjs.org/package/@yeliex/snowflake

Usage

$ docker run -p 3000:3000 --name snowflake yeliex/snowflake
$ curl localhost:3000
# or
$ curl localhost:3000?type=json
# or
$ curl -H "Accept: application/json" localhost:3000

Authorization

$ docker run -p 3000:3000 --name snowflake -v ./config:/snowflake/config yeliex/snowflake

# config/config.yml
security:
  token:
    - token1
    - token2
    
$ curl -H "X-TOKEN: token1" localhost:3000
# OR
$ curl localhost:3000?token=token1

Configuration

  • production: /snowflake/config.yml
  • development: ./config/config.yml
# Server base
server:
  listenPort: 3000

snowflake:
  region: 1
  worker: 1
  endpoint: 1 # replace region and worker

security:
  token: # if empty, run without auth
    - token1
    - token2

api

ALL /_health

health check

GET /

gen id

Return json

/?type=json OR header Accept: application/json

Auth

/?token=token OR header X-Token: token