Giter VIP home page Giter VIP logo

agreed's Introduction

Node.js CI

agreed is Consumer Driven Contract tool with JSON mock server.

agreed has 3 features.

  1. Create contract file as json(json5/yaml/etc) file
  2. mock server for frontend development
  3. test client for backend development

Install

$ npm install @agreed/cli -g

Usage

Usage as Frontend Mock Server

  • Create agreed file (this file is used as a contract between frontend and backend)
// save as agreed.js
module.exports = [
  {
    request: {
      path: '/user/:id',
      method: 'GET',
      query: {
        q: '{:someQueryStrings}',
      },
      values: {
        id: 'yosuke',
        someQueryStrings: 'foo'
      },
    },
    response: {
      headers: {
        'x-csrf-token': 'csrf-token', 
      },
      body: {
        message: '{:greeting} {:id} {:someQueryStrings}',
        images: '{:images}',
        themes: '{:themes}',
      },
      values: {
        greeting: 'hello',
        images: [
          'http://example.com/foo.jpg',
          'http://example.com/bar.jpg',
        ],
        themes: {
          name: 'green',
        },
      }
    },
  },
]
  • Run server
$ agreed-server --path ./agreed.js --port 3010
  • curl to the mock server
$ curl http://localhost:3010/user/yosuke?q=foo
{
  "message": "hello yosuke foo",
  "images": [
    "http://example.com/foo.jpg",
    "http://example.com/bar.jpg"
  ],
  "themes": {
    "name": "green"
  }
}

Usage as Backend test client

  • Run test client for confirm response
$ agreed-client --path ./agreed.js --port 3030 --host example.com

Usage: Agreed Documentation

  • Run documentation server
$ agreed-ui --path ./agreed.js --port 3031

ScreenShot

agreed's People

Contributors

cos31 avatar dependabot[bot] avatar dorayakikun avatar harhogefoo avatar ka2jun8 avatar kt3k avatar progfay avatar quramy avatar renovate-bot avatar renovate[bot] avatar rt33 avatar yosuke-furukawa avatar yudppp avatar yuichi-kanno avatar yukihirop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agreed's Issues

Can't use parameter as function arguments.

It is my query hoge

      query: {
        hoge: '{:hoge}'
      }

I use func() method and argument is a in body.
It returns just '{:hoge}'.

const func = (a) => {
    console.log(a); // => it is just '{:hoge}'
};

module.exports = [
  {
      // something
      // something
      body: func('{:hoge}')
  }
]

[Bug?] The match with the definition of the passed query character cannot be confirmed.

Summary

Thank you for making a nice library,

It was discovered while trying out the sample code.

I think there is a problem with the code here.

result = Checker.query(request.query, req.query, options);

actual

$ curl http://localhost:3010/user/yosuke\?q\=foo
{"message":"hello yosuke foo","images":["http://example.com/foo.jpg","http://example.com/bar.jpg"],"themes":{"name":"green"}}%

$ curl http://localhost:3010/user/yosuke\?q\=fooaaaaa
{"message":"hello yosuke fooaaaaa","images":["http://example.com/foo.jpg","http://example.com/bar.jpg"],"themes":{"name":"green"}}%

$ curl http://localhost:3010/user/yosuke\?q\=fooaaaaaaaaaaaa
{"message":"hello yosuke fooaaaaaaaaaaaa","images":["http://example.com/foo.jpg","http://example.com/bar.jpg"],"themes":{"name":"green"}}%

expected

$ curl http://localhost:3010/user/yosuke\?q\=foo
{"message":"hello yosuke foo","images":["http://example.com/foo.jpg","http://example.com/bar.jpg"],"themes":{"name":"green"}}%

$ curl http://localhost:3010/user/yosuke\?q\=fooaaaaa
Agree Not Found

$ curl http://localhost:3010/user/yosuke\?q\=fooaaaaaaaaaaaa
Agree Not Found

Shouldn't the URL be matched against the values ​​in values.someQueryStrings ?

// save as agreed.js
module.exports = [
  {
    request: {
      path: '/user/:id',
      method: 'GET',
      query: {
        q: '{:someQueryStrings}',
      },
      values: {
        id: 'yosuke',
        someQueryStrings: 'foo'
      },

Environment

$ node -v
v13.13.0
"@agreed/cli": "^5.1.10"

plz add post document

postのbodyによってresponseを変えたい時にはどうするべきか。
ドキュメントがほしい。

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency @babel/plugin-proposal-private-property-in-object to v7.21.11
  • Update dependency body-parser to v1.20.2
  • Update dependency json5 to v2.2.3
  • Update dependency minimist to v1.2.8
  • Update dependency prettier to v2.8.8
  • Update dependency serialize-javascript to v6.0.2
  • Update dependency ts-node to v10.9.2
  • Update babel monorepo to v7.24.6 (@babel/eslint-parser, @babel/preset-react)
  • Update dependency eslint-config-prettier to v8.10.0
  • Update dependency express to v4.19.2
  • Update dependency jsonschema to v1.4.1
  • Update dependency morgan to v1.10.0
  • Update dependency path-to-regexp to v6.2.2
  • Update dependency react-json-tree to v0.19.0
  • Update dependency typescript to v4.9.5
  • Update dependency typescript-json-schema to ^0.63.0
  • Update react monorepo to v18.3.1 (react, react-dom)
  • Update typescript-eslint monorepo to v7.11.0 (@typescript-eslint/types, @typescript-eslint/typescript-estree)
  • Update actions/checkout action to v4
  • Update actions/setup-node action to v4
  • Update dependency @types/node to v20
  • Update dependency eslint to v9
  • Update dependency eslint-config-prettier to v9
  • Update dependency eslint-plugin-prettier to v5
  • Update dependency express-http-proxy to v2
  • Update dependency fs-extra to v11
  • Update dependency prettier to v3
  • Update dependency typescript to v5
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
packages/typed/.circleci/config.yml
  • circleci/node 17-browsers
github-actions
.github/workflows/nodejs.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
packages/cli/package.json
  • colo ^1.0.0
  • json5 ^2.0.0
  • minimist ^1.2.0
  • eater 4.0.4
  • plz-port 1.0.0
packages/client/package.json
  • colo ^1.0.0
  • is-empty ^1.0.0
  • eater 4.0.4
  • plz-port 1.0.0
packages/core/package.json
  • @types/node ^18.0.0
  • json5 ^2.0.0
  • jsonschema ^1.2.4
  • path-to-regexp ^6.0.0
  • stable ^0.1.8
  • typescript ^4.0.0
  • yamljs ^0.3.0
  • assert-stream 1.1.1
  • body-parser 1.20.0
  • codecov 3.8.3
  • eater 4.0.4
  • eslint 7.32.0
  • eslint-config-prettier 8.7.0
  • eslint-plugin-prettier 4.2.1
  • espower-loader 1.2.2
  • express 4.18.2
  • is-empty 1.2.0
  • must-call 1.0.0
  • npm-run-all 4.1.5
  • nyc 15.1.0
  • plz-port 1.0.0
  • power-assert 1.6.1
  • prettier 2.8.4
packages/server/package.json
  • body-parser ^1.18.3
  • cors ^2.8.5
  • express ^4.16.4
  • express-http-proxy ^1.6.0
  • morgan ^1.9.1
  • assert-stream 1.1.1
  • eater 4.0.4
  • must-call 1.0.0
  • plz-port 1.0.0
packages/typed/package.json
  • @types/estree 1.0.0
  • @types/minimist ^1.2.0
  • @types/node ^18.0.0
  • @typescript-eslint/types ^7.2.0
  • @typescript-eslint/typescript-estree ^7.2.0
  • doctrine ^3.0.0
  • json2yaml ^1.1.0
  • minimist ^1.2.0
  • typescript-json-schema ^0.55.0
  • body-parser 1.20.0
  • cors 2.8.5
  • express 4.18.2
  • prettier 2.8.4
  • ts-node ^10.9.2
  • tslint 6.1.3
  • tslint-config-prettier 1.18.0
  • tslint-plugin-prettier 2.3.0
  • tsx ^4.7.1
  • typescript 4.7.4
packages/ui/package.json
  • @babel/plugin-proposal-private-property-in-object ^7.21.11
  • colo 1.0.0
  • express 4.18.2
  • fs-extra 11.1.0
  • json-schema-to-flow-type 1.0.0
  • lodash.template 4.5.0
  • minimist 1.2.8
  • serialize-javascript 6.0.1
  • @babel/eslint-parser ^7.23.10
  • @babel/preset-react ^7.23.3
  • axios 0.27.2
  • classnames 2.3.1
  • eslint 7.32.0
  • eslint-config-prettier 8.7.0
  • eslint-plugin-prettier 4.2.1
  • eslint-plugin-react 7.30.0
  • prettier 2.8.4
  • prop-types 15.8.1
  • react 18.2.0
  • react-dom 18.2.0
  • react-json-tree 0.18.0
  • react-scripts 5.0.1

  • Check this box to trigger a request for Renovate to run again on this repository

OpenAPI

Agreed planning to support the open API?

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.