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

jjz-mockjs

v1.0.1

Published

基于nodejs的mock服务器

Downloads

1

Readme

概述

基于nodejs的mock服务器,支持get/post数据提交,一键生成 CRUD api接口,支持token校验、可配置化请求和响应参数及启动环境所需的参数

安装

npm i -g jjz-mockjs

使用

  1. 定义工作目录下或子目录定义配置文件; 默认当前目录/mock/config.js
  2. 定义解析成api路径的数据文件(.json格式),可定义在工作目录下的任意子目录 每个文件代表接口的路径名,每个目录接口的父目录 默认 当前目录/mock/api
  • 比如 当前目录/mock/api/u/vip.json; 可生成 /u/vip(列表)/u/vip/:id(详情)/u/vip/add(新增 post)/u/vip/edit(修改 post)/u/vip/del(删除 post)
  • 比如 当前目录/mock/api/user.json; 可生成 /user(列表)/u/vip/:id(详情)/u/vip/add(新增 post)/u/vip/edit(修改 post)/u/vip/del(删除 post)
  1. 数据文件内容为空的时候设置成 []

配置文件说明

  • mockServer: 生成api路径对应的文件的目录; 默认 mock/api
  • port: mock服务启动端口; 默认 7000
  • token: 设置token的值; 如果没有配置该值,则不会进行token校验
  • tokenExpire: token缓存时间; 默认 当前时间+1天的时间戳(单位: 毫秒)
  • apiReturnErrorKey: 接口返回的表示error字段名; 默认 error
  • apiReturnMsgKey: 接口返回的表示msg字段名; 默认 msg
  • apiReturnDataKey: 接口返回的表示data字段名; 默认 data
  • delParamsIdKey: 删除接口提交的表示id参数名; 默认 ids
  • paginationTotalKey: 列表分页接口表示总条数字段; 默认 total
  • paginationPageKey: 列表分页接口表示当前页字段,也可做请求传参; 默认 page
  • paginationPageSizeKey: 列表分页接口表示每页多少条字段, 也可用作传参; 默认 pageSize
  • paginationDataKey: 列表分页接口表示数据字段; 默认 data

启动

mockjs [配置文件路径]