Licence
MIT
Version
0.10.0
Deps
0
Vulns
0
Weekly
0
trepo-webworker-js
Starts a Trepo Server in a Web Worker.
Example
var worker = new Worker('/trepo-webworker.js');
worker.onmessage = function(e) {
console.log(e.data);
// Data will have 2 fields, id and payload.
}
// To start Trepo
worker.postMessage({
id: '1234',
cmd: 'start',
payload: {
repo: 'my-repo',
vgraph: {
//engine: 'level',
name: 'testing'
},
xsearch: {
prefix: 'testing'
}
}
});
// To make a request
worker.postMessage({
id: '1234',
cmd: 'request',
payload: {
method: 'GET',
path: '/graph/info'
}
});
// To Stop Trepo
worker.postMessage({
id: '1234',
cmd: 'stop',
payload: {}
});
Usage
Each request sends an id, cmd, and payload. Each response includes an id and a payload.
Request
id- Used to match requests with responses (each response will include the id of the request).cmd- One ofstart,stop, andrequest.payload- The request payload.
Response
id- Used to match requests with responses.payload- The response payload.