New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sloki-node-client

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sloki-node-client - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

src/BaseClient.js

21

CHANGELOG.md
# Changelog
## [0.0.7] - UNRELEASED
### Added
* add getMethodsName() [#3](https://github.com/sloki-project/sloki-node-client/issues/3)
* add getMethodDescription() [#4](https://github.com/sloki-project/sloki-node-client/issues/4)
* TLS clients [#7](https://github.com/sloki-project/sloki-node-client/issues/7)
### Changed
* use named parameters in jsonrpc layer [#6](https://github.com/sloki-project/sloki-node-client/issues/6)
## [0.0.6] - 2019-02-09
* Support Promises
### Added
* All methods now support Promises [#2](https://github.com/sloki-project/sloki-node-client/issues/2)
## [0.0.3] - 2019-01-27
* First version, only TCP client is implemented
* Use callback
### Added
* First version : TCP client
* All methods support callback only for moment

6

examples/callback.js

@@ -11,9 +11,9 @@ const Client = require('../')

(next) => {
client.loadDatabase('myTestDatabase', next);
client.loadDatabase({ database:'myTestDatabase' }, next);
},
(db, next) => {
client.insert('devices',{'foo':'bar'}, next);
client.insert({ collection:'devices', document:{'foo':'bar'} }, next);
},
(result, next) => {
client.find('devices', next);
client.find({ collection:'devices' }, next);
},

@@ -20,0 +20,0 @@ (devices, next) => {

@@ -1,2 +0,2 @@

const Client = require('../')
const Client = require('../');

@@ -8,5 +8,5 @@ const client = new Client('tcp://127.0.0.1:6370');

await client.connect();
await client.loadDatabase('myTestDatabase');
await client.insert('devices',{'foo':'bar'});
const devices = await client.find('devices');
await client.loadDatabase({ db:'myTestDatabase' });
await client.insert({ col:'devices', doc:{ 'foo':'bar' } });
const devices = await client.find({ col:'devices' });
await client.saveDatabase();

@@ -21,5 +21,5 @@ await client.close();

}
}
};
client.init();

@@ -1,54 +0,54 @@

const implementedTransports = ['tcp','tls'];
const defaultOptions = {
applicationLayer:'jayson'
}
const implementedTransports = [
'tcp', // alias for binary
'tls', // alias for binarys
'binary',
'binarys',
'jsonrpc',
'jsonrpcs'
];
function Client(url, options) {
let client;
let e = url.match(/^([^:]+)/);
if (!url) {
throw new Error('no endpoint specified (i.e tcp://localhost)');
}
const e = url.match(/^([^:]+)/);
if (!e) {
throw new Error('URL must start with ' + implementedProtocols.join(',')+'');
process.exit(-1);
return;
throw new Error(`endpoint must start with ${implementedTransports.join(',')}`);
}
options = Object.assign(defaultOptions, options||{});
options = options||{};
let transportLayer;
options.protocol = e[1].toLowerCase();
if (implementedTransports.indexOf(options.protocol)<0) {
throw new Error(`endpoint does not contain any implemented protocol ${implementedTransports.join(',')}`);
}
if (e) {
transportLayer = e[1].toLowerCase();
if (implementedTransports.indexOf(transportLayer)<0) {
throw new Error('URL does not contain any implemented protocol (' + implementedTransports.join(',')+')');
return null;
}
if (options.protocol === 'tcp') {
options.protocol = 'binary';
}
if (transportLayer === "tls") {
throw new Error('Protocol '+proto+' not yet implemented');
process.exit(-1);
if (options.protocol === 'tls') {
options.protocol = 'binarys';
}
if (transportLayer === "tcp" || transportLayer === "tls") {
url = url.replace(/(tcp|tls):\/\//,'').split(':');
let host = url[0];
let port = parseInt(url[1]);
let myClient;
url = url.replace(/^[^:]+:\/\//, '').split(':');
const host = url[0];
const port = parseInt(url[1]);
switch (transportLayer) {
case "tcp":
switch (options.applicationLayer) {
case "jayson":
MyClient = require('./src/tcpJayson');
return new MyClient(port, host, options);
break;
default:
throw new Error('Unknow application layer '+options.applicationLayer);
}
case "tls":
throw new Error('Transport layer TLS not yet implemented');
}
let MyClient;
if (options.protocol.match(/jsonrpc/)) {
MyClient = require('./src/jsonrpc');
} else if (options.protocol.match(/binary/)) {
MyClient = require('./src/binary');
} else {
throw new Error(`Unknow protocol ${options.protocol}`);
}
return new MyClient(port, host, options);
}
module.exports = Client;
{
"name": "sloki-node-client",
"version": "0.0.6",
"version": "0.0.7",
"description": "NodeJS Client for Sloki",

@@ -11,3 +11,3 @@ "main": "index.js",

"type": "git",
"url": "git+https://github.com/sloki-project/sloki-node-client.git"
"url": "git+https://github.com/sloki-project/sloki.git"
},

@@ -21,11 +21,12 @@ "keywords": [

"bugs": {
"url": "https://github.com/sloki-project/sloki-node-client/issues"
"url": "https://github.com/sloki-project/sloki/issues"
},
"homepage": "https://github.com/sloki-project/sloki-node-client#readme",
"homepage": "https://github.com/sloki-project/sloki/blob/master/clients/node/README.md",
"dependencies": {
"JSONStream": "^1.3.5",
"async": "^2.6.1",
"debug": "^4.1.1",
"hyperid": "^2.0.2"
"JSONStream": "1.3.5",
"async": "2.6.1",
"debug": "4.1.1",
"hyperid": "2.0.2",
"missive": "3.0.1"
}
}
# Sloki-node-client
A NodeJS Client for [Sloki](https://github.com/sloki-project/sloki)
[![Join the chat at https://gitter.im/sloki-server/community](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sloki-server/community)
[![npm version](https://badge.fury.io/js/sloki-node-client.svg)](http://badge.fury.io/js/sloki-node-client)
[![alt packagequality](http://npm.packagequality.com/shield/sloki-node-client.svg)](http://packagequality.com/#?package=sloki-node-client)
[![Known Vulnerabilities](https://snyk.io/test/github/sloki-project/sloki-node-client/badge.svg?targetFile=package.json)](https://snyk.io/test/github/sloki-project/sloki-node-client?targetFile=package.json)
[![npm version](https://badge.fury.io/js/sloki-node-client.svg?v=0)](http://badge.fury.io/js/sloki-node-client)
[![Known Vulnerabilities](https://snyk.io/test/github/sloki-project/sloki/badge.svg?targetFile=clients/node/package.json)](https://snyk.io/test/github/sloki-project/sloki?targetFile=clients/node/package.json)
[![Dependencies](https://david-dm.org/sloki-project/sloki.svg?path=clients/node)](https://david-dm.org/sloki-project/sloki-node-client)
[![Dev Dependencies](https://david-dm.org/sloki-project/sloki/dev-status.svg?path=clients/node)](https://david-dm.org/sloki-project/sloki-node-client?type=dev)

@@ -16,8 +16,11 @@ -----

-----
## Usage
TODO
See [examples](examples/)
----
## Source code
See [sloki repository](https://github.com/sloki-project/sloki/tree/master/clients/node)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc