0.1.5 • Published 6 years ago

moc v0.1.5

Weekly downloads
30
License
-
Repository
-
Last release
6 years ago

#moc

前端构造数据服务

安装

npm i moc --save

# global install

sudo npm i moc -g
import moc from 'moc'

const config = {
    mockRoot: __dirname, // 默认项目跟目录
    port: 3000, // 启动端口
    tasks: { // 任务处理函数
        modifyTask (ctx, next) {
            return {
                data: 0,
                message: 'success'
            }
        },
        webTask (ctx, next) {
            let {level, method} = ctx.params
            return `./web/${level}/${method}`
        }
    },
    mapping: { // 请求任务映射关系
        modifyTask: ['**/modify', '**/update'],
        webTask: [
            'web/user/:level/:method'
        ]
    },
    static: {
        direction: __dirname,
        extensions: ['html', 'js', 'css']
    },
    plugins: {
        md: function (ctx, next) {
            // koa handler
            if (ctx.request.path.match(/.md$/)) {
                ctx.response.write('....')
            }
        }
    }
}

mock.start(config)
0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago