packages/cli/config-overrides.js
function mockServer(app) {
        const jsonRouter = jsonServer.router(db);

        const shouldMockReq = req => {
          return (
            req.method !== "GET" ||
            (req.headers.accept &&
              req.headers.accept.indexOf("application/json") !== -1)
          );
        };

        if (serverOpts.delay) {
          app.use((req, res, next) => {
            if (shouldMockReq(req)) {
              return pause(serverOpts.delay)(req, res, next);
            }
            return next();
          });
        }

        app.use(jsonServer.rewriter(rewrites));

        // user defined routers
        app.use(jsonServer.bodyParser);

        // user query normalizr
        app.use((req, res, next) => {
          if (shouldMockReq(req)) {
            req.query = toJsonServer(req.query);
            return next();
          }
          return next();
        });

        routers.forEach(router => app.use(router));

        // json server router
        app.use((req, res, next) => {
          if (shouldMockReq(req)) {
            return jsonRouter(req, res, next);
          }
          return next();
        });

        return app;
      }
function mockServer(app) {
        const jsonRouter = jsonServer.router(db);

        const shouldMockReq = req => {
          return (
            req.method !== "GET" ||
            (req.headers.accept &&
              req.headers.accept.indexOf("application/json") !== -1)
          );
        };

        if (serverOpts.delay) {
          app.use((req, res, next) => {
            if (shouldMockReq(req)) {
              return pause(serverOpts.delay)(req, res, next);
            }
            return next();
          });
        }

        app.use(jsonServer.rewriter(rewrites));

        // user defined routers
        app.use(jsonServer.bodyParser);

        // user query normalizr
        app.use((req, res, next) => {
          if (shouldMockReq(req)) {
            req.query = toJsonServer(req.query);
            return next();
          }
          return next();
        });

        routers.forEach(router => app.use(router));

        // json server router
        app.use((req, res, next) => {
          if (shouldMockReq(req)) {
            return jsonRouter(req, res, next);
          }
          return next();
        });

        return app;
      }
function mockServer ( app ) { const jsonRouter = jsonServer . router ( db ) ; const shouldMockReq = req => { return ( req . method !== "GET" || ( req . headers . accept && req . headers . accept . indexOf ( "application/json" ) !== - 1 ) ) ; } ; if ( serverOpts . delay ) { app . use ( ( req , res , next ) => { if ( shouldMockReq ( req ) ) { return pause ( serverOpts . delay ) ( req , res , next ) ; } return next ( ) ; } ) ; } app . use ( jsonServer . rewriter ( rewrites ) ) ; // user defined routers app . use ( jsonServer . bodyParser ) ; // user query normalizr app . use ( ( req , res , next ) => { if ( shouldMockReq ( req ) ) { req . query = toJsonServer ( req . query ) ; return next ( ) ; } return next ( ) ; } ) ; routers . forEach ( router => app . use ( router ) ) ; // json server router app . use ( ( req , res , next ) => { if ( shouldMockReq ( req ) ) { return jsonRouter ( req , res , next ) ; } return next ( ) ; } ) ; return app ; }
mock server hoc
@param {Express.Application} app
mock server hoc