GithubHelp home page GithubHelp logo

zjsen668 / portal-fe-devserver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iuap-design/portal-fe-devserver

0.0 1.0 0.0 6 KB

本项目可以实现前端项目中公共依赖的本地 server 启动、proxy 代码转发、mock 数据模拟等功能

License: MIT License

JavaScript 100.00%

portal-fe-devserver's Introduction

portal-fe-devServer

portal-fe-devServer 这个 package 名带有业务含义,其本身实现的功能是基于 koa 、koa-router、node-fetch 等 package 集成封装后实现了本地启动 server 以及 proxy 代理转发。

Usage

install 安装

$ yarn add portal-fe-devServer

config 配置使用

var DevServer = require('portal-fe-devServer')
var koa = require('koa')
var app = koa();

var serverConfig = {
    // 将本地启动的 server 作为参数传递
    app: app,
    serverport: 8080,
    // 当前应用对应的上下文
    context: '/example',
    // isProxyFirst : 是否后端代理优先     
    // true -> 优先使用代理服务器数据,false -> 使用本地模拟数据
    isProxyFirst: true,
    //代理服务器列表
    proxyList: [{
        host: 'http://127.0.0.1:9090',
        context: '/integration'
    }, {
        host: 'http://172.20.8.76',
        context: '/workbench'
    }],
    //代理忽略的URL列表
    proxyIgnore: [
        "/",
        "/css.js",
        "/text.js",
        "/src/*",
        "/vendor/*",
        "/conf/*"
    ],
    //模拟请求列表
    mockList: [{
            type: "get",
            url: "/integration/system/nc",
            json: "nc.json"
        }, {
            type: "delete",
            url: "/integration/system/1",
            json: "deleteSystem.json"
        }]
}

var mockServer = new DevServer( serverConfig );

mockServer.start();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.