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_ERRORNumber -32700 INVALID_REQUESTNumber -32600 METHOD_NOT_FOUNDNumber -32601 INVALID_PARAMSNumber -32602 INTERNAL_ERRORNumber -32603 -
<static> interfaces :function
-
Interfaces that will be automatically bound as properties of a Server instance
Type:
- function
- Source:
Properties:
Name Type Default Description httpfunction httpsfunction tcpfunction tlsfunction middlewarefunction
Methods
-
_resolveRouter(method, params)
-
Invoke the router
Parameters:
Name Type Description methodString Method to resolve paramsArray | Object Request params - Source:
Returns:
- Type
- Method
-
call(request [, context] [, originalCallback])
-
Calls a method on the server
Parameters:
Name Type Argument Description requestObject | Array | String A JSON-RPC request object. Object for single request, Array for batches and String for automatic parsing (using the reviver option) contextObject <optional>
Optional context object passed to methods originalCallbackfunction <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 codeNumber <optional>
-32603 Error code messageString <optional>
"Internal error" Error message dataObject <optional>
Additional data that should be provided - Source:
Returns:
- Type
- Object
-
getMethod(name)
-
Gets a method from the server
Parameters:
Name Type Description nameString - Source:
Returns:
- Type
- Method
-
hasMethod(name)
-
Checks if a method is registered with the server
Parameters:
Name Type Description nameString Name of method - Source:
Returns:
- Type
- Boolean
-
method(name, definition)
-
Adds a single method to the server
Parameters:
Name Type Description nameString Name of method to add definitionfunction | 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 methodsObject Methods to add - Source:
-
removeMethod(name)
-
Removes a method from the server
Parameters:
Name Type Description nameString - Source: