npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mmstudio/doccode

v3.0.7

Published

编码服务

Downloads

23

Readme

编码服务

Description

生成唯一全局编码。

编码配置均需要有前缀,同时前缀也作为编码的名称,即数据库中id字段值。该服务免配置,但也可以在数据库中对配置表进行修改.

注意

该服务不可部署多个实例

另外,由于该服务生成编号时为了保证生成的编号唯一,需要排队处理大量的并发请求,所以在使用中,请一定避免多次调用。

部署

  1. 生成配置表,根据实际部署情况修改
  2. 安装yarn add @mmstudio/doccode pg(pg for PostgreSQL, mysql for MySQL/MariaDB, sqlite3 for SQLite3, oracledb for Oracle, or mssql for MSSQL )
  3. 启动./node_moduels/.bin/mm-doccode

Useage

curl http://127.0.0.1:8890 -d 'name=foo'
# ["foo000001"]
curl http://127.0.0.1:8890 -d 'name=foo&num=1'
# ["foo000002"]
curl http://127.0.0.1:8890 -d 'name=foo&num=3'
# ["foo000003","foo000004","foo000005"]
curl http://127.0.0.1:8890 --header "Content-Type:application/json" -d '{"name":"foo","num":1}'
# ["foo000006"]
curl http://127.0.0.1:8890 -d 'name=20200204&num=10&len=3'
# ["20200204001","20200204002","20200204003","20200204004","20200204005","20200204006","20200204007","20200204008","20200204009","20200204010"]
curl http://127.0.0.1:8890 -d 'name=20200204&num=10&len=2'
# ["2020020401","2020020402","2020020403","2020020404","2020020405","2020020406","2020020407","2020020408","2020020409","2020020410"]

经以上调用之后,数据库表如下:

id | len | no ---|---|--- foo | 6 | 2 bar | 6 | 5 20200204 | 3 | 10 20200204 | 2 | 10

Configuration

mm.json

postgre

{
	"port": 8890,
	"dbconfig": {
		"client": "pg",
		"connection": "postgres://mmstudio:[email protected]:5432/mmstudio"
	}
}

mysql/mariadb

{
	"port": 8890,
	"dbconfig": {
		"client": "mysql",
		"connection": "mysql://mmstudio:[email protected]:3306/mmstudio?connectionLimit=5"
	}
}}

另外,也支持mssql,oracle,和sqlite。

log4js.json

{
	"appenders": {
		"out": {
			"type": "stdout"
		},
		"console": {
			"type": "console"
		},
		"dateFile": {
			"type": "dateFile",
			"filename": "./logs/mm.log",
			"maxLogSize": 10240000,
			"backups": 30
		}
	},
	"categories": {
		"default": {
			"appenders": [
				"console",
				"dateFile"
			],
			"level": "debug"
		}
	}
}

Table

字段名称|类型|说明 ---|---|--- id|text|关键字,如果配置表有该项,则使用该项配置,如没有,则自动创建,也作为前缀 len|smallint|编码长度,仅包含数字长度,不包含前缀长度,默认为6位 no|bigint|当前编号,自动创建时默认起始编号为1

docker-compose

docker-compose安置

[sudo] docker-compose -f db.yaml up

db.yaml

version: '3.7'

services:
  postgres:
    image: postgres
    container_name: postgres
    volumes:
      - /home/taoqf/data/postgre:/var/lib/postgresql/data
    restart: always
    environment:
      POSTGRES_DB: mmstudio
      POSTGRES_USER: mmstudio
      POSTGRES_PASSWORD: Mmstudio123
    ports:
      - 5432:5432

  adminer:
    container_name: adminer
    image: adminer
    restart: always
    ports:
      - 8080:8080
# networks:
#   default: