rpc-websocketserver
Version:
Simple rpc websocket server, wrapping the very popular 'ws' library. Register your RPCs with convenient decorators.
102 lines • 3.89 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.InternalError = exports.InvalidParams = exports.InvalidMethod = exports.InvalidRequest = exports.ParseError = exports.JSONRPC2Error = void 0;
var utils_1 = require("./utils");
/**
* Base JSON RPC 2 error class. Contains JSON RPC 2 conform error object.
*/
var JSONRPC2Error = /** @class */ (function (_super) {
__extends(JSONRPC2Error, _super);
/**
* @param code {number} - JSON RPC 2 error code
* @param details {ErrorDetails} - optional error details to be appended to the error object
*/
function JSONRPC2Error(code, details) {
var _this = _super.call(this) || this;
_this.name = 'JSONRPC2Error';
_this.object = utils_1.buildError(code, details);
_this.message = _this.object.message;
return _this;
}
return JSONRPC2Error;
}(Error));
exports.JSONRPC2Error = JSONRPC2Error;
/**
* JSON RPC 2 Parse error class. Contains JSON RPC 2 conform error object including code.
*/
var ParseError = /** @class */ (function (_super) {
__extends(ParseError, _super);
function ParseError(details) {
var _this = _super.call(this, -32700, details) || this;
_this.name = 'ParseError';
return _this;
}
return ParseError;
}(JSONRPC2Error));
exports.ParseError = ParseError;
/**
* JSON RPC 2 Invalid request error class. Contains JSON RPC 2 conform error object including code.
*/
var InvalidRequest = /** @class */ (function (_super) {
__extends(InvalidRequest, _super);
function InvalidRequest(details) {
var _this = _super.call(this, -32600, details) || this;
_this.name = 'InvalidRequest';
return _this;
}
return InvalidRequest;
}(JSONRPC2Error));
exports.InvalidRequest = InvalidRequest;
/**
* JSON RPC 2 Invalid method error class. Contains JSON RPC 2 conform error object including code.
*/
var InvalidMethod = /** @class */ (function (_super) {
__extends(InvalidMethod, _super);
function InvalidMethod(details) {
var _this = _super.call(this, -32601, details) || this;
_this.name = 'InvalidMethod';
return _this;
}
return InvalidMethod;
}(JSONRPC2Error));
exports.InvalidMethod = InvalidMethod;
/**
* JSON RPC 2 Invalid params error class. Contains JSON RPC 2 conform error object including code.
*/
var InvalidParams = /** @class */ (function (_super) {
__extends(InvalidParams, _super);
function InvalidParams(details) {
var _this = _super.call(this, -32602, details) || this;
_this.name = 'InvalidParams';
return _this;
}
return InvalidParams;
}(JSONRPC2Error));
exports.InvalidParams = InvalidParams;
/**
* JSON RPC 2 Internal error class. Contains JSON RPC 2 conform error object including code.
*/
var InternalError = /** @class */ (function (_super) {
__extends(InternalError, _super);
function InternalError(details) {
var _this = _super.call(this, -32603, details) || this;
_this.name = 'InternalError';
return _this;
}
return InternalError;
}(JSONRPC2Error));
exports.InternalError = InternalError;
//# sourceMappingURL=errors.js.map