New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@142vip/common

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@142vip/common

142vip平台通用工具包,封装常用工具函数

latest
npmnpm
Version
0.0.1-alpha.9
Version published
Maintainers
1
Created
Source

@142vip/common

142vip平台通用工具包,封装常用工具函数

随机字符串

封装随机字符串生成函数,常用的有:

  • generateRandomStr
  • generateRandomStrWithSpecials
  • generateRandomStrWithLetter

分页

请求

封装了分页请求中的常见的currentPagepageSize字段。

/**
 * 分页时的请求参数
 * - 可继承
 */
export interface PaginationParams {
  currentPage: number
  pageSize: number
}

响应

分页数据的响应结构,继承了 PaginationParams的请求参数中的currentPage和pageSize字段,同时添加了totalPage字段和data字段,data字段为分页数据,支持泛型。

/**
 * 分页相应参数
 */
export interface PaginationResponseItem<T> extends PaginationParams {
  totalPage: number
  data: T[]
}

当分页接口返回数据时,常见的结构为:

{
  "currentPage": 1,
  "pageSize": 10,
  "totalPage": 1,
  // data字段支持泛型,常见是数组对象
  "data": []
}

接口响应

通用结构

export interface VipBaseResponse {
  traceId: string
  code: HttpStatus
  success: boolean
  message: string
}

请求成功

/**
 * 成功时,接口返回结构
 */
export interface VipSuccessResponse<T> extends VipBaseResponse {
  result: T
}

请求失败

/**
 * 异常时,接口返回结构
 */
export interface VipErrorResponse<T = string> extends VipBaseResponse {
  // 生产环境,严禁暴露这个字段
  detailErrorMessage?: T
}

参考

  • @142vip/utils

证书

MIT

Copyright (c) 2019-present, 142vip 储凡

Keywords

公众号搜:储凡

FAQs

Package last updated on 27 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts