server.create
Create a transport-agnostic peer that exposes procedures
CLI- Package
- @procedures/peer · README
- Path
["server","create"]- CLI
mark server create- As data
{"$proc":["server","create"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/peer"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["server","create"], {});
console.log(JSON.stringify(result));From the command line
$ mark server create
As data, in a program
{ "$proc": ["server", "create"], "input": {} }Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
transports | any[] | no | The transports to start (default: HTTP on port 3000) | |
autoRegister | boolean | no | Serve every procedure of the registry (default: true) | |
token | string | no | A secret that every request must send | |
expose | string[] | no | The procedures to serve: exact keys (git.status) or prefixes (git.*). Default: every procedure |
Output
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
serverId | string | yes | The id of the server: server.stop takes it | |
endpoints | object[] | yes | The endpoints of the server | |
procedureCount | number | yes | The number of procedures that the server serves |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"transports": {
"description": "The transports to start (default: HTTP on port 3000)",
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "http"
},
"port": {
"type": "integer",
"minimum": 1,
"maximum": 65535
},
"host": {
"type": "string",
"minLength": 1
},
"basePath": {
"type": "string"
},
"cors": {
"type": "boolean"
},
"corsOrigins": {
"type": "array",
"items": {
"type": "string"
}
},
"urlStrategy": {
"type": "string",
"enum": [
"rest",
"rpc"
]
},
"token": {
"type": "string",
"minLength": 1
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "websocket"
},
"port": {
"type": "integer",
"minimum": 1,
"maximum": 65535
},
"host": {
"type": "string",
"minLength": 1
},
"path": {
"type": "string"
},
"origins": {
"type": "array",
"items": {
"type": "string"
}
},
"token": {
"type": "string",
"minLength": 1
}
},
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "local"
}
},
"required": [
"type"
]
}
]
}
},
"autoRegister": {
"description": "Serve every procedure of the registry (default: true)",
"type": "boolean"
},
"token": {
"description": "A secret that every request must send",
"type": "string",
"minLength": 1
},
"expose": {
"description": "The procedures to serve: exact keys (git.status) or prefixes (git.*). Default: every procedure",
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
}
}
},
"output": {
"type": "object",
"properties": {
"serverId": {
"type": "string",
"description": "The id of the server: server.stop takes it"
},
"endpoints": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"http",
"websocket",
"local"
],
"description": "The transport"
},
"address": {
"type": "string",
"description": "The address of the endpoint"
}
},
"required": [
"type",
"address"
],
"additionalProperties": {}
},
"description": "The endpoints of the server"
},
"procedureCount": {
"type": "number",
"description": "The number of procedures that the server serves"
}
},
"required": [
"serverId",
"endpoints",
"procedureCount"
],
"additionalProperties": {}
}
}