Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appcd-client

Package Overview
Dependencies
Maintainers
3
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appcd-client - npm Package Compare versions

Comparing version 1.1.0-0 to 1.1.0

CHANGELOG.md

58

dist/client.js

@@ -166,6 +166,8 @@ "use strict";

*
* @param {String} path - The path to send.
* @param {Object} [data] - An object to send.
* @param {String} [type] - The request type. Valid types include `call`, `subscribe`, and
* `unsubscribe`.
* @param {String|Object} pathOrParams - The path to request or an object containing the path,
* data, and type.
* @param {String} [pathOrParams.path] - The path to request.
* @param {Object} [pathOrParams.data] - An object to send.
* @param {String} [pathOrParams.type] - The request type. Valid types include `call`,
* `subscribe`, and `unsubscribe`.
* @returns {EventEmitter} Emits events `response` and `error`.

@@ -176,14 +178,37 @@ * @access public

request({
path,
data,
type
} = {}) {
request(pathOrParams) {
if (!pathOrParams || typeof pathOrParams !== 'string' && typeof pathOrParams !== 'object') {
throw new TypeError('Expected non-empty path or parameters object');
}
const emitter = new _events.EventEmitter();
const startTime = new Date(); // need to delay request so event emitter can be returned and events can
const id = _uuid.default.v4();
const startTime = new Date();
const req = {
version: '1.0',
path: pathOrParams,
id
};
if (typeof pathOrParams === 'object') {
Object.assign(req, pathOrParams);
}
if (!req.path || typeof req.path !== 'string') {
throw new TypeError('Expected path to be a non-empty string');
}
if (req.data && (typeof req.data !== 'object' || Array.isArray(req.data))) {
throw new TypeError('Expected data to be an object');
}
if (req.type && typeof req.type !== 'string') {
throw new TypeError('Expected type to be a string');
} // need to delay request so event emitter can be returned and events can
// be wired up
setImmediate(() => {
const id = _uuid.default.v4();
return this.connect().on('connected', client => {

@@ -196,3 +221,3 @@ this.requests[id] = response => {

delete response.id;
log(`${style(status)} ${highlight(path)} ${note(`${new Date() - startTime}ms`)}`);
log(`${style(status)} ${highlight(req.path)} ${note(`${new Date() - startTime}ms`)}`);

@@ -226,9 +251,2 @@ switch (statusClass) {

const req = {
version: '1.0',
path,
id,
data,
type
};
log('Sending request:', req);

@@ -235,0 +253,0 @@ client.socket.send(JSON.stringify(req));

{
"name": "appcd-client",
"version": "1.1.0-0",
"version": "1.1.0",
"description": "The Node.js client for connecting to the Appc Daemon.",

@@ -25,5 +25,5 @@ "main": "./dist/client",

"dependencies": {
"appcd-logger": "^1.1.0-0",
"appcd-response": "^1.1.0-0",
"appcd-util": "^1.1.0-0",
"appcd-logger": "^1.1.0",
"appcd-response": "^1.1.0",
"appcd-util": "^1.1.0",
"msgpack-lite": "^0.1.26",

@@ -35,3 +35,3 @@ "source-map-support": "^0.5.4",

"devDependencies": {
"appcd-gulp": "^1.1.0-0",
"appcd-gulp": "^1.1.1",
"gulp": "^3.9.1"

@@ -38,0 +38,0 @@ },

# appcd-client
The Node.js client for connecting to the Appc Daemon.
The Node.js client for connecting to the Appc Daemon. Internally appcd-client uses a WebSocket for
communicating with the server.
Visit https://github.com/appcelerator/appc-daemon for more information.
## Installation
npm i appcd-client
## Usage
```javascript
```js
import Client from 'appcd-client';
const client = new Client();
client

@@ -23,6 +31,26 @@ .request('/appcd/status')

## API Documentation
To subscribe to a service:
To generate API docs into static HTML files, run:
```js
client
.request({
path: '/appcd/status/system/loadavg',
type: 'subscribe'
})
.on('response', status => {
console.log(status);
client.disconnect();
})
.on('error', err => {
console.error('ERROR!');
console.error(err);
});
```
gulp docs
## Legal
This project is open source under the [Apache Public License v2][1] and is developed by
[Axway, Inc](http://www.axway.com/) and the community. Please read the [`LICENSE`][1] file included
in this distribution for more information.
[1]: https://github.com/appcelerator/appc-daemon/packages/appcd-client/LICENSE
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