@open-rpc/mock-server
Advanced tools
Comparing version 1.6.0 to 1.7.0
#!/usr/bin/env node | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -39,9 +58,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -48,0 +60,0 @@ var program = require("commander"); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var child_process_1 = require("child_process"); | ||
var examples_1 = __importDefault(require("@open-rpc/examples")); | ||
var http = __importStar(require("http")); | ||
var data = JSON.stringify({ | ||
id: 1, | ||
jsonrpc: "2.0", | ||
method: "addition", | ||
params: [2, 2], | ||
}); | ||
var options = { | ||
hostname: "0.0.0.0", | ||
port: 3333, | ||
path: "/", | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Length": data.length, | ||
}, | ||
}; | ||
var http_1 = __importDefault(require("http")); | ||
describe("cli", function () { | ||
it("can be run with an example", function (done) { return __awaiter(void 0, void 0, void 0, function () { | ||
var childProc; | ||
return __generator(this, function (_a) { | ||
childProc = child_process_1.exec("node ./build/cli.js -d '" + JSON.stringify(examples_1.default.simpleMath) + "'"); | ||
setTimeout(function () { | ||
var req = http.request(options, function (res) { | ||
expect(res.statusCode).toBe(200); | ||
res.on("data", function (d) { | ||
expect(JSON.parse(d).result).toBe(4); | ||
childProc.kill("SIGHUP"); | ||
done(); | ||
it("can be run with an example", function (done) { | ||
var data = JSON.stringify({ | ||
id: 1, | ||
jsonrpc: "2.0", | ||
method: "addition", | ||
params: [2, 2], | ||
}); | ||
var options = { | ||
hostname: "localhost", | ||
port: 3333, | ||
path: "/", | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Length": data.length, | ||
}, | ||
}; | ||
var childProc = child_process_1.exec("node ./build/cli.js -d '" + JSON.stringify(examples_1.default.simpleMath) + "'"); | ||
setTimeout(function () { | ||
var req = http_1.default.request(options, function (res) { | ||
expect(res.statusCode).toBe(200); | ||
res.on("data", function (d) { | ||
expect(JSON.parse(d.toString()).result).toBe(4); | ||
childProc.kill("SIGHUP"); | ||
setTimeout(done, 2000); | ||
}); | ||
}); | ||
req.on("error", function (error) { throw error; }); | ||
req.write(data); | ||
req.end(); | ||
}, 1000); | ||
}, 10000); | ||
it("can run in service mode", function (done) { | ||
var childProc = child_process_1.exec("node ./build/cli.js -m service -p 3334"); | ||
var requestBody = JSON.stringify({ | ||
id: 1, | ||
jsonrpc: "2.0", | ||
method: "mock", | ||
params: [examples_1.default.simpleMath], | ||
}); | ||
var reqObj = { | ||
hostname: "0.0.0.0", | ||
port: 3334, | ||
path: "/", | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Length": requestBody.length, | ||
}, | ||
}; | ||
setTimeout(function () { | ||
var req = http_1.default.request(reqObj, function (res) { | ||
expect(res.statusCode).toBe(200); | ||
res.on("data", function (d) { | ||
expect(JSON.parse(d.toString()).result).toBe("simpleMath-1.0.0"); | ||
req.removeAllListeners(); | ||
var simpleMathReqBody = JSON.stringify({ | ||
id: 2, | ||
jsonrpc: "2.0", | ||
method: "addition", | ||
params: [2, 2], | ||
}); | ||
var simpleMathReqObj = { | ||
hostname: "localhost", | ||
port: 3334, | ||
path: "/simpleMath-1.0.0", | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Length": simpleMathReqBody.length, | ||
}, | ||
}; | ||
var insideReq = http_1.default.request(simpleMathReqObj, function (insideRes) { | ||
expect(insideRes.statusCode).toBe(200); | ||
insideRes.on("data", function (insideD) { | ||
expect(JSON.parse(insideD.toString()).result).toBe(4); | ||
childProc.kill("SIGHUP"); | ||
insideReq.removeAllListeners(); | ||
setTimeout(done, 2000); | ||
}); | ||
}); | ||
insideReq.on("error", function (error) { throw error; }); | ||
insideReq.write(simpleMathReqBody); | ||
insideReq.end(); | ||
}); | ||
req.on("error", function (error) { throw error; }); | ||
req.write(data); | ||
req.end(); | ||
}, 1000); | ||
return [2 /*return*/]; | ||
}); | ||
}); }); | ||
}); | ||
req.on("error", function (error) { throw error; }); | ||
req.write(requestBody); | ||
req.end(); | ||
}, 5000); | ||
}, 20000); | ||
}); |
@@ -53,2 +53,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serviceMode = void 0; | ||
var server_js_1 = require("@open-rpc/server-js"); | ||
@@ -55,0 +56,0 @@ var lodash_1 = __importDefault(require("lodash")); |
@@ -29,3 +29,6 @@ { | ||
"summary": "an OpenRPC document to mock", | ||
"schema": { "$ref": "#/components/schemas/OpenRPCDocument" } | ||
"schema": { | ||
"title": "OpenRPC Document", | ||
"description": "an open rpc document as defined by https://spec.open-rpc.org." | ||
} | ||
} | ||
@@ -32,0 +35,0 @@ ], |
@@ -0,1 +1,17 @@ | ||
# [1.7.0](https://github.com/open-rpc/mock-server/compare/1.6.0...1.7.0) (2020-08-05) | ||
### Bug Fixes | ||
* debug logs ([abae802](https://github.com/open-rpc/mock-server/commit/abae802ee43b61acb0a49df2e75839dd28f3b6a2)) | ||
* improve testing and coverage ([975f424](https://github.com/open-rpc/mock-server/commit/975f42429ad306b9c56ec8275fd44d1fd66cab2a)) | ||
* increase timeouts on tests ([3193383](https://github.com/open-rpc/mock-server/commit/31933838816599b28fd4128dc051f21ea1c1cef0)) | ||
* remove logs ([eb294f7](https://github.com/open-rpc/mock-server/commit/eb294f7eeb50f404a1eb0331fc4cfbe657de93bc)) | ||
* switch to different port for second test ([ab96a6a](https://github.com/open-rpc/mock-server/commit/ab96a6a9cc4b984301370773b7396653adbe99ed)) | ||
### Features | ||
* upgrade deps ([76d1d63](https://github.com/open-rpc/mock-server/commit/76d1d63bf5f4cb3d1d10e85766eb2b7d88a9af34)) | ||
# [1.6.0](https://github.com/open-rpc/mock-server/compare/1.5.0...1.6.0) (2020-05-07) | ||
@@ -2,0 +18,0 @@ |
{ | ||
"name": "@open-rpc/mock-server", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Provides a mock JSON-RPC API given an OpenRPC Document", | ||
@@ -33,18 +33,18 @@ "repository": { | ||
"dependencies": { | ||
"@open-rpc/examples": "^1.5.0", | ||
"@open-rpc/schema-utils-js": "^1.13.3", | ||
"@open-rpc/server-js": "^1.7.1", | ||
"lodash": "^4.17.11" | ||
"@open-rpc/examples": "^1.6.0", | ||
"@open-rpc/schema-utils-js": "^1.14.0", | ||
"@open-rpc/server-js": "^1.8.0", | ||
"lodash": "^4.17.19" | ||
}, | ||
"devDependencies": { | ||
"@open-rpc/meta-schema": "^1.11.0", | ||
"@types/connect": "^3.4.32", | ||
"@types/cors": "^2.8.5", | ||
"@types/jest": "^25.1.0", | ||
"@types/json-schema": "^7.0.3", | ||
"@types/lodash": "^4.14.123", | ||
"jest": "^25.1.0", | ||
"ts-jest": "^25.0.0", | ||
"typescript": "^3.4.5" | ||
"@open-rpc/meta-schema": "^1.12.7", | ||
"@types/connect": "^3.4.33", | ||
"@types/cors": "^2.8.6", | ||
"@types/jest": "^26.0.7", | ||
"@types/json-schema": "^7.0.5", | ||
"@types/lodash": "^4.14.158", | ||
"jest": "^25.5.4", | ||
"ts-jest": "^25.5.1", | ||
"typescript": "^3.9.7" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43078
421
Updated@open-rpc/examples@^1.6.0
Updated@open-rpc/server-js@^1.8.0
Updatedlodash@^4.17.19