Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #178 from apiaryio/v2
Browse files Browse the repository at this point in the history
Implements v2
  • Loading branch information
artem-zakharchenko authored Jun 18, 2019
2 parents ad90056 + 5bd3333 commit 0138366
Show file tree
Hide file tree
Showing 71 changed files with 1,975 additions and 4,197 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'consistent-return': 'off',
'class-methods-use-this': 'off',
'no-plusplus': 'off',
'func-names': 'off',

// Temporary overrides. Logic to be rewritten.
// TODO https://github.com/apiaryio/gavel.js/issues/150
Expand Down
30 changes: 9 additions & 21 deletions bin/gavel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env node
/* eslint-disable */

var cmd = require('commander');
var httpParser = require('http-string-parser');
var curlParser = require('curl-trace-parser');
var gavel = require('../lib/gavel');
var gavel = require('../lib');
var fs = require('fs');

cmd.version('0.0.1');
Expand All @@ -23,29 +24,16 @@ process.stdin.on('end', function() {

var realHttp = curlParser.parseBack(stdin);

var realRequest = httpParser.parseRequest(realHttp['request']);
var realResponse = httpParser.parseResponse(realHttp['response']);
var realRequest = httpParser.parseRequest(realHttp.request);
var realResponse = httpParser.parseResponse(realHttp.response);

var expectedRequest = httpParser.parseRequest(expectedHttp['request']);
var expectedResponse = httpParser.parseResponse(expectedHttp['response']);
var expectedRequest = httpParser.parseRequest(expectedHttp.request);
var expectedResponse = httpParser.parseResponse(expectedHttp.response);

var requestResult = false;
var responseResult = false;
const requestResult = gavel.validate(expectedRequest, realRequest);
const responseResult = gavel.validate(expectedResponse, realResponse);

gavel.isValid(realRequest, expectedRequest, 'request', function(
err,
result
) {
requestResult = result;
gavel.isValid(realResponse, expectedResponse, 'response', function(
err,
result
) {
responseResult = result;
});
});

if (requestResult && responseResult) {
if (requestResult.isValid && responseResult.isValid) {
process.exit(0);
} else {
process.exit(1);
Expand Down
17 changes: 0 additions & 17 deletions lib/gavel.js

This file was deleted.

5 changes: 5 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { validate } = require('./validate');

module.exports = {
validate
};
Loading

0 comments on commit 0138366

Please sign in to comment.