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

kenote-config-helper

v1.0.11

Published

configuration helper.

Downloads

17

Readme

config-helper

Configuration helper

NPM Version NPM Downloads Build Status Gratipay

Installation

$ npm install kenote-config-helper
# Or
$ yarn add kenote-config-helper

Usages

Create Channel

/data/channels/account.yml

---
# 频道 我的帐户 配置 ####################################################################
######################################################################################

# 频道 ID
id            : 1
# 频道名称
name          : 我的帐户
# 频道标识
label         : account
# 频道描述
description   : 查看和管理自己的信息、活动、安全选项和隐私偏好设置
# 默认打开页面
default       : /account/baseinfo
# 自定义参数
options:
  # 用户方案类型
  plan_type:
    - key           : ditch
      name          : 渠道
    - key           : sendmail
      name          : 系统邮件
# 频道导航
navs:
  # 导航分栏 -- 帐户管理
  - index         : 1-1
    name          : 帐户管理
    icon          : iconfont icon-passport
    children:
      - index         : /account/baseinfo
        name          : 基本资料
      - index         : /account/security
        name          : 安全设置
      - index         : /account/plan
        name          : 方案管理

app.ts

import { KenoteConfig, Channel, getChannelId } from 'kenote-config-helper'
import { loadData } from 'kenote-config-helper/dist/utils.server'

const channels: KenoteConfig.Channel[] = <KenoteConfig.Channel[]> loadData('data/channels', 'array')

const channelId: number = getChannelId('/account/baseinfo')
const channel: KenoteConfig.Channel | undefined = channels.find( _channel => _channel.id === channelId )

if (channel) {
  let nav: Navigation = new Channel(channel).find('/account/baseinfo')
  /** value for nav
   * {
   *   index  : '/account/baseinfo',
   *   name   : '基本资料'
   * }
   **/
}

Use Error Set

import { useError, Maps } from 'kenote-config-helper'

const code: Maps<number> = {
  ERROR_STATUS_NULL                : 0,
  ERROR_AUTH_FLAG_ACCESS           : 1001
}
const message: Maps<string> = {
  ERROR_STATUS_NULL                : 'Request Success!',
  ERROR_AUTH_FLAG_ACCESS           : '没有访问该页面的权限'
}
const start: number = 1000

const { __ErrorCode, __ErrorMessage, ErrorInfo } = useError(code, message, start)

// thrown custom error
throw ErrorInfo(__ErrorCode.ERROR_AUTH_FLAG_ACCESS)

// handing errors
try {
  // ...
} catch (error) {
  if (CustomError(error)) {
    // custom error
  }
  else {
    // system error
  }
}

License

this repo is released under the MIT License.