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

sesame-http

v0.1.0-beta

Published

A mini http server that analog datas.

Downloads

6

Readme

sesame-http

一个可以拦截Ajax请求并模拟数据的迷你服务器
Current Version:@0.0.1Beta

需求背景

在开发新项目时,发现公司已有的模拟假数据的http服务器已经不能满足项目的需求。并且Mock.js等模拟数据的库也不能够兼容公司已有的模拟数据方案。只好自己动手造轮子。
Inspired by Mock.js

1.项目中的模拟数据在调试时需要频繁的修改,需要能够便捷生成随机数据的方法。
2.需要能够在webpack中便捷的使用,也要能够在非webpack中便捷的调试
3.需要能够更具请求的全部信息(header、cookie)等,来返回对应的数值
4.支持不同response status值的返回,例如404,301等
5.支持返回文件
6.提供便捷的钩子函数,易于扩展
7.支持规则式的拦截假数据 如sesame.mock("http://xxx.xxx.xxx/getData","POST",function(){return data})
8.支持文件式的拦截数据 如请求 /api/getUsers ,可以在项目根目录建立api/getUsers.js然后在该文件内部书写逻辑返回数据
9.支持RESTful类型的数据便捷的进行模拟(Todo later)
10.支持在页面快捷修改模拟数据(Todo later)
11.支持文档转模拟数据(Todo later)

设计方案

设计思路 :

  • sesame-http使用express作为服务器来拦截请求,可以外挂在webpack上,也可以单独使用。
  • 采用websocket实现页面通信,从而实现再页面快捷修改假数据
  • 建立随机数生成机制,附加在sesame-http上,可以快捷的生成和拓展随机数。

#文档

进入这里查看sesame-http文档