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

@zeesuu/service

v1.0.12

Published

compile API settings to service function

Downloads

2

Readme

@zeesuu/service

将特定格式的 API 配置,转成能够直接使用的 Service.

并挂载在 Vue.prototype.$service 下

请求对象挂在 Vue.prototype.$http 下

Usage

// main.js
import ZeesuuService from ' @zeesuu/service';

// 配置
Vue.use(ZeesuuService, {
  $http: axios, //自己封装好的请求对象

  apis: [
    // 格式为: apiUrl | method | alias
    // apiUrl 为必填, method 不填时默认为get, alias 选填
    '/user/login|post|UserLoginFunction',

    // 默认get 方法
    '/user/info',

    // 这个例子只有apiUrl和alias,method部分默认为get,但是要给到两个竖线作为分隔
    '/user/list||AllUserList',

    // 这个例子适合RESTful的url设计
    '/video/upload/(id)/delete/(pid)|post',

    // 这个例子适合配置其他域名下的请求地址
    'http://www.xyz.com/aaa/bbb',
    'https://www.xyz.com/ccc/ddd',
  ],

  // optional setting, default as '' and the root of request will use $http's setting
  appRoot: 'http://www.xyz.com/',

  // optional setting, default as false, 看看是不是小程序
  isMini: true,

  // 打开调试,可以显示所有已经转换的service
  debug: true,
});
// other.js or vue file

const options = {};

// 上面的配置会直接生成下列 service
// 无参数
this.$service.UserLoginFunction();
this.$service.UserInfo({}, options);

// 有参数直接传
this.$service.AllUserList({
  page: 0,
  size: 10,
});

// 由RESTful地址转变来的service如果不传参数会报错
this.$service.VideoUploadDelete(
  {
    id: 1,
    pid: 2000,
  },
  options,
);

// 完整的请求地址, 以协议开头,后面接实际路径,实际路径的解析同上
this.$service.HttpAaaBbb();
this.$service.HttpsCccDdd(); // HTTPS请求

// 独立使用请求对象
this.$http.get('url');