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

@nsrd/neuq-request-js

v0.0.2

Published

a wrapper of axios for NeuqSoft RD Gateway.

Downloads

1

Readme

Neuq Request

Neuq Request 为基于 axios河北东软统一服务网关 的 JS 网络请求实现。

使用

  1. 引用

    import { NeuqRequest, SIGN_TYPE, ENCRYPT_TYPE } from "@nsrd/neuq-request";
  2. 创建实例

    const http = NeuqRequest(options<Object>);

    实例选项 options:

    • baseURL<String> 根地址,选填项,默认值 /
    • timeout<String>,网络请求超时时间,单位毫秒,选填项,默认值 6000
    • headers<Object>,请求头,选填项,默认值 {}
    • requestInterceptor<Function(config<Object>)>,请求拦截器,选填项,请参考 Aixos request interceptor
    • responseSuccessInterceptor<Function(response<Object>)>,响应成功拦截器,选填项,请参考 Aixos response interceptor
    • responseFailInterceptor<Function(error<Object>)>,响应失败拦截器,选填项,请参考 Aixos response interceptor
    • securityGateway<Object>,安全网关选项,选填项

    以使用 SM2 签名、SM4 加密方式构造请求实例:

    const http = NeuqRequest({
      baseURL: "/",
      timeout: 10 * 1000,
      headers: {
        "Content-Type": "application/json"
      },
      requestInterceptor: function(config) {
        return config;
      },
      responseSuccessInterceptor: function(response) {
        return Promise.resolve(JSON.parse(response.data.body));
      },
      responseFailInterceptor: function(error) {
        return error.response;
      },
      securityGateway: {
        appId: "DemoSM2",
        signType: SIGN_TYPE.SM2,
        encryptType: ENCRYPT_TYPE.SM4,
        appSignPrivateKey: "",
        appSignPublicKey: "",
        encryptKey: "",
        platformPublicKey: ""
      }
    });
  3. 网络请求

    当前只支持 POST/DELETE/PUT/GET 四种求情方式。

    • post http.post(config<Object>)
    • delete http.delete(config<Object>)
    • put http.put(config<Object>)
    • get http.get(config<Object>)

    选项 config,与 Axios request config 一致。

    以使用 SM2 签名、SM4 加密方式构造的请求实例发送 post 请求:

    http
     .post({
       url: "gateway-request/demo/mock/390/json",
       data: {
         bizNo: "GO20300258433171456"
       }
     })
     .then(res => {
       console.log("handleSM2SM4PostRequest", res);
     })
     .catch(err => {
       console.error("handleSM2SM4PostRequest", err);
     })
     .finally(() => {});

内置签名与加密工具

import { sm, rsa } from "@nsrd/neuq-request";
  1. sm2 签名 sm.sm2.signature(message, appSignPrivateKey, appSignPublicKey, appId);
  2. sm4 加密 sm.sm4.encrypt(message, encryptKey);
  3. sm4 解密 sm.sm4.decrypt(message, encryptKey);
  4. rsa 签名 rsa.signature(message, appSignPrivateKey, rsa.alg.SHA256withRSA);

更新计划

  1. 测试
  2. 支持文件上传
  3. 支持加密算法 RSA

如有异常需求,请联系 huangrx