code: function(data, req, res, config){
          if(!data.cnt) return false;
          // console.log("----------ajax json:\n", data.type);
          try{
              switch(data.type){
                  case 'mjson': //处理mockjson
                      console.log(mockjs.mock(JSON.parse(data.cnt)))
                      data.cnt = JSON.stringify(mockjs.mock(JSON.parse(data.cnt)), null, 4);
                  case 'json':
                      res.writeHead(200, {
                          'Content-Type': utils.MIME['json']
                      });
                      res.write(data.cnt);
                      res.end();
                      break;
                  case 'js':
                      //data = new vm.script(data[0]);
                      // 将分解好的url给mock用户*.js
                      req.wwwurl = url.parse(config.protocol + '://' + req.headers.host + req.url);
                      var qstr = req.wwwurl.query ? qs.parse(req.wwwurl.query) : {},
                          query = {};
                      for(var i in qstr){
                          var $ = /(.+)\[(.+)\]/.exec(i);
                          // console.log("$: ", $);
                          $ ? (query[$[1]] || (query[$[1]] = {})) && (query[$[1]][$[2]] = qstr[i]):
                              query[i] = qstr[i];  
                      }
                      // console.log("qstr: ", qstr);
                      //extname === 'html' && console.log(req, '\n\n\n\n', req.wwwurl)
                      req.wwwurl.queryObj = query;
                      config.log && console.log('----------mock js func:\n', data.cnt.toString());
                      vm.runInThisContext('(' + data.cnt + ')')(req, res, require);
                      break;
                  default:
                      console.log("mock 暂只支持.mjson .json .js文件");
                      res.end("mock 暂只支持.mjson .json .js文件");
              }
          } catch(e){
              console.log("mock error: ", e);
          }
          return true;
      }
docs: mock response 用mock data 响应服务