• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

GrafGenerator/gulp-json-server: Gulp plugin-wrapper for json-server

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

GrafGenerator/gulp-json-server

开源软件地址(OpenSource Url):

https://github.com/GrafGenerator/gulp-json-server

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

gulp-json-server Build Status npm version

Wrapper for json-server.

Important! API versions >1.0.0 are incompatible with ones <1.0.0, see this page for new API, and examples of usage.

Install

$ npm install --save-dev gulp-json-srv

Usage

var gulp = require("gulp");
var jsonServer = require("gulp-json-srv");

var server = jsonServer.create();

gulp.task("start", function(){
    return gulp.src("data.json")
        .pipe(server.pipe());
});

See samples for more information about usage of plugin.

API

Options

Options Default value Description
baseUrl null The base URL for server API.
bodyParserJson null Allows override of default bodyParser.json() method so it is possible to pass in custom options. e.g. bodyParser.json({limit: '10mb', expanded: false}).
cumulative false Controls when to merge files from different pipe() calls (i.e. two pipelines execution.)
cumulativeSession true Controls when to merge files in one pipe() call (i.e. one pipeline execution.). If not, then only last file passed to plugin will form the DB state.
customRoutes null A key-value pairs of custom routes that should be applied to server. Each value should be the object with method and handler properties, describing HTTP method and handler of custom route respectively.
id "id" Identity property name of objects. Changing this allows to imitate MongoDB's _id f.e.
port 3000 Port number on which json-server will listen.
rewriteRules null A key-value pairs of rewrite rules that should be applied to server.
static null If specified and not null, sets the static files folder and lets json-server serve static files from that folder.
verbosity {
    level:"error",
    urlTracing:true
}
Should be either string or object. In case value is object, specifies log level (see loglevel for details), and urlTracing flag, which allows to control messages about accessed routes. In case value is string, specifies only log level, and urlTracing is considered to be true.

Important: Note that cumulative and cumulativeSession options could be specified in options object, passed to pipe() method and they will override one set at server level.

Methods

Method Description
kill(callback) Immediately stops the server and closes all opened connections. If callback is provided, it will be called once server stopped.
pipe(options) Provides stream trasformation for gulp pipeline. Passing 'options' to this method allows to override options, set at server level (currently cumulative and cumulativeSession are overridable).

Links

License

MIT © 2016 Nikita Ivanov




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap