Nondigestible Purple Mayonnaise

    @mileage/mock

    1.0.1 • Public • Published

    一个简单的mock服务器

    通过mockjs模拟数据,通过koa2构建服务器

    npm i @mileage/mock -g
    
    mileage-mock mock 你的存放mock的json文件夹 你的端口(默认3000)
    
    # 示例
    mileage-mock mock D:\mileage-mock\mock 9090
    
    # mock文件夹的结构
    mock
     data.json
       {
         "res": 200,
         "data|1-10":[
           {
             "id|+1": 1,
             "name": "张三",
             "age": "20"
           }
         ]
       }
    
    # 访问
    localhost:9090/mock/data
    localhost:9090/mock/data.json
    
    # 响应结构
    {
        "res": 200,
        "data": [
            {
                "id": 1,
                "name": "张三",
                "age": "20"
            },
            {
                "id": 2,
                "name": "张三",
                "age": "20"
            },
            {
                "id": 3,
                "name": "张三",
                "age": "20"
            },
            {
                "id": 4,
                "name": "张三",
                "age": "20"
            },
            {
                "id": 5,
                "name": "张三",
                "age": "20"
            }
        ]
    }

    Install

    npm i @mileage/mock

    DownloadsWeekly Downloads

    11

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    3.84 kB

    Total Files

    4

    Last publish

    Collaborators

    • mileagewan