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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vpost

v0.0.6

Published

An easy module for frontend engineer to create temporary API with node.js.本模块适用于前端工程师创建临时接口用于调试代码。

Downloads

16

Readme

VPost

Short for virtual-post, an easy module for frontend engineer to create temporary API with node.js

本模块(virtual-post)适用于前端工程师创建临时接口用于调试代码。样例如下:

##example:

var VPost = require("../lib/VPost");

var config = {
	rootPath:"/test",
	filePath: "",
	data:[
		{
			"req":"/getString",
			"res":'{"str":"aa"}',
			"code":"201"
		},
		{
			"req":"/getFunction?a=111",
			"res":function(url){
				return '{"function":"' + String(Math.random()) + '","a":"' + url.$query.a + '"}' 
			}
		},
		{
			"req":"/getArray",
			"res":[1,2,3,4,5]
		},
		{
			"req":"/getObject",
			"res": {
				a:"a",
				b:["b1","b2","b3","b4","b5"],
				c:function(){
					return "c";
				},
				d:{
					d1:"d1",
					d2:["d21","d22","d23"],
					d3:function(){
						return "d3"
					},
					d4:{
						d41:"d41"
					}
				}
			}
		},
		{
			"req":/regExp/i,
			"res":"RegExp"
		}
	],
	default:"not found",
	port:"2048"
	
} 

var vPost = new VPost(config);

##用node运行起来,即可在127.0.0.1:2048访问到接口: ##run by node and visit in 127.0.0.1:2048:

VPost接收到请求时,优先匹配接口,假如没有成功匹配对应接口,则继续尝试匹配文件(默认放入www/文件夹内),二者都匹配失败时返回404

request:127.0.0.1:2048/test/getString response:{"str":"aa"}

request:127.0.0.1:2048/test/getFunction?a=111 response:{"function":"0.2123435453534","a":"111"}

request:127.0.0.1:2048/test/getObject response:{"a":"a","b":"b1","c":"c","d":{"d1":"d1","d2":"d21","d3":"d3","d4":{"d41":"d41"}}}

request:127.0.0.1:2048/test/getRegExp response:RegExp

request:127.0.0.1:2048/index.html response:index.html file

request:127.0.0.1:2048/test/getMoney response:not found

##参数说明 para intro:

rootPath:根路径; filePath:文件根路径,默认为‘www/’; data:请求参数数组:

code为返回状态码,选填,默认200 req为请求路径,可以为字符串或正则表达式; res为返回参数(接受字符串/数字/数组/函数/对象);

返回参数为数组时,随机返回数组中某一值,如需要返回数组,请用括号括起,如'[1,2,3]' 为函数时,返回函数返回值,可在参数中传入一个url对象,包含$query和$search两个属性 为对象时,会遍历该对象,对象中的value转换成对应的字符串;

default:没有找到对应接口时返回的值;

port:端口,选填,默认8888