https://github.com/yeliex/snowflake
server to generate uniq-id with twitter-snowflake arithmetic
https://github.com/yeliex/snowflake
docker idgenerator nodejs snowflake
Last synced: about 1 year ago
JSON representation
server to generate uniq-id with twitter-snowflake arithmetic
- Host: GitHub
- URL: https://github.com/yeliex/snowflake
- Owner: yeliex
- License: mit
- Created: 2018-07-20T01:52:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-11T07:01:10.000Z (about 3 years ago)
- Last Synced: 2024-10-01T10:18:58.173Z (over 1 year ago)
- Topics: docker, idgenerator, nodejs, snowflake
- Language: TypeScript
- Homepage: https://id.yeliex.com
- Size: 450 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# snowflake
server to generate uniq-id with twitter-snowflake arithmetic



### Usage
```bash
$ 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
```bash
$ 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
```bash
# 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`