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

fis-mock

v1.0.2

Published

fis本地服务器和mock程序

Downloads

8

Readme

fis本地服务器和mock程序

fis的server.conf本地模拟服务器, 注意server.conf配置中指向文件所在目录为相对与server.conf的目录

安装

npm install fis-mock

用法

var express = require('express');
var app = new express();
var mock = require('fis-mock');
app.use(function(req, res, next) {
    console.log('url: ', req.url);
    next();
});
app.use(express.static(__dirname + '/output'));

app.use(mock(__dirname + '/server.conf')); // mock配置文件

app.listen(8081, function(err) {
    if(err) {
        console.log('listen failed: ', err);
    } else {
        console.log('listen at 8081, please open: http://localhost:8081/')
    }
});

参数: mock规则配置文件

返回: express中间件

命令行

Usage: fism [options]

Options:
  -s, --static   静态文件目录,默认output. 多个静态文件夹时使用逗号","隔开  [string]
  -m, --mock     mock文件目录,未指定时会使用server.conf                 [string]
  -p, --port     监听端口,默认8080                                     [number]
  -v, --version  version                                               [boolean]
  -h, --help     Show help                                             [boolean]

Examples:
  fism -s output -m mock/server.conf

View Details: http://gitlab.baidu.com/muzhilong/fis-mock

匹配规则说明

匹配规则对应文件只有以下列单词开头的行才会匹配规则,其他任何内容开头将作为注释

  • rewrite reg rewriteUrl #匹配到正则,发送文件
  • redirect reg redirectUrl #匹配到正则,则转发到新的url
  • exec reg execFile #execFile指向一个js, 参数为req和res, 和正常express中间件类似

history

  • v1.0.2
    • fix mock文件路径计算问题
  • v1.0.1
    • 命令行参数static格式修改,可配置多个静态目录
  • v1.0.0
    • 本地静态服务及命令行配置