@jianxcao/mock
1. `npm install @jianxcao/mock`
Last updated 2 months ago by jianxcao .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @jianxcao/mock 
SYNC missed versions from official npm registry.

mock middleware

  1. npm install @jianxcao/mock

clone from https://github.com/umijs

mock file


module.exports = {
    // Support type as Object and Array
    'GET /api/users': {
      users: [1, 2]
    },
    
    'GET /api/params': (req, res, next) => {
      console.log(req.query);
      res.body = {
        id: 225672
      }
    },
    // Method like GET or POST can be omitted
    '/api/users/1': {
      id: 1
    },
    'GET /api/uses/45': {
      code: 0,
      data: [],
      msg: '323'
    },
    'GET /api/:id': (req, res, next) => {
      res.body = {
        id: req.params.id
      };
  
    },
  
    'POST /api/users': (req, res, next) => {
      res.body = {
        id: 222
      }
    },
    'POST /api/other': (req, res, next) => {
      res.body = {
        id: 222
      }
    }
  };
  

please see path-to-regexp

Current Tags

  • 0.0.7                                ...           latest (2 months ago)

6 Versions

  • 0.0.7                                ...           2 months ago
  • 0.0.6                                ...           3 months ago
  • 0.0.5                                ...           6 months ago
  • 0.0.4                                ...           10 months ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 2
Last Day 2
Last Week 6
Last Month 7
Dependencies (8)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |