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

mock_service

v1.1.0

Published

A mock API data service for frontend development.

Downloads

1

Readme

Mock Service

A mock API data service for frontend development.

提供一个UI后台用作前端开发的模拟前后端数据对接

介绍

  • 使用流程大概是在前端项目运行一个代理服务, 代理指向API服务端口, 当有请求发来时, API服务自动把请求push到UI后台,

  • 然后我们就可以在后台写一些测试数据发回给请求。

  • 支持post/get等类型的请求

  • 后台的功能包涵JSON数据录入, 自动返回数据, 能查看请求参数及其它请求信息, 筛选请求捕捉等。

  • 后台我们录入的数据是存在本地的indexedDB。

##Demo 先打开 后台页面, 然后访问 API服务链接 就可以在后台页面看到访问的信息。

##依赖 需要有redis环境 MacOS上安装很简单, 以下命令:

brew install redis

运行:

redis-server

##使用 可选两种使用方式:

方式一:直接clone代码

git clone https://github.com/nonjene/mock_service.git

然后安装依赖, 运行:

npm install --production

默认的后台端口是3000, 访问端口是3001。 (可在./config/config.json修改)

运行API服务及后台:

npm run start

然后浏览器打开后台:http://localhost:3000

然后就可以测试是否可运行了: 访问: http://localhost:3001/some/api/request

查看后台页面,就会收到请求信息了。

然后可以在前端项目建一个80端口的服务代理到3001端口,就OK啦。详见./demo/index.js

方式二: 作为express或koa服务的中间件

安装中间件:

npm install mock_service

使用:

var mockService = require("mock_service");

app.use(mockService({
    webSocketConfig: {port: 3336},
    redisConfig: {port: 6379},
    adminPort: 3000
}))

LICENSE

MIT