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

@xsyx/easy-api-mp

v0.1.0

Published

1. 在 modules 中配置接口基本信息 - url 接口地址 - method 请求方式 - 更多配置 ```javascript export default { // 一个简单的url 配置 'fetchSomeData': { // 完整的访问方法名 url: "/sample/data/normal", // 请

Downloads

2

Readme

api 使用手册

  1. 在 modules 中配置接口基本信息
    • url 接口地址
    • method 请求方式
    • 更多配置
        export default {
            // 一个简单的url 配置
            'fetchSomeData': {
                 // 完整的访问方法名
                 url: "/sample/data/normal", // 请求的地址(必填)
                 mockUrl: "/mock/data/normal", // mock 地址(可选项)
                 mockData: { rspCode: "success", data: [] }, // 静态 mock 数据
                 cached: "5000", // 表示接口在多久以内,缓存临时数据(可选项)
                 sensitive: "11", // 灵敏期,在这个时间段内,不会走缓存
                 method: "POST", // 请求方法 post get(可选项)
                 concurrency: false, // 是否允许并发(可选项)
                 mock: false, // 是否访问mock(可选项)
                 fit: (rsp, params) => {
                   // 拦截返回数据格式化
                   return rsp;
                 },
                 repeat: 3, // 重试次数
                 feed: (rsp, params)=>{ // 补偿机制,如果重试无效,则进入兜底返回
                     // 补偿机制
                 }
            }
        }
  2. 在 api.js 中注册对应的模块,同时导出。
    • 导出的变量名,既是最终使用时调用的名字。
    • 如: api.brandHouse.fetch1(params, options)
    • 其中 brandHouse 就是 模块名
    • params 就是接口本次带的参数
    • options 包含如下两个参数
    • loading false string|bool|object 如果为 object ,则完整支持 wx.showLoading(object)
    • silence false bool 是否在出错的时候静默

tips: 注册 toast / loading 插件

如果运行环境在 web 中, 则可以通过如下两个方法注册对应的插件,用以展示吐司消息和loading请求动画

  • registerToastPlugin( callback[toastConfig] )
  • registerLoadingPlugin( callback[loadingConfig] )