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

@qiov/node-inc

v0.23.0

Published

incubator common modules for node

Downloads

6

Readme

incubator common modules for node

[TOC] incubator公共模块,提供incubator体系下用户管理、日志管理、授权登录等模块的能力

refresh token机制

如果一直处于操作中,incubator支持维持登录态,在登录态即将过期时刷新有效期。

原理

如果在过期前一段时间用户有操作,在调用center接口时, 1、增加请求头——

'need-refresh-token': 1

2、请求返回时会添加响应头——

'incubator-refresh-token': 'a4268c96-8a11-407e-b9a5-b1a7ac047929'

3、将用户session中的原token更新为新的token即可

node sdk实现方式:

需要配合fbi-project-incubator项目模板使用,在poxyCenterRoutes中定义的路由,按需添加updateSession方法即可。如:

router.post('/api/auth/islogin', async (ctx) => {
  let res: any = ctx.session && !!ctx.session.token
  if (res) {
    res = await this.isLogin(ctx.session.token)
    this.updateSession(res, ctx)
    ctx.body = resReturn(res.data, res.code)
  } else {
    ctx.body = resReturn(res)
  }
})

单测执行须知

sdk接口规范文档可能会因为更新不及时,存在与当前版本的接口不一致的地方,这种不一致会造成子应用通过sdk调用center服务的时候出现异常。为了能快速找出文档与接口的不一致,可以通过执行单元测试来发现。具体执行步骤如下:

  • incubator-center项目切换到已发布的最新版本,启动本地的center服务

  • 打开http://127.0.0.1:8081,用平台管理员身份登录,抓包api/auth/getUser获取token和id

  • 修改tests/inc.config.ts中部分参数,其中iamTokenuserId来源于上一步

    {
      // 本地环境
      appId: '46444645', 
      appSecret: 'd1b040e1-0dc1-4b8b-8812-297585daf101',
      incServer: 'http://127.0.0.1:8080',
      iamToken: 'a9b3545b-f799-4464-b921-fb3c08d6393e',
      userId: '144115205301725059', // 当前登录用户ID
      orgId: '100000000000000000000000', // center租户组织机构
    }
  • 执行单元测试npm run test。测试用例都是按照最新文档编写,下图体现了inc.org.getTreeById接口文档与实际不一致的情况

  • 根据上一步中未通过用例的提示,修改接口文档

参考