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

@shanghailz/lz-request

v0.1.0

Published

### 安装 ``` npm i --save ```

Downloads

2

Readme

lz-request:丽章 http 请求库

介绍

lz-request 包含了一组丽章后端通用的 api:

  • getTable:获取表格数据
  • getSubTable:获取子表数据
  • addRecords:添加记录
  • modifyRecords:修改记录
  • removeRecords:移除记录
  • clearCache:清除后端缓存
  • ...
/**
 * api.js 文件
 * */
import http from 'lz-request';
// ...
export default http;

// ===================================================

/**
 * example.js 文件:使用通用的 api
 * */
import http from './api';
// ...
let res;
try {
  // 使用通用 api getTable 来获取资源 id 为 5050505050 表的数据
  res = await http().getTable({
    resid: 5050505050
  });
} catch (err) {
  return console.error(err);
}
//...

以及一套扩展 特定项目的定制 api 的方法:

// 例如:在 powerworks 项目中,需要定义一个 api,来获取网页头部的提醒数量

/**
 * api.js 文件
 * */
import http from 'lz-request';

// 设置默认的基地址
http.setDefaultBaseURL('http://localhost:8080/');

// 设置默认的请求头
http.setDefaultHeaders({
  'Content-Type': 'application/json'
});

// 创建定制的获取提醒数量的 api,方法名为 'getReminderNum'
http.createApi('getReminderNum', {
  method: 'get',
  url: '/api/Resource/RetrieveReminderNum'
});

export default http;

// ===================================================

/**
 * 在 header.js 组件中使用
 * */
import http from './api';
// ...

let res;
try {
  // 使用在 api.js 文件中创造出来的定制 api:getReminderNum()
  res = await http().getReminderNum();
} catch (err) {
  return console.error(err);
}

//...

安装

npm i --save @powerworks/lz-request

通用设置方法

  1. http.setDefaultBaseURL

通用 api

  1. getTable(params):get 请求,获取表数据
await getTable({
  resid, // 资源 id:必填项
  subresid, // 子表资源 id
  cmswhere, // where 语句
  hostrecid, // 记录 REC_ID
  sortOrder, // 排序
  sortField, // 排序字段
  key, // 模块查询
  cmscolumns, // 主表按需要的字段返回数据,字段之间使用 "," 隔开
  getcolumninfo, // 是否返回字段定义:默认 '0',不返回字段定义;'1' 返回字段定义
  pageindex, // 分页页码:默认 0 ,不分页
  pagesize, // 分页大小
  subcmscolumns // 子表按需要的字段返回数据,字段之间使用 "," 隔开
})
  1. getSubTable(params):get 请求,获取子表数据
await getSubTable({});