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

@ahao430/sdk-demo

v1.0.1

Published

## 开发

Downloads

4

Readme

sdk-demo

开发

安装依赖

cd到项目目录,npm run dev开发,同时npm start运行demo

npm run build打包

发布

npm publish --access public

遇到的问题:

  1. 需要设置npm源为npm。nrm use npm
  2. 去npm注册,npm login命令登录
  3. invalid name。monorepo命名为@name/package,会被当做私有,在发布命令后面加上--access public
  4. bug。package.json的name中,@后面的名字必须是刚刚登录的用户名
  5. 发布时版本号必须升高
  6. 发布时不能有暂存的改动

项目中安装和使用

npm install -S @ahao430/sdk-demo

刚发布,npm源改回npm

nvm use v16

yarn

// h5使用,main.js引用
import sdk from '@ahao430/sdk-demo/dist/index.js'

sdk.debug = true
sdk.setStore({
  appId: 'xxx',
  env: 'dev',
}})
console.log(sdk)

sdk.a.getList(params, options)
// 小程序使用. app.js引用
import sdk from '@ahao430/sdk-demo/dist/zfb.js'

sdk.debug = true
sdk.setStore({
  appId: 'xxx',
  env: 'dev',
}})

console.log(sdk)

sdk.a.getList(params, options)

store参数

  • env 环境变量,控制接口域名环境
  • debug 调试,是否打印更多信息
  • appId,应用的appId,注入到接口
  • uid,支付宝uid,注入到接口,h5需要
  • authCode,支付宝小程序authCode,小程序自动获取

接口参数

sdk.[module].[api](params, options) 第一个参数是接口参数对象,如果是get请求就是query参数;如果是post请求是body参数,如果post请求还有url参数,可以在options.params写 第二个请求是参数对象,包含一些自定义参数,还有一些通用的参数,如headers等等。

扶摇接口现在在拦截器统一加密放到headers。

h5使用axios,小程序使用my.request,但是做了抹平操作。