@wannasky/server
node 代理服务器 路由配置 liveReload等
Last updated 7 months ago by wannasky .
MIT · Original npm · Tarball · package.json
$ cnpm install @wannasky/server 
SYNC missed versions from official npm registry.

@wannasky/server

node服务器,支持代理,路由等功能

配置

新建wserver.config.js(默认)用于配置服务器相关参数


module.exports = {

    root: './',     // 服务器根目录

    port: 8989,     // 端口号
    
    memory: false,  // 静态资源是否从内存读取,memory-fs ,默认 false
    
    liveReload: false, //是否文件变化(root下),自动刷新,memory模式下不生效

    proxy: {
        '/api/one': {
            target: 'https://one.dyn.com',
            headers: {
                host: 'xxx'
            }
        },
        '/api/two': 'https://two.dyn.com'
    },

    router: {
        
        // get post put delete 等
        '/account/:user': {
            
            get: (req, res, query) => {
                res.json({
                    message: 'success',
                    info: {
                        name: query
                    }
                });
            },
            
            post: (req, res) => {
                res.json({
                    message: 'success'
                });
            }
        }
        
    },
    
    try_files: './index.html'  // try files

}

使用

运行 wserver即可

自定义配置文件 wserver -c custom.config.js

Current Tags

  • 2.2.7                                ...           latest (7 months ago)

20 Versions

  • 2.2.7                                ...           7 months ago
  • 2.2.6                                ...           7 months ago
  • 2.2.5                                ...           7 months ago
  • 2.2.4                                ...           7 months ago
  • 2.1.4                                ...           7 months ago
  • 2.2.3                                ...           7 months ago
  • 2.2.2                                ...           7 months ago
  • 2.2.1                                ...           7 months ago
  • 2.2.0                                ...           7 months ago
  • 2.1.3                                ...           a year ago
  • 2.1.2                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.5                                ...           a year ago
  • 2.0.4                                ...           a year ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (11)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |