Aconex / drakov

Mock Server that implements the API Blueprint specification
MIT License
481 stars 115 forks source link

support generate routes from dicectory #148

Closed tooooolong closed 7 years ago

tooooolong commented 7 years ago

When i pass a directory to -f argument, it will make sourceFiles options as the first file in this directory

➜  drakov git:(master) ./drakov -f /Users/changhong/code/apibay/shanbay/*.apib
[INFO] No configuration files found
[INFO] Loading configuration from CLI
{ _:
   [ '/Users/changhong/code/apibay/shanbay/checkin.apib',
     '/Users/changhong/code/apibay/shanbay/experiment.apib',
     '/Users/changhong/code/apibay/shanbay/flex.apib',
     '/Users/changhong/code/apibay/shanbay/harbor.apib',
     '/Users/changhong/code/apibay/shanbay/insurance.apib',
     '/Users/changhong/code/apibay/shanbay/live.apib',
     '/Users/changhong/code/apibay/shanbay/loong.apib',
     '/Users/changhong/code/apibay/shanbay/lottery.apib',
     '/Users/changhong/code/apibay/shanbay/media.apib',
     '/Users/changhong/code/apibay/shanbay/news.apib',
     '/Users/changhong/code/apibay/shanbay/notification.apib',
     '/Users/changhong/code/apibay/shanbay/pay.apib',
     '/Users/changhong/code/apibay/shanbay/people.apib',
     '/Users/changhong/code/apibay/shanbay/questionnaire.apib',
     '/Users/changhong/code/apibay/shanbay/quote.apib',
     '/Users/changhong/code/apibay/shanbay/report.apib',
     '/Users/changhong/code/apibay/shanbay/shop.apib',
     '/Users/changhong/code/apibay/shanbay/soup.apib',
     '/Users/changhong/code/apibay/shanbay/speak.apib',
     '/Users/changhong/code/apibay/shanbay/studyroom.apib',
     '/Users/changhong/code/apibay/shanbay/wechat_app.apib' ],
  f: '/Users/changhong/code/apibay/shanbay/academy.apib',
  sourceFiles: '/Users/changhong/code/apibay/shanbay/academy.apib',
  serverPort: 3000,
  p: 3000,
  public: false,
  discover: false,
  D: false,
  '$0': 'drakov',
  config: undefined,
  staticPaths: undefined,
  pathDelimiter: undefined,
  stealthmode: undefined,
  disableCORS: undefined,
  sslKeyFile: undefined,
  sslCrtFile: undefined,
  delay: undefined,
  method: undefined,
  header: undefined,
  autoOptions: undefined,
  watch: undefined }

I find that yargs did this.

With this PR, we can generate routes from single file or a directory.

Add support for HOST metadata.

if there is a prefix path in the HOST meta, we add this prefix to the routes in express.

For example,

HOST: https://www.shanbay.com/api/v2/test

## Login [/login/]

### Login [POST]

+ Response 200 (application/json)
    + Attributes (BaseSuccessResponse)

will have a route: POST /api/v2/test/login/