Giter Club home page Giter Club logo

Comments (14)

jaywcjlove avatar jaywcjlove commented on June 15, 2024 1

@vanpipy thx! Released [email protected]

from mocker-api.

jaywcjlove avatar jaywcjlove commented on June 15, 2024

@vanpipy I don't know what you are going to do.

from mocker-api.

vanpipy avatar vanpipy commented on June 15, 2024

Because the implementation is:

const HOST = process.env.HOST || '0.0.0.0';

Like this

-   mocker mock/index.js
+   mocker --config mocker.config.json mock/index.js // or
+   mocker mock/inde.js // search the mocker.config.json in the project defaulty

And the user can set the HOST and PORT as wish.

Is that necessary?

from mocker-api.

jaywcjlove avatar jaywcjlove commented on June 15, 2024

@vanpipy Support mocker mock/m1.js test/m2.js

from mocker-api.

jaywcjlove avatar jaywcjlove commented on June 15, 2024

@vanpipy Upgrade + [email protected]

from mocker-api.

vanpipy avatar vanpipy commented on June 15, 2024

Hi, @jaywcjlove ,

I got your idea, the next PR will upgrade the version and the document together.

from mocker-api.

jaywcjlove avatar jaywcjlove commented on June 15, 2024

@vanpipy Already supported.

  • Support command line multi-file listeners 2c4dd5c

from mocker-api.

jaywcjlove avatar jaywcjlove commented on June 15, 2024

@vanpipy Support setting configuration on package.json?

{
  ...
  "mocker": {
    "host": "127.0.0.1",
    "port": 7788
  }
}

from mocker-api.

vanpipy avatar vanpipy commented on June 15, 2024

@vanpipy Support setting configuration on package.json?

{
  ...
  "mocker": {
    "host": "127.0.0.1",
    "port": 7788
  }
}

That is a better choice :D.

And a result needs to figure out which one is the first config for the user.

I suggest the priority:

  1. from the command line.
  2. from the package.json.
  3. from the mocker.config.json.

from mocker-api.

jaywcjlove avatar jaywcjlove commented on June 15, 2024

@vanpipy Support setting parameters:

mocker mock/index.js --port 7788
mocker mock/index.js --host 0.0.0.0

help:

Usage: mocker <path> [--config] [--help|h]

Displays help information.

Options:
  --config <path> Simple configuration

Example:
  mocker mock/index.js
  mocker mock/index.js --port 7788
  mocker mock/index.js --host 0.0.0.0
  mocker mock/m1.js test/m2.js
  mocker mock/m1.js --config mocker.config.json

from mocker-api.

vanpipy avatar vanpipy commented on June 15, 2024

Hi, @jaywcjlove ,

Yes, --host and --port is useful, and the usage needed.

from mocker-api.

jaywcjlove avatar jaywcjlove commented on June 15, 2024

Hi @vanpipy

I hope to help improve the documentation when I have time, thank you!

Command line supports more parameter configuration:

{
  ...
  "mocker": {
    "host": "127.0.0.1",
    "port": 7788,
    "pathRewrite": {
      "^/api/repos/": "/repos/"
    },
    "changeHost": true,
    ...
  }
}

from mocker-api.

vanpipy avatar vanpipy commented on June 15, 2024

Summary:

The mocker command line support 3 parameters:

  1. --host localhost
  2. --port 8000
  3. --config ./mocker.config.json

Of course, the -h and --help is in the house already.

And the priority of the config - assuming three configurations exist already.

  1. Local mocker config like mocker.config.json.
  2. The config in the package.json like:
{
    "mocker": { ... }
}
  1. The parameters from the command line.

First, the mocker commander will try to find the mocker.config.json. If exists and overwrite the default config.
Second, try to take the mocker from package.json. If exists and overwrite again.
Third, try to take host and port from the command line and overwrite the host and port.

That is all things of the mocker command line doing.

from mocker-api.

vanpipy avatar vanpipy commented on June 15, 2024

The issue resolved, so close it.

from mocker-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.