new Server( [methods] [, options])
Constructor for a Jayson Server
Parameters:
Name | Type | Argument | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
methods |
Object.<String, function()> |
<optional> |
Methods to add | |||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
Properties
|
- Source:
Properties:
Name | Type | Description |
---|---|---|
options |
Object | A reference to the internal options object that can be modified directly |
errorMessages |
Object | Map of error code to error message pairs that will be used in server responses |
http |
ServerHttp | HTTP interface constructor |
https |
ServerHttps | HTTPS interface constructor |
tcp |
ServerTcp | TCP interface constructor |
tls |
ServerTls | TLS interface constructor |
middleware |
Middleware | Middleware generator function |
Returns:
- Type
- Server
Extends
- require('events').EventEmitter
Members
-
<static> errors :Number
-
JSON-RPC specification errors that map to an integer code
Type:
- Number
- Source:
Properties:
Name Type Default Description PARSE_ERROR
Number -32700 INVALID_REQUEST
Number -32600 METHOD_NOT_FOUND
Number -32601 INVALID_PARAMS
Number -32602 INTERNAL_ERROR
Number -32603 -
<static> interfaces :function
-
Interfaces that will be automatically bound as properties of a Server instance
Type:
- function
- Source:
Properties:
Name Type Default Description http
function https
function tcp
function tls
function middleware
function
Methods
-
_resolveRouter(method, params)
-
Invoke the router
Parameters:
Name Type Description method
String Method to resolve params
Array | Object Request params - Source:
Returns:
- Type
- Method
-
call(request [, context] [, originalCallback])
-
Calls a method on the server
Parameters:
Name Type Argument Description request
Object | Array | String A JSON-RPC request object. Object for single request, Array for batches and String for automatic parsing (using the reviver option) context
Object <optional>
Optional context object passed to methods originalCallback
function <optional>
Callback that receives one of two arguments: first is an error and the second a response - Source:
-
error( [code] [, message] [, data])
-
Returns a JSON-RPC compatible error property
Parameters:
Name Type Argument Default Description code
Number <optional>
-32603 Error code message
String <optional>
"Internal error" Error message data
Object <optional>
Additional data that should be provided - Source:
Returns:
- Type
- Object
-
getMethod(name)
-
Gets a method from the server
Parameters:
Name Type Description name
String - Source:
Returns:
- Type
- Method
-
hasMethod(name)
-
Checks if a method is registered with the server
Parameters:
Name Type Description name
String Name of method - Source:
Returns:
- Type
- Boolean
-
method(name, definition)
-
Adds a single method to the server
Parameters:
Name Type Description name
String Name of method to add definition
function | Client Function or Client for a relayed method - Source:
Throws:
-
Invalid parameters
- Type
- TypeError
-
methods(methods)
-
Adds a batch of methods to the server
Parameters:
Name Type Description methods
Object Methods to add - Source:
-
removeMethod(name)
-
Removes a method from the server
Parameters:
Name Type Description name
String - Source: