teth-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.12 • Public • Published

环境要求

  1. 建议node >= 12.16

使用

npm install teth-sdk

add teth.config.ts

import {TethConfig} from 'teth-sdk';

module.exports = {
    // 平台申请的app的英文名称
    appName: 'test',

    // 平台的该app的密钥
    appSecret: 'xxxxxx',

    // 该服务所在实例,默认os.hostname()
    // 当处于服务发现模式时,该实例ID需要和服务发现获取的实例ID保持一致,否则会被忽略掉
    instanceId: require('os').hostname(),

    // 该服务所在实例的地区或机房,默认default
    region: 'default',

    // 外部访问实例的host:机器+端口
    // accessUrl: '127.0.0.1:' + port,

    // 指标采集时,流量指标默认有一个维度uri,其值是请求path
    // 但是有时候path的取值个数会有几百上千种,特别是无效流量path。
    // 为了避免维度爆炸或者避免无效流量采集而带来内存占用,在此对uri的取值
    uriAdjust(uriPath: string) {
        // 根据app来转换uri维度
        // /app/index : 保留原样 /app/index
        // /app/auth.tar: 变成 /all_static
        // /Application/xxxx : 变成 /other-request
        if (uriPath.startsWith('/app')) {
            // 静态资源请求
            if (uriPath.includes('.')) {
                return '/all_static';
            }
            return uriPath;
        }
        return '/all_other_request';
    },

    packageDir: __dirname,

    // logPaths: [
    //     'log/xxxxx'
    // ],
} as TethConfig;

import sdk

import teth from 'teth-sdk';

teth.start({
    // 配置文件路径
    configPath: require.resolve('./teth.config'),
});

研发

开发

# 进行watch 编译,产出到dist
npm run dev

# lint
npm run lint

开发注意

  1. 记得对example进行压测 / cpu profile分析,以确定本次升级修改前后是否有性能退化
  2. 禁止使用moment等库

测试

# npm run test

# production编译,产出到dist
npm run build

发布npm包

### 1. lint and build
git pull origin master --rebase
rm -fr dist && npm run lint && npm run build && npm run test
git commit -m "fix/feature: xxx"

### 2. 增加版本号,生成commit和tag ,示例是小版本, 请按照当时具体情况修改版本号,如果版本修改不符合预期,那就人工修改
npm version patch

### 3. 先git commit 本次提交
git add .
version=`node -e "console.log(require('./package.json').version)"`
git commit -m "release ${version}"
git tag "v${version}"

### 4. 构建产出到dist目录,并发布到npm
rm -fr dist && npm run build && npm publish

### 5. 发起CR评审
git push origin HEAD:refs/for/master
git clone

git branch -b new_feature

git commit -m "icafe ID + feature描述"

git push origin HEAD:refs/for/master

Readme

Keywords

none

Package Sidebar

Install

npm i teth-sdk

Weekly Downloads

3

Version

1.0.12

License

none

Unpacked Size

340 kB

Total Files

64

Last publish

Collaborators

  • cxtom
  • kaivean
  • zhaolongfei