@feathersjs/transport-commons
Advanced tools
Comparing version 4.1.1 to 4.1.2
# Change Log | ||
## [v4.1.1](https://github.com/feathersjs/transport-commons/tree/v4.1.1) (2018-07-03) | ||
[Full Changelog](https://github.com/feathersjs/transport-commons/compare/v4.1.0...v4.1.1) | ||
**Merged pull requests:** | ||
- Properly dispatch arrays that do not come from Feathers hook events [\#77](https://github.com/feathersjs/transport-commons/pull/77) ([daffl](https://github.com/daffl)) | ||
## [v4.1.0](https://github.com/feathersjs/transport-commons/tree/v4.1.0) (2018-06-28) | ||
@@ -4,0 +11,0 @@ [Full Changelog](https://github.com/feathersjs/transport-commons/compare/v4.0.2...v4.1.0) |
{ | ||
"name": "@feathersjs/transport-commons", | ||
"description": "Shared functionality for websocket providers", | ||
"version": "4.1.1", | ||
"homepage": "https://github.com/feathersjs/transport-commons", | ||
"version": "4.1.2", | ||
"homepage": "https://feathersjs.com", | ||
"main": "lib/", | ||
@@ -14,3 +14,3 @@ "keywords": [ | ||
"type": "git", | ||
"url": "git://github.com/feathersjs/transport-commons.git" | ||
"url": "git://github.com/feathersjs/feathers.git" | ||
}, | ||
@@ -24,3 +24,3 @@ "author": { | ||
"bugs": { | ||
"url": "https://github.com/feathersjs/transport-commons/issues" | ||
"url": "https://github.com/feathersjs/feathers/issues" | ||
}, | ||
@@ -31,24 +31,13 @@ "engines": { | ||
"scripts": { | ||
"publish": "git push origin --tags && npm run changelog && git push origin", | ||
"changelog": "github_changelog_generator && git add CHANGELOG.md && git commit -am \"Updating changelog\"", | ||
"release:pre": "npm version prerelease && npm publish --tag pre --access public", | ||
"release:patch": "npm version patch && npm publish --access public", | ||
"release:minor": "npm version minor && npm publish --access public", | ||
"release:major": "npm version major && npm publish --access public", | ||
"lint": "semistandard --fix", | ||
"mocha": "mocha --opts mocha.opts", | ||
"coverage": "istanbul cover node_modules/mocha/bin/_mocha -- --opts mocha.opts", | ||
"test": "npm run lint && npm run coverage" | ||
"test": "../../node_modules/.bin/mocha --opts ../../mocha.opts" | ||
}, | ||
"semistandard": { | ||
"env": [ | ||
"mocha" | ||
] | ||
}, | ||
"directories": { | ||
"lib": "lib" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@feathersjs/commons": "^1.4.0", | ||
"@feathersjs/errors": "^3.0.0", | ||
"@feathersjs/errors": "^3.3.1", | ||
"debug": "^3.1.0", | ||
@@ -59,7 +48,5 @@ "lodash": "^4.17.10", | ||
"devDependencies": { | ||
"@feathersjs/feathers": "^3.0.0", | ||
"istanbul": "^1.1.0-alpha.1", | ||
"mocha": "^5.0.0", | ||
"semistandard": "^12.0.0" | ||
} | ||
"@feathersjs/feathers": "^3.0.0" | ||
}, | ||
"gitHead": "a618e325acc797dfb895f69310e55075838dfdeb" | ||
} |
106
README.md
# @feathersjs/transport-commons | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/feathersjs/transport-commons.svg)](https://greenkeeper.io/) | ||
[![Build Status](https://travis-ci.org/feathersjs/transport-commons.png?branch=master)](https://travis-ci.org/feathersjs/transport-commons) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/87c506753cb9fc6a8b87/maintainability)](https://codeclimate.com/github/feathersjs/transport-commons/maintainability) | ||
[![Test Coverage](https://api.codeclimate.com/v1/badges/87c506753cb9fc6a8b87/test_coverage)](https://codeclimate.com/github/feathersjs/transport-commons/test_coverage) | ||
[![Dependency Status](https://img.shields.io/david/feathersjs/transport-commons.svg?style=flat-square)](https://david-dm.org/feathersjs/transport-commons) | ||
[![Build Status](https://travis-ci.org/feathersjs/feathers.png?branch=master)](https://travis-ci.org/feathersjs/feathers) | ||
[![Dependency Status](https://img.shields.io/david/feathersjs/feathers.svg?style=flat-square&path=packages/transport-commons)](https://david-dm.org/feathersjs/feathers?path=packages/transport-commons) | ||
[![Download Status](https://img.shields.io/npm/dm/@feathersjs/transport-commons.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/transport-commons) | ||
> Shared functionality for Feathers API transports like [@feathers/socketio](https://github.com/feathersjs/socketio) and [@feathersjs/primus](https://github.com/feathersjs/primus). Only intended to be used internally. | ||
> Shared functionality for Feathers API transports like `@feathers/socketio` and `@feathersjs/primus`. Only intended to be used internally. | ||
@@ -17,98 +13,2 @@ ## About | ||
`lib/client.js` is a base socket service client | ||
`lib/index.js` returns a configurable function and requires the following options: | ||
- `done` - A Promise that resolves once the real-time protocol server has been set up | ||
- `emit` - The name of the method to emit data to a socket (`'emit'` for Socket.io and `'send'` for Primus) | ||
- `socketKey` - A string or ES6 Symbol which stores the actual socket connection | ||
- `getParams` - A function that returns the Feathers connection options for a socket | ||
## Channels | ||
Channels provide channel functionality for bi-directional Feathers service providers. It is e.g. used by the Socket.io and Primus provider to quickly determine what messages to send to connected clients. | ||
``` | ||
const channels = require('@feathersjs/transport-commons/lib/channels'); | ||
``` | ||
## Documentation | ||
### `app.channel(... names)` | ||
Returns a named or combined channel object. | ||
```js | ||
const channel = app.channel('test'); // return a `test` channel | ||
channel.join(connection); // join a channel | ||
channel.leave(connection); // leave a channel | ||
channel.filter(connection => {}) // return a new channel with filtered connections | ||
channel.length // return the number of connections | ||
channel.connections // all connections in this channel | ||
const combined = app.channel('test', 'other'); // return a combined channel | ||
combined.join(connection); // join the `test` and `other` channel | ||
combined.leave(connection); // leave the `test` and `other` channel | ||
channel.filter(connection => {}) // return a new channel with filtered connections (connections will only be iterated once) | ||
combined.length // return the number of connections | ||
combined.connections // all connections in the combined channel (if a connection is in multiple channels it will only show once) | ||
``` | ||
### `app.service('servicename').publish(event, callback)`, `app.service('servicename').publish(callback)` | ||
Register a publishing callback for a service and event (or all events) that returns a (named or combined) channel. | ||
```js | ||
app.use('/test', { | ||
create(data) { | ||
return Promise.resolve(data); | ||
} | ||
}); | ||
// `created` event for the `test` service | ||
app.service('test').publish('created', (data, hook) => | ||
app.channel('*') | ||
); | ||
// `created` event for the `test` service, sending different data to two different channels | ||
app.service('test').publish('created', (data, hook) => { | ||
return [ | ||
app.channel('admins'), | ||
app.channel('users').send(_.omit(data, 'groups', 'email')) | ||
]; | ||
}); | ||
// All events for all services | ||
app.publish((data, hook) => | ||
app.channel('*') | ||
); | ||
// All `created` events for all services | ||
app.publish('created', (data, hook) => | ||
app.channel('*') | ||
); | ||
// All events for `test` service | ||
app.service('test').publish((data, hook) => | ||
app.channel('*') | ||
); | ||
``` | ||
### `app.on('publish', function(event, channel, hook) {})` | ||
An event that will be sent every time a service event that has connections to publish to happens. `channel` is a combined channel with all connections to publish the event to. | ||
> _Note:_ If there are no channels or connections the `publish` event will not be sent. | ||
```js | ||
app.on('publish', (event, channel, hook) => { | ||
channel.connections.forEach(connection => { | ||
// Do something with `connection` | ||
}); | ||
}); | ||
``` | ||
## License | ||
@@ -115,0 +15,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
36072
14
18
Updated@feathersjs/errors@^3.3.1