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

auto-axios

v1.0.3

Published

auto config axios with map

Downloads

13

Readme

简介

使用 ts 对 axios 进行封装,并提供了详尽的ts类型。

使用

yarn add auto-axios 或者 npm i auto-axios

配置化 axios

详见 配置表说明

  • 约定的返回
  • 请求可去重
  • 请求重复错误弹框可控制
  • 请求参数空数据自动处理
  • 配置化 axios
  • 错误码 可配置开关
  • 错误消息 可配置开关
  • 请求等待层 可配置开关
  • 请求等待层 可配置开关

配置表

interface IAutoRequestCfg {
    REQ_CONST: {
        BaseUrl: string,
        LoginExpiredCode: Array<number|string>, // 会话超时错误码集合
        RetSucCode: Array<number|string>, // 返回成功码集合
        LoginUrl: string, // login请求的 path部分
        AuthOperationUrl?: '', // 获取 csrftoken值的请求url

        Timeout?: number, // m * s
        DefaultLang?: string,
        MaskClassNames?: Array<string>,
    }
    REQ_SWITCH?: {
        GetErrMsgWay?: "byMap"|"byRes", // 错误消息来源
        GlobalErrMsgSwitch?: TSwitch, // 全局错误消息 提示开关; 1 开启; 0 关闭
        GlobalLoadingSwitch?: TSwitch, // 全局等待层 开关; 1 开启; 0 关闭
        IfCancelDupReq?: TSwitch, // 是否取消重复请求; 1 取消重复请求; 0 不取消
    },
    RET_FIELDS_CFG: {
        RetCode: string, // 返回码字段
        RetMsg: string,
        RetData: string,
        RetCount: string, // 列表查询条数 统计字段
        TokenStorageKey: string, // token字段在 Storage 里面的 key
        TokenHttpKey: string, //  token字段在 http请求 里面的 key

        LangStorageKey: string, // 存储 里的 语言字段 key
        LangHttpKey?: string, // 发送给后台的 语言字段
    },
    REQ_WAYS_CFG?: {
        DefaultWay?: 'post' | 'get' | 'delete' | 'put', // 默认请求方法
        DefaultHeader?: IObjAny,
    },
    showTipBox(
        retMsg?: string,
        retCode?: string | number,
        statusCode?: string | number,
        response?: IRespConfig|AxiosResponse,
    ): void; // 错误弹框 回调
    // 返回 loadService 对象需要提供 closeLoadMask() + showLoadMask() 方法
    getLoadService?: () => ILoad; // getLoadService: (): ILoad => ({ showLoadMask, closeLoadMask })
    beforeReq?: (config:AxiosRequestConfig) => void; //  请求前最后可直接修改 config的入口
}