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

yuntun-api-auth

v0.0.4

Published

```js roles: { // admin SUPER_ADMIN: {corp_id: 'yuntun', role_id: 'super_admin'}, // 可分配系统权限、配置系统全局变量、用户数据最高权限、公司数据最高权限 GENERAL_ADMIN: {corp_id: 'yuntun', role_id: 'general_admin'}, // 管理员角色可以为其他公司分配系统权限、配置系统全局变量、用户数据最高权限 THIRDPART_ADMIN:

Downloads

10

Readme

ROLES

roles: {
    // admin
    SUPER_ADMIN: {corp_id: 'yuntun', role_id: 'super_admin'}, // 可分配系统权限、配置系统全局变量、用户数据最高权限、公司数据最高权限
    GENERAL_ADMIN: {corp_id: 'yuntun', role_id: 'general_admin'}, // 管理员角色可以为其他公司分配系统权限、配置系统全局变量、用户数据最高权限
    THIRDPART_ADMIN: {corp_id: 'corp_id', role_id: 'thirdpart_admin'}, // 第三方管理员角色可以为其公司分配系统权限、配置系统变量、其公司员工数据的最高权限
    // yuntun user
    YUNTUN_GENERAL_USER: {corp_id: 'yuntun', role_id: 'general_user'}, // 云吞普通已注册用户,可以线上使用云吞提供的资源、服务
    YUNTUN_VIP_USER: {corp_id: 'yuntun', role_id: 'vip_user'}, // 云吞付费用户,可以线上、线下使用云吞提供的资源、服务
    YUNTUN_ANONYMOUS_USER: {corp_id: 'yuntun', role_id: 'anonymous_user'}, // 云吞匿名用户,只通过微信登陆,未绑定手机号的用户,该部分用户只能查看线上云吞提供的基础页面
    // thirdpart user
    THIRDPART_GENERAL_USER: {corp: 'corp_id', role_id: 'general_user'}, // 第三方公司的普通用户(一般是微信用户)
    THIRDPART_VIP_USER: {corp: 'corp_id', role_id: 'vip_user'}, // 根据第三方公司的实际业务,赋予使用第三方业务管理的权限,可发起活动、收集活动数据
    THIRDPART_ANONYMOUS_USER: {corp: 'corp_id', role_id: 'anonymous_user'} // 根据第三方业务的实际情况,设置,不作处理权限同 普通用户
}

ROUTER

// 绑定手机号及相关标志(设备,用户等信息)
{
    method: 'GET', path: '/bind_phone',
    config: {
        auth: false,
        description: '绑定手机号及相关标志(设备,用户等信息)',
        tags: ['api', 'auth'],
        validate: {
            query: Joi.object({
                phone: Joi.string().required(),
                sid: Joi.string().required().description(`
                For now, sid = 'webglVendorAndRenderer', created when phone entered, and btn bind_phone clicked, used to limit invoke times`),
                unionid: Joi.string().optional(),
            }).unknown()
        },
    },
    handler: async (request, h) => {
        const result = {
            code: 0 | -1,
            msg: '',
        };
        return h.response(result);
    },
},
// 验证短信验证码登录
{
    method: 'GET', path: '/login',
    config: {
        auth: false,
        description: '验证短信验证码登录',
        tags: ['api', 'auth'],
        validate: {
            query: Joi.object({
                phone: Joi.string().required(),
                code: Joi.string().required(),
                sid: Joi.string().required().description(`sid = 'webglVendorAndRenderer'`),
                unionid: Joi.string().optional(),
            }).unknown()
        },
    },
    handler: async (request, h) => {
        // TODO: 数据库user表中根据手机号获取用户信息,无则插入一条新数据,uid根据phone生成md5值
        const result = {
            code: 0 | -1,
            msg: '',
            data: 'jwt token', // jwt token info include user info exlcude passwd, client used to store in cookie.
        };
        return h.response(result);
    },
},
// 根据unionid、uid、phone获取用户信息
{
    method: 'GET', path: '/userinfo',
    config: {
        auth: false,
        description: '根据unionid、uid、phone获取用户信息',
        tags: ['api', 'auth'],
        validate: {
            query: Joi.object({
                phone: Joi.string().optional(),
                uid: Joi.string().optional(),
                unionid: Joi.string().optional(),
            }).xor('phone', 'uid', 'unionid')
        }
    },
    handler: async (request, h) => {
        // TODO: users.findOne({ $or: [ {phone}, {uid}, {unionid} ] }, ['-_id', '-passwd']);
        const result = {
            code: 0 | -1,
            msg: '',
            data: 'user data', // jwt token info include user info exlcude passwd, client used to store in cookie.
        };
        return h.response(result);
    }
},
//

Configuration

add into .env file

# NODE_ENV
NODE_ENV=dev

# SERVER_INFO
SERVER_HOST=0.0.0.0
SERVER_PORT=7777

# Redis
RD_HOST=10.1.1.149
RD_PORT=6379

# Mongo
DB_HOST=10.1.1.149
DB_PORT=22001
DB_NAME=yuntun_dev

# YUNTUN
YUNTUN_APP_ID=wxb091d7e1d35bb77a
YUNTUN_APP_SECRET=3cc5f7e1c8bd4785a1edf5e93a47bba1
YUNTUN_PAY_SECRET=12387652323

# ALI 自行在阿里云上注册
ACCESS_KEY_ID=
ACCESS_KEY_SECRET=
OSS_BUCKET_NAME=