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

aos-entity

v1.0.5

Published

restfulApi remote Data and do callback operation,store data cache,remember operation,auth logic

Downloads

5

Readme

##activityApi Model##

Entity 构建生成

npm install

gulp build --env qa 测试环境 debug模式
gulp build --env pro 产线版本
gulp build --env dev dev 环境 debug模式

生成dist目录 Entity.js

env 环境

prod
qa
dev

支持 api 请求 回调函数

  auth
  login
  activity
  signUp
  reached
  gifts
  draw
  energy
  user
  ecg
  healthservice

  [api detail]

       `auth h5 页面 entity初始化`
        Window.baseApi.setConfig({
           userId:'876382025',
           appId:'10400203',
           security:'2gTO2MDN2gDNxYCMEhTQ0gzNClTMzkTL0IUO00yMCJDOtMkQGRTLzgTMFZDMwkjJ1IDMygzM2cDO'
        });

        `h5 页面auth 获取`
        Window.Entity.auth.fetch(suc,fail)

        `本地auth` 获取
        console.log(Window.baseApi.getLocalAuthorization())


        `后台管理系统登录初始化`
        Window.baseApi.setConfig({
           appId:'20100101', 
           userId:'',
           security:''
        });

        `登录接口`
        Window.Entity.login.fetch(suc,fail)

        `华米医疗接口`
        Window.Entity.medical.fetch(data,suc,fail)
        Window.Entity.medical.detail(data,suc,fail)

        `小米运动训练中心健康接口`
        Window.Entity.healthservice.detail(data,suc,fail)


        [活动类接口]
        
            `抽奖`
            Window.Entity.draw.fetch(suc,fail)

            `用户信息接口`
            Window.Entity.user.fetch(suc,fail)

            `活动接口`
            Window.Entity.activity.fetch(suc,fail)

            `奖品接口`
            Window.Entity.gifts.fetch(suc,fail)

            `报名`
            Window.Entity.signUp.fetch(suc,fail)

            `达标`
            Window.Entity.reached.fetch(suc,fail)

  baseApi 基础类

  支持 amd cmd

auth (baseApi.prototype.auth) --- baseApi 基础类方法

  `Entity.reached.auth(callBackSuccess,callBackFail)`
  `Entity.gifts.auth(callBackSuccess,callBackFail)`

  Entity.auth.fetch(callBackSuccess,callBackFail)

get activity restful request

  `Entity.reached.fetch(callBackSuccess,callBackFail)`
  .....
  `Entity.gifts.fetch(callBackSuccess,callBackFail)`
  .....
  `Entity.signUp.fetch(callBackSuccess,callBackFail)`
  .....
  `Entity.user.fetch(callBackSuccess,callBackFail)`
  .....
  `Entity.activity.fetch(callBackSuccess,callBackFail)`

缓存结果集

  baseApi.request 静态
  baseApi.joinIn 静态
  Window.baseApi.getLocalAuthorization() 获取本地auth

组件初始化

  baseApi.setConfig(config);

   config{
     appId; 设置活动id
     userid; 设置用户id
     security; 设置秘钥
   }

记录操作

  baseApi.hasReqApiErrList 记录获取数据失败的操作列表 静态

    exp: 
      [
        ["activity",callBackSuccess,callBackFail],
        ["reached",callBackSuccess,callBackFail],
        ["user",callBackSuccess,callBackFail]
      ]


  baseApi.hasReqApiErrMap 记录获取数据失败操作列表 map对象

    exp: 
      {
        activity : ["activity",callBackSuccess,callBackFail],
        reached : ["reached",callBackSuccess,callBackFail],
        user : ["user",callBackSuccess,callBackFail]
      }

  baseApi.hasReqApiList 记录获取数据成功操作的方法列表 静态
     exp: ["activity", "user", "reached"]

entity 用于各个接口apiModel的配置,初始化; 继承于 baseApi

活动,用户基础数据

app_key
key
token
auth

baseApi.getCommonParams()

Entity.auth.getUser()

do_Operation 重新发起请求

exp: 
   Entity.activity.do_Operation(["activity",callBackSuccess,callBackFail])

   Entity.activity.do_Operation(baseApi.hasReqApiErrList.pop())


互斥登录异常处理,重新发起上一次请求
auth成功后 发起 hasReqApiErrList 队列中未成功的最后一条操作

其他失败操作 自行调用 以防触发不必要的回调函数破坏现有逻辑

暂时使用 Window.baseApi Window.Entity