From 92db1c98b4e5dcbef3950b2acc3395c18f888d67 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Mon, 13 Apr 2020 14:28:18 -0700 Subject: [PATCH] chore(package): Remove @feathersjs/primus packages from core --- packages/authentication-client/package.json | 2 - packages/authentication-client/src/core.ts | 2 +- packages/authentication-client/src/index.ts | 1 - .../test/integration/primus.test.ts | 45 -- packages/client/index.d.ts | 3 - packages/client/package.json | 14 +- packages/client/primus.js | 1 - packages/client/src/index.js | 2 - packages/client/src/primus.js | 1 - packages/client/test/sockets/primus.test.js | 29 - packages/client/test/sockets/socketio.test.js | 2 +- packages/client/webpack.config.js | 2 - packages/primus-client/.npmignore | 1 - packages/primus-client/CHANGELOG.md | 343 ------------ packages/primus-client/LICENSE | 22 - packages/primus-client/README.md | 23 - packages/primus-client/index.d.ts | 17 - packages/primus-client/lib/index.js | 32 -- packages/primus-client/package.json | 55 -- packages/primus-client/test/index.test.js | 80 --- packages/primus-client/test/server.js | 43 -- packages/primus/.npmignore | 1 - packages/primus/CHANGELOG.md | 519 ------------------ packages/primus/LICENSE | 22 - packages/primus/README.md | 23 - packages/primus/index.d.ts | 11 - packages/primus/lib/index.js | 88 --- packages/primus/package.json | 60 -- packages/primus/test/events.js | 221 -------- packages/primus/test/index.test.js | 215 -------- packages/primus/test/methods.js | 113 ---- 31 files changed, 9 insertions(+), 1984 deletions(-) delete mode 100644 packages/authentication-client/test/integration/primus.test.ts delete mode 100644 packages/client/primus.js delete mode 100644 packages/client/src/primus.js delete mode 100644 packages/client/test/sockets/primus.test.js delete mode 100644 packages/primus-client/.npmignore delete mode 100644 packages/primus-client/CHANGELOG.md delete mode 100644 packages/primus-client/LICENSE delete mode 100644 packages/primus-client/README.md delete mode 100644 packages/primus-client/index.d.ts delete mode 100644 packages/primus-client/lib/index.js delete mode 100644 packages/primus-client/package.json delete mode 100644 packages/primus-client/test/index.test.js delete mode 100644 packages/primus-client/test/server.js delete mode 100644 packages/primus/.npmignore delete mode 100644 packages/primus/CHANGELOG.md delete mode 100644 packages/primus/LICENSE delete mode 100644 packages/primus/README.md delete mode 100644 packages/primus/index.d.ts delete mode 100644 packages/primus/lib/index.js delete mode 100644 packages/primus/package.json delete mode 100644 packages/primus/test/events.js delete mode 100644 packages/primus/test/index.test.js delete mode 100644 packages/primus/test/methods.js diff --git a/packages/authentication-client/package.json b/packages/authentication-client/package.json index c0a8313502..aacfaa69bf 100644 --- a/packages/authentication-client/package.json +++ b/packages/authentication-client/package.json @@ -52,8 +52,6 @@ "devDependencies": { "@feathersjs/authentication-local": "^4.5.2", "@feathersjs/express": "^4.5.2", - "@feathersjs/primus": "^4.5.2", - "@feathersjs/primus-client": "^4.5.2", "@feathersjs/rest-client": "^4.5.2", "@feathersjs/socketio": "^4.5.2", "@feathersjs/socketio-client": "^4.5.2", diff --git a/packages/authentication-client/src/core.ts b/packages/authentication-client/src/core.ts index 77178872f4..fcba078c69 100644 --- a/packages/authentication-client/src/core.ts +++ b/packages/authentication-client/src/core.ts @@ -37,7 +37,7 @@ export class AuthenticationClient { options: AuthenticationClientOptions; constructor (app: Application, options: AuthenticationClientOptions) { - const socket = app.io || app.primus; + const socket = app.io || (app as any).primus; const storage = new StorageWrapper(app.get('storage') || options.storage); this.app = app; diff --git a/packages/authentication-client/src/index.ts b/packages/authentication-client/src/index.ts index d2f7d49354..ea1b2ad808 100644 --- a/packages/authentication-client/src/index.ts +++ b/packages/authentication-client/src/index.ts @@ -7,7 +7,6 @@ declare module '@feathersjs/feathers' { interface Application { io?: any; rest?: any; - primus?: any; authentication: AuthenticationClient; authenticate: AuthenticationClient['authenticate']; reAuthenticate: AuthenticationClient['reAuthenticate']; diff --git a/packages/authentication-client/test/integration/primus.test.ts b/packages/authentication-client/test/integration/primus.test.ts deleted file mode 100644 index f08f65f152..0000000000 --- a/packages/authentication-client/test/integration/primus.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -// @ts-ignore -import Primus from 'primus'; -// @ts-ignore -import Emitter from 'primus-emitter'; -import feathers, { Application } from '@feathersjs/feathers'; -import primusClient from '@feathersjs/primus-client'; -import primus from '@feathersjs/primus'; - -import authClient from '../../src'; -import getApp from './fixture'; -import commonTests from './commons'; - -const port = 8998; -const baseURL = `http://localhost:${port}`; -const Socket = Primus.createSocket({ - transformer: 'websockets', - plugin: { - emitter: Emitter - } -}); - -describe('@feathersjs/authentication-client Primus integration', () => { - let app: Application; - let server: any; - - before(() => { - app = getApp(feathers().configure(primus({ - transformer: 'websockets' - }))); - - server = app.listen(port); - }); - - after(() => server.close()); - - commonTests(() => app, () => { - return feathers() - .configure(primusClient(new Socket(baseURL), { timeout: 1000 })) - .configure(authClient()); - }, { - email: 'primusauth@feathersjs.com', - password: 'secrets', - provider: 'primus' - }); -}); diff --git a/packages/client/index.d.ts b/packages/client/index.d.ts index 70dff7ed41..362ed7b5eb 100644 --- a/packages/client/index.d.ts +++ b/packages/client/index.d.ts @@ -1,7 +1,6 @@ import feathers from '@feathersjs/feathers'; import authentication from '@feathersjs/authentication-client'; import errors from '@feathersjs/errors'; -import primus from '@feathersjs/primus-client'; import rest from '@feathersjs/rest-client'; import socketio from '@feathersjs/socketio-client'; @@ -13,14 +12,12 @@ export = feathersClient; type Feathers = typeof feathers; type FeathersAuthenticationClient = typeof authentication; type FeathersErrors = typeof errors; -type FeathersPrimusClient = typeof primus; type FeathersRestClient = typeof rest; type FeathersSocketIOClient = typeof socketio; interface FeathersClient extends Feathers { authentication: FeathersAuthenticationClient; errors: FeathersErrors; - primus: FeathersPrimusClient; rest: FeathersRestClient; socketio: FeathersSocketIOClient; } diff --git a/packages/client/package.json b/packages/client/package.json index 8994e0ff8f..8d9cc785ff 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@feathersjs/client", - "description": "A module that consolidates Feathers client modules for REST (jQuery, Request, Superagent) and Websocket (Socket.io, Primus) connections", + "description": "A module that consolidates Feathers client modules for REST and Websocket connections", "version": "4.5.2", "repository": { "type": "git", @@ -38,18 +38,18 @@ "last 2 versions", "IE 10" ], - "devDependencies": { - "@babel/core": "^7.9.0", - "@babel/preset-env": "^7.9.5", + "dependencies": { "@feathersjs/authentication-client": "^4.5.2", "@feathersjs/errors": "^4.5.2", "@feathersjs/express": "^4.5.2", "@feathersjs/feathers": "^4.5.2", - "@feathersjs/primus": "^4.5.2", - "@feathersjs/primus-client": "^4.5.2", "@feathersjs/rest-client": "^4.5.2", "@feathersjs/socketio": "^4.5.2", - "@feathersjs/socketio-client": "^4.5.2", + "@feathersjs/socketio-client": "^4.5.2" + }, + "devDependencies": { + "@babel/core": "^7.9.0", + "@babel/preset-env": "^7.9.0", "@feathersjs/tests": "^4.5.2", "babel-loader": "^8.1.0", "body-parser": "^1.19.0", diff --git a/packages/client/primus.js b/packages/client/primus.js deleted file mode 100644 index 53970a2f9c..0000000000 --- a/packages/client/primus.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist/primus'); diff --git a/packages/client/src/index.js b/packages/client/src/index.js index 806ad42dbd..2ec1dd457c 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -3,12 +3,10 @@ const errors = require('@feathersjs/errors'); const authentication = require('@feathersjs/authentication-client'); const rest = require('@feathersjs/rest-client'); const socketio = require('@feathersjs/socketio-client'); -const primus = require('@feathersjs/primus-client'); Object.assign(feathers, { errors, socketio, - primus, rest, authentication }); diff --git a/packages/client/src/primus.js b/packages/client/src/primus.js deleted file mode 100644 index 0def5eb195..0000000000 --- a/packages/client/src/primus.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@feathersjs/primus-client'); diff --git a/packages/client/test/sockets/primus.test.js b/packages/client/test/sockets/primus.test.js deleted file mode 100644 index 38c00275de..0000000000 --- a/packages/client/test/sockets/primus.test.js +++ /dev/null @@ -1,29 +0,0 @@ -const primus = require('@feathersjs/primus'); -const baseTests = require('@feathersjs/tests/lib/client'); - -const app = require('../fixture'); -const feathers = require('../../'); - -describe('Primus connector', function () { - const client = feathers(); - - let socket; - - before(function (done) { - this.server = app(function () { - this.configure(primus({ - transformer: 'websockets' - }, function (primus) { - socket = new primus.Socket('http://localhost:12012'); - client.configure(feathers.primus(socket)); - })); - }).listen(12012, done); - }); - - after(function () { - socket.socket.close(); - this.server.close(); - }); - - baseTests(client, 'todos'); -}); diff --git a/packages/client/test/sockets/socketio.test.js b/packages/client/test/sockets/socketio.test.js index 31ad9bff94..b6840767ad 100644 --- a/packages/client/test/sockets/socketio.test.js +++ b/packages/client/test/sockets/socketio.test.js @@ -3,7 +3,7 @@ const socketio = require('@feathersjs/socketio'); const baseTests = require('@feathersjs/tests/lib/client'); const app = require('../fixture'); -const feathers = require('../../'); +const feathers = require('../../src'); describe('Socket.io connector', function () { const socket = io('http://localhost:9988'); diff --git a/packages/client/webpack.config.js b/packages/client/webpack.config.js index 137839964f..96c35f70d9 100644 --- a/packages/client/webpack.config.js +++ b/packages/client/webpack.config.js @@ -61,8 +61,6 @@ module.exports = [ createConfig('rest', true), createConfig('socketio'), createConfig('socketio', true), - createConfig('primus'), - createConfig('primus', true), createConfig('authentication'), createConfig('authentication', true) ]; diff --git a/packages/primus-client/.npmignore b/packages/primus-client/.npmignore deleted file mode 100644 index 65e3ba2eda..0000000000 --- a/packages/primus-client/.npmignore +++ /dev/null @@ -1 +0,0 @@ -test/ diff --git a/packages/primus-client/CHANGELOG.md b/packages/primus-client/CHANGELOG.md deleted file mode 100644 index bee9b6c2d6..0000000000 --- a/packages/primus-client/CHANGELOG.md +++ /dev/null @@ -1,343 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) - - -### Bug Fixes - -* Change this reference in client libraries to explicitly passed app ([#1597](https://github.com/feathersjs/feathers/issues/1597)) ([4e4d10a](https://github.com/feathersjs/feathers/commit/4e4d10a)) - - - - - -## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) - - -### Bug Fixes - -* Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) - - - - - -# [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) - - -### Bug Fixes - -* Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) - - - - - -# [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - -# [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) - - -### Bug Fixes - -* Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) -* Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) - - -### Features - -* Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - - - - - -## [1.1.7](https://github.com/feathersjs/feathers/compare/@feathersjs/primus-client@1.1.6...@feathersjs/primus-client@1.1.7) (2019-01-02) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - - -## [1.1.6](https://github.com/feathersjs/feathers/compare/@feathersjs/primus-client@1.1.5...@feathersjs/primus-client@1.1.6) (2018-12-16) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - - -## [1.1.5](https://github.com/feathersjs/feathers/compare/@feathersjs/primus-client@1.1.4...@feathersjs/primus-client@1.1.5) (2018-10-25) - - -### Bug Fixes - -* Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - - - - - - -## [1.1.4](https://github.com/feathersjs/feathers/compare/@feathersjs/primus-client@1.1.3...@feathersjs/primus-client@1.1.4) (2018-09-21) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - - -## [1.1.3](https://github.com/feathersjs/feathers/compare/@feathersjs/primus-client@1.1.2...@feathersjs/primus-client@1.1.3) (2018-09-17) - -**Note:** Version bump only for package @feathersjs/primus-client - - - - - - -## [1.1.2](https://github.com/feathersjs/feathers/compare/@feathersjs/primus-client@1.1.1...@feathersjs/primus-client@1.1.2) (2018-09-02) - -**Note:** Version bump only for package @feathersjs/primus-client - - -## 1.1.1 - -- Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) - -## [v1.1.0](https://github.com/feathersjs/primus-client/tree/v1.1.0) (2018-02-09) -[Full Changelog](https://github.com/feathersjs/primus-client/compare/v1.0.3...v1.1.0) - -**Merged pull requests:** - -- Update @feathersjs/transport-commons to the latest version 🚀 [\#12](https://github.com/feathersjs/primus-client/pull/12) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - -## [v1.0.3](https://github.com/feathersjs/primus-client/tree/v1.0.3) (2018-02-05) -[Full Changelog](https://github.com/feathersjs/primus-client/compare/v1.0.2...v1.0.3) - -**Merged pull requests:** - -- Move to use transport-commons [\#11](https://github.com/feathersjs/primus-client/pull/11) ([daffl](https://github.com/daffl)) -- Update mocha to the latest version 🚀 [\#10](https://github.com/feathersjs/primus-client/pull/10) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update ws to the latest version 🚀 [\#9](https://github.com/feathersjs/primus-client/pull/9) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - -## [v1.0.2](https://github.com/feathersjs/primus-client/tree/v1.0.2) (2018-01-03) -[Full Changelog](https://github.com/feathersjs/primus-client/compare/v1.0.1...v1.0.2) - -**Merged pull requests:** - -- Update readme to correspond with latest release [\#8](https://github.com/feathersjs/primus-client/pull/8) ([daffl](https://github.com/daffl)) -- Update semistandard to the latest version 🚀 [\#7](https://github.com/feathersjs/primus-client/pull/7) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update feathers-memory to the latest version 🚀 [\#6](https://github.com/feathersjs/primus-client/pull/6) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update uws to the latest version 🚀 [\#5](https://github.com/feathersjs/primus-client/pull/5) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - -## [v1.0.1](https://github.com/feathersjs/primus-client/tree/v1.0.1) (2017-11-16) -[Full Changelog](https://github.com/feathersjs/primus-client/compare/v1.0.0...v1.0.1) - -**Merged pull requests:** - -- Add default export for better ES module \(TypeScript\) compatibility [\#4](https://github.com/feathersjs/primus-client/pull/4) ([daffl](https://github.com/daffl)) - -## [v1.0.0](https://github.com/feathersjs/primus-client/tree/v1.0.0) (2017-11-01) -[Full Changelog](https://github.com/feathersjs/primus-client/compare/v1.0.0-pre.2...v1.0.0) - -**Merged pull requests:** - -- Update dependencies for release [\#3](https://github.com/feathersjs/primus-client/pull/3) ([daffl](https://github.com/daffl)) - -## [v1.0.0-pre.2](https://github.com/feathersjs/primus-client/tree/v1.0.0-pre.2) (2017-10-23) -[Full Changelog](https://github.com/feathersjs/primus-client/compare/v1.0.0-pre.1...v1.0.0-pre.2) - -**Merged pull requests:** - -- Use scoped npm packages [\#2](https://github.com/feathersjs/primus-client/pull/2) ([daffl](https://github.com/daffl)) - -## [v1.0.0-pre.1](https://github.com/feathersjs/primus-client/tree/v1.0.0-pre.1) (2017-10-19) -**Merged pull requests:** - -- Update dependencies to enable Greenkeeper 🌴 [\#1](https://github.com/feathersjs/primus-client/pull/1) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/packages/primus-client/LICENSE b/packages/primus-client/LICENSE deleted file mode 100644 index 7139cac0dd..0000000000 --- a/packages/primus-client/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2020 Feathers - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/packages/primus-client/README.md b/packages/primus-client/README.md deleted file mode 100644 index 9c8ad9129e..0000000000 --- a/packages/primus-client/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# @feathersjs/primus-client - -[![CI](https://github.com/feathersjs/feathers/workflows/Node.js%20CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3A%22Node.js+CI%22) -[![Dependency Status](https://img.shields.io/david/feathersjs/feathers.svg?style=flat-square&path=packages/primus-client)](https://david-dm.org/feathersjs/feathers?path=packages/primus-client) -[![Download Status](https://img.shields.io/npm/dm/@feathersjs/primus-client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/primus-client) - -> Client services for Primus and feathers-primus - -## Installation - -``` -npm install @feathersjs/primus-client --save -``` - -## Documentation - -Refer to the [Feathers Primus client API documentation](https://docs.feathersjs.com/api/client/primus.html) for more details. - -## License - -Copyright (c) 2019 [Feathers contributors](https://github.com/feathersjs/client/graphs/contributors) - -Licensed under the [MIT license](LICENSE). diff --git a/packages/primus-client/index.d.ts b/packages/primus-client/index.d.ts deleted file mode 100644 index d394ee41ec..0000000000 --- a/packages/primus-client/index.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Primus removed its typings from the repo -// https://github.com/primus/primus/pull/623, as of 01/2018 there are none on -// DefinitelyTyped. - -declare const primusClient: FeathersPrimusClient; -export = primusClient; - -interface FeathersPrimusClient { - (socket: any, options?: primusClient.Options): () => void; - default: FeathersPrimusClient; -} - -declare namespace primusClient { - interface Options { - timeout?: number; - } -} diff --git a/packages/primus-client/lib/index.js b/packages/primus-client/lib/index.js deleted file mode 100644 index afd97f05b7..0000000000 --- a/packages/primus-client/lib/index.js +++ /dev/null @@ -1,32 +0,0 @@ -const Service = require('@feathersjs/transport-commons/client'); - -function primusClient (connection, options) { - if (!connection) { - throw new Error('Primus connection needs to be provided'); - } - - const defaultService = function (name) { - return new Service(Object.assign({}, options, { - name, - connection, - method: 'send' - })); - }; - - const initialize = function (app) { - if (typeof app.defaultService === 'function') { - throw new Error('Only one default client provider can be configured'); - } - - app.primus = connection; - app.defaultService = defaultService; - }; - - initialize.Service = Service; - initialize.service = defaultService; - - return initialize; -} - -module.exports = primusClient; -module.exports.default = primusClient; diff --git a/packages/primus-client/package.json b/packages/primus-client/package.json deleted file mode 100644 index e715045271..0000000000 --- a/packages/primus-client/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "@feathersjs/primus-client", - "description": "Client services for Primus and feathers-primus", - "version": "4.5.2", - "homepage": "https://feathersjs.com", - "main": "lib/index.js", - "types": "index.d.ts", - "keywords": [ - "feathers", - "feathers-plugin" - ], - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/feathers" - }, - "repository": { - "type": "git", - "url": "git://github.com/feathersjs/feathers.git" - }, - "author": { - "name": "Feathers contributors", - "email": "hello@feathersjs.com", - "url": "https://feathersjs.com" - }, - "contributors": [], - "bugs": { - "url": "https://github.com/feathersjs/feathers/issues" - }, - "engines": { - "node": ">= 12" - }, - "scripts": { - "test": "mocha --config ../../.mocharc.json" - }, - "directories": { - "lib": "lib" - }, - "publishConfig": { - "access": "public" - }, - "dependencies": { - "@feathersjs/transport-commons": "^4.5.2" - }, - "devDependencies": { - "@feathersjs/commons": "^4.5.2", - "@feathersjs/feathers": "^4.5.2", - "@feathersjs/primus": "^4.5.2", - "@feathersjs/tests": "^4.5.2", - "feathers-memory": "^4.1.0", - "mocha": "^7.1.1", - "ws": "^7.2.3" - }, - "gitHead": "9b9f0f13387341bdd320f1e66feda828fca2c9f2" -} diff --git a/packages/primus-client/test/index.test.js b/packages/primus-client/test/index.test.js deleted file mode 100644 index 25e480ddf4..0000000000 --- a/packages/primus-client/test/index.test.js +++ /dev/null @@ -1,80 +0,0 @@ -const assert = require('assert'); -const feathers = require('@feathersjs/feathers'); -const baseTests = require('@feathersjs/tests/lib/client'); - -const server = require('./server'); -const primus = require('../lib'); - -describe('feathers-primus/client', () => { - let srv; - let socket; - - const app = feathers().configure(primus({}, { timeout: 500 })); - const service = app.service('todos'); - - before(done => { - srv = server(primus => { - service.connection = socket = new primus.Socket('http://localhost:12012'); - }).listen(12012); - - srv.on('listening', () => done()); - }); - - after(done => { - socket.socket.close(); - srv.close(done); - }); - - it('exports default', () => { - assert.strictEqual(primus.default, primus); - }); - - it('throws an error with no connection', () => { - try { - feathers().configure(primus()); - assert.ok(false); - } catch (e) { - assert.strictEqual(e.message, 'Primus connection needs to be provided'); - } - }); - - it('app has the primus attribute', () => { - assert.ok(app.primus); - }); - - it('throws an error when configured twice', () => { - try { - app.configure(primus({})); - assert.ok(false, 'Should never get here'); - } catch (e) { - assert.strictEqual(e.message, 'Only one default client provider can be configured'); - } - }); - - it('can initialize a client instance', () => { - const init = primus(service.connection); - const todos = init.service('todos'); - - assert.ok(todos instanceof init.Service, 'Returned service is a client'); - - return todos.find().then(todos => assert.deepEqual(todos, [ // eslint-disable-line - { - text: 'some todo', - complete: false, - id: 0 - } - ])); - }); - - it('times out with error when using non-existent service', () => { - const notMe = app.service('not-me'); - // Hack because we didn't set the connection at the beginning - notMe.connection = socket; - - return notMe.remove(1).catch(e => { - assert.strictEqual(e.message, `Service 'not-me' not found`); - }); - }); - - baseTests(service); -}); diff --git a/packages/primus-client/test/server.js b/packages/primus-client/test/server.js deleted file mode 100644 index 95247b9464..0000000000 --- a/packages/primus-client/test/server.js +++ /dev/null @@ -1,43 +0,0 @@ -const feathers = require('@feathersjs/feathers'); -const primus = require('@feathersjs/primus'); -const { Service } = require('feathers-memory'); - -// eslint-disable-next-line no-extend-native -Object.defineProperty(Error.prototype, 'toJSON', { - value: function () { - var alt = {}; - - Object.getOwnPropertyNames(this).forEach(function (key) { - alt[key] = this[key]; - }, this); - - return alt; - }, - configurable: true -}); - -class TodoService extends Service { - get (id, params) { - if (params.query.error) { - return Promise.reject(new Error('Something went wrong')); - } - - return super.get(id) - .then(data => Object.assign({ query: params.query }, data)); - } -} - -module.exports = function (cb) { - const app = feathers() - .configure(primus({ - transformer: 'websockets' - }, cb)) - .use('/todos', new TodoService()); - - app.service('todos').create({ - text: 'some todo', - complete: false - }); - - return app; -}; diff --git a/packages/primus/.npmignore b/packages/primus/.npmignore deleted file mode 100644 index 65e3ba2eda..0000000000 --- a/packages/primus/.npmignore +++ /dev/null @@ -1 +0,0 @@ -test/ diff --git a/packages/primus/CHANGELOG.md b/packages/primus/CHANGELOG.md deleted file mode 100644 index ace2b8dc04..0000000000 --- a/packages/primus/CHANGELOG.md +++ /dev/null @@ -1,519 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [4.5.2](https://github.com/feathersjs/feathers/compare/v4.5.1...v4.5.2) (2020-03-04) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.5.1](https://github.com/feathersjs/feathers/compare/v4.5.0...v4.5.1) (2020-01-24) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -# [4.5.0](https://github.com/feathersjs/feathers/compare/v4.4.3...v4.5.0) (2020-01-18) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.4.3](https://github.com/feathersjs/feathers/compare/v4.4.1...v4.4.3) (2019-12-06) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.4.1](https://github.com/feathersjs/feathers/compare/v4.4.0...v4.4.1) (2019-11-27) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -# [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.3.10](https://github.com/feathersjs/feathers/compare/v4.3.9...v4.3.10) (2019-10-26) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.3.9](https://github.com/feathersjs/feathers/compare/v4.3.8...v4.3.9) (2019-10-26) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.3.7](https://github.com/feathersjs/feathers/compare/v4.3.6...v4.3.7) (2019-10-14) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.3.5](https://github.com/feathersjs/feathers/compare/v4.3.4...v4.3.5) (2019-10-07) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.3.4](https://github.com/feathersjs/feathers/compare/v4.3.3...v4.3.4) (2019-10-03) - - -### Bug Fixes - -* Typing improvements ([#1580](https://github.com/feathersjs/feathers/issues/1580)) ([7818aec](https://github.com/feathersjs/feathers/commit/7818aec)) - - - - - -## [4.3.3](https://github.com/feathersjs/feathers/compare/v4.3.2...v4.3.3) (2019-09-21) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.3.2](https://github.com/feathersjs/feathers/compare/v4.3.1...v4.3.2) (2019-09-16) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -## [4.3.1](https://github.com/feathersjs/feathers/compare/v4.3.0...v4.3.1) (2019-09-09) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -# [4.3.0](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.4...v4.3.0) (2019-08-27) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -# [4.3.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.3...v4.3.0-pre.4) (2019-08-22) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -# [4.3.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.2...v4.3.0-pre.3) (2019-08-19) - - -### Bug Fixes - -* Use WeakMap to connect socket to connection ([#1509](https://github.com/feathersjs/feathers/issues/1509)) ([64807e3](https://github.com/feathersjs/feathers/commit/64807e3)) - - - - - -# [4.3.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.3.0-pre.1...v4.3.0-pre.2) (2019-08-02) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -# [4.3.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.5...v4.3.0-pre.1) (2019-07-11) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -# [4.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.4...v4.0.0-pre.5) (2019-07-10) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -# [4.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.3...v4.0.0-pre.4) (2019-07-05) - -**Note:** Version bump only for package @feathersjs/primus - - - - - -# [4.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.2...v4.0.0-pre.3) (2019-06-01) - - -### Bug Fixes - -* Update dependencies and fix tests ([#1373](https://github.com/feathersjs/feathers/issues/1373)) ([d743a7f](https://github.com/feathersjs/feathers/commit/d743a7f)) - - - - - -# [4.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.1...v4.0.0-pre.2) (2019-05-15) - - -### Bug Fixes - -* Use `export =` in TypeScript definitions ([#1285](https://github.com/feathersjs/feathers/issues/1285)) ([12d0f4b](https://github.com/feathersjs/feathers/commit/12d0f4b)) - - -### Features - -* Add global disconnect event ([#1355](https://github.com/feathersjs/feathers/issues/1355)) ([85afcca](https://github.com/feathersjs/feathers/commit/85afcca)) - - - - - -# [4.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.0.0-pre.0...v4.0.0-pre.1) (2019-05-08) - - -### Features - -* Add params.headers to all transports when available ([#1303](https://github.com/feathersjs/feathers/issues/1303)) ([ebce79b](https://github.com/feathersjs/feathers/commit/ebce79b)) - - - - - -# [4.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v3.2.0-pre.1...v4.0.0-pre.0) (2019-04-21) - - -### Bug Fixes - -* Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) -* Update all dependencies to latest ([#1206](https://github.com/feathersjs/feathers/issues/1206)) ([e51e0f6](https://github.com/feathersjs/feathers/commit/e51e0f6)) -* **package:** update debug to version 3.0.0 ([#59](https://github.com/feathersjs/feathers/issues/59)) ([fedcf06](https://github.com/feathersjs/feathers/commit/fedcf06)) - - -### Features - -* Add TypeScript definitions ([#1275](https://github.com/feathersjs/feathers/issues/1275)) ([9dd6713](https://github.com/feathersjs/feathers/commit/9dd6713)) - - - - - -## [3.2.8](https://github.com/feathersjs/feathers/compare/@feathersjs/primus@3.2.7...@feathersjs/primus@3.2.8) (2019-01-02) - -**Note:** Version bump only for package @feathersjs/primus - - - - - - -## [3.2.7](https://github.com/feathersjs/feathers/compare/@feathersjs/primus@3.2.6...@feathersjs/primus@3.2.7) (2018-12-16) - -**Note:** Version bump only for package @feathersjs/primus - - - - - - -## [3.2.6](https://github.com/feathersjs/feathers/compare/@feathersjs/primus@3.2.5...@feathersjs/primus@3.2.6) (2018-10-25) - - -### Bug Fixes - -* Make Mocha a proper devDependency for every repository ([#1053](https://github.com/feathersjs/feathers/issues/1053)) ([9974803](https://github.com/feathersjs/feathers/commit/9974803)) - - - - - - -## [3.2.5](https://github.com/feathersjs/feathers/compare/@feathersjs/primus@3.2.4...@feathersjs/primus@3.2.5) (2018-09-21) - -**Note:** Version bump only for package @feathersjs/primus - - - - - - -## [3.2.4](https://github.com/feathersjs/feathers/compare/@feathersjs/primus@3.2.3...@feathersjs/primus@3.2.4) (2018-09-17) - -**Note:** Version bump only for package @feathersjs/primus - - - - - - -## [3.2.3](https://github.com/feathersjs/feathers/compare/@feathersjs/primus@3.2.2...@feathersjs/primus@3.2.3) (2018-09-02) - -**Note:** Version bump only for package @feathersjs/primus - - -## 3.2.2 - -- Migrate to Monorepo ([feathers#462](https://github.com/feathersjs/feathers/issues/462)) - -## [v3.2.1](https://github.com/feathersjs/primus/tree/v3.2.1) (2018-06-03) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.2.0...v3.2.1) - -**Merged pull requests:** - -- Update uberproto to the latest version 🚀 [\#80](https://github.com/feathersjs/primus/pull/80) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update uws to the latest version 🚀 [\#79](https://github.com/feathersjs/primus/pull/79) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update ws to the latest version 🚀 [\#78](https://github.com/feathersjs/primus/pull/78) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - -## [v3.2.0](https://github.com/feathersjs/primus/tree/v3.2.0) (2018-02-09) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.1.0...v3.2.0) - -**Merged pull requests:** - -- Update @feathersjs/transport-commons to the latest version 🚀 [\#77](https://github.com/feathersjs/primus/pull/77) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - -## [v3.1.0](https://github.com/feathersjs/primus/tree/v3.1.0) (2018-01-30) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.0.3...v3.1.0) - -**Merged pull requests:** - -- Update dependency to @feathersjs/transport-commons [\#76](https://github.com/feathersjs/primus/pull/76) ([daffl](https://github.com/daffl)) - -## [v3.0.3](https://github.com/feathersjs/primus/tree/v3.0.3) (2018-01-18) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.0.2...v3.0.3) - -**Merged pull requests:** - -- Remove setMaxListeners [\#75](https://github.com/feathersjs/primus/pull/75) ([daffl](https://github.com/daffl)) -- Update mocha to the latest version 🚀 [\#74](https://github.com/feathersjs/primus/pull/74) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update ws to the latest version 🚀 [\#73](https://github.com/feathersjs/primus/pull/73) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - -## [v3.0.2](https://github.com/feathersjs/primus/tree/v3.0.2) (2018-01-03) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.0.1...v3.0.2) - -**Merged pull requests:** - -- Update documentation to correspond with latest release [\#72](https://github.com/feathersjs/primus/pull/72) ([daffl](https://github.com/daffl)) -- Update semistandard to the latest version 🚀 [\#71](https://github.com/feathersjs/primus/pull/71) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update feathers-memory to the latest version 🚀 [\#70](https://github.com/feathersjs/primus/pull/70) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update uws to the latest version 🚀 [\#69](https://github.com/feathersjs/primus/pull/69) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - -## [v3.0.1](https://github.com/feathersjs/primus/tree/v3.0.1) (2017-11-16) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.0.0...v3.0.1) - -**Merged pull requests:** - -- Add default ES module default exports to make TypeScript integration … [\#68](https://github.com/feathersjs/primus/pull/68) ([daffl](https://github.com/daffl)) - -## [v3.0.0](https://github.com/feathersjs/primus/tree/v3.0.0) (2017-11-01) -[Full Changelog](https://github.com/feathersjs/primus/compare/v2.2.1...v3.0.0) - -**Merged pull requests:** - -- Update dependencies for release [\#67](https://github.com/feathersjs/primus/pull/67) ([daffl](https://github.com/daffl)) -- Throw an error when using an incompatible version of Feathers [\#66](https://github.com/feathersjs/primus/pull/66) ([daffl](https://github.com/daffl)) - -## [v2.2.1](https://github.com/feathersjs/primus/tree/v2.2.1) (2017-10-31) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.0.0-pre.4...v2.2.1) - -**Merged pull requests:** - -- Add an error when trying to use earlier versions with Feathers v3 [\#65](https://github.com/feathersjs/primus/pull/65) ([daffl](https://github.com/daffl)) - -## [v3.0.0-pre.4](https://github.com/feathersjs/primus/tree/v3.0.0-pre.4) (2017-10-25) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.0.0-pre.3...v3.0.0-pre.4) - -## [v3.0.0-pre.3](https://github.com/feathersjs/primus/tree/v3.0.0-pre.3) (2017-10-23) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.0.0-pre.2...v3.0.0-pre.3) - -**Merged pull requests:** - -- Updates for Feathers v3 \(Buzzard\) [\#64](https://github.com/feathersjs/primus/pull/64) ([daffl](https://github.com/daffl)) -- Update to use npm scopes [\#63](https://github.com/feathersjs/primus/pull/63) ([daffl](https://github.com/daffl)) - -## [v3.0.0-pre.2](https://github.com/feathersjs/primus/tree/v3.0.0-pre.2) (2017-10-19) -[Full Changelog](https://github.com/feathersjs/primus/compare/v3.0.0-pre.1...v3.0.0-pre.2) - -## [v3.0.0-pre.1](https://github.com/feathersjs/primus/tree/v3.0.0-pre.1) (2017-10-18) -[Full Changelog](https://github.com/feathersjs/primus/compare/v2.2.0...v3.0.0-pre.1) - -**Closed issues:** - -- An in-range update of babel-core is breaking the build 🚨 [\#56](https://github.com/feathersjs/primus/issues/56) -- Update npm version [\#55](https://github.com/feathersjs/primus/issues/55) - -**Merged pull requests:** - -- Compatibility and updates for Feathers v3 [\#62](https://github.com/feathersjs/primus/pull/62) ([daffl](https://github.com/daffl)) -- Update to new plugin infrastructure [\#61](https://github.com/feathersjs/primus/pull/61) ([daffl](https://github.com/daffl)) -- Update mocha to the latest version 🚀 [\#60](https://github.com/feathersjs/primus/pull/60) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update debug to the latest version 🚀 [\#59](https://github.com/feathersjs/primus/pull/59) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update primus type definition [\#58](https://github.com/feathersjs/primus/pull/58) ([Sieabah](https://github.com/Sieabah)) -- Update uws to the latest version 🚀 [\#57](https://github.com/feathersjs/primus/pull/57) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) - -## [v2.2.0](https://github.com/feathersjs/primus/tree/v2.2.0) (2017-05-29) -[Full Changelog](https://github.com/feathersjs/primus/compare/v2.1.0...v2.2.0) - -**Closed issues:** - -- An in-range update of feathers-hooks is breaking the build 🚨 [\#53](https://github.com/feathersjs/primus/issues/53) -- An in-range update of debug is breaking the build 🚨 [\#52](https://github.com/feathersjs/primus/issues/52) -- An in-range update of primus is breaking the build 🚨 [\#51](https://github.com/feathersjs/primus/issues/51) -- An in-range update of uws is breaking the build 🚨 [\#50](https://github.com/feathersjs/primus/issues/50) -- Expose headers and remote ip on feathers object [\#46](https://github.com/feathersjs/primus/issues/46) -- docs are out of date [\#28](https://github.com/feathersjs/primus/issues/28) - -**Merged pull requests:** - -- Update ws to the latest version 🚀 [\#54](https://github.com/feathersjs/primus/pull/54) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update semistandard to the latest version 🚀 [\#49](https://github.com/feathersjs/primus/pull/49) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update feathers-hooks to the latest version 🚀 [\#48](https://github.com/feathersjs/primus/pull/48) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update dependencies to enable Greenkeeper 🌴 [\#47](https://github.com/feathersjs/primus/pull/47) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) -- Update uws to version 0.14.0 🚀 [\#45](https://github.com/feathersjs/primus/pull/45) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - -## [v2.1.0](https://github.com/feathersjs/primus/tree/v2.1.0) (2017-03-01) -[Full Changelog](https://github.com/feathersjs/primus/compare/v2.0.0...v2.1.0) - -**Closed issues:** - -- Issues with using feathers-primus/client and feathers-client [\#41](https://github.com/feathersjs/primus/issues/41) -- Any breaking change in 2.0.0? [\#39](https://github.com/feathersjs/primus/issues/39) - -**Merged pull requests:** - -- Update uws to version 0.13.0 🚀 [\#44](https://github.com/feathersjs/primus/pull/44) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Typescript Definitions [\#43](https://github.com/feathersjs/primus/pull/43) ([AbraaoAlves](https://github.com/AbraaoAlves)) -- Update ws to version 2.0.0 🚀 [\#42](https://github.com/feathersjs/primus/pull/42) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Update uws to version 0.12.0 🚀 [\#37](https://github.com/feathersjs/primus/pull/37) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - -## [v2.0.0](https://github.com/feathersjs/primus/tree/v2.0.0) (2016-12-02) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.4.1...v2.0.0) - -**Closed issues:** - -- uws [\#36](https://github.com/feathersjs/primus/issues/36) - -**Merged pull requests:** - -- Update feathers-memory to version 1.0.0 🚀 [\#35](https://github.com/feathersjs/primus/pull/35) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Update feathers-commons to version 0.8.0 🚀 [\#34](https://github.com/feathersjs/primus/pull/34) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Swapping rm to rifraf and using relative path to \_mocha for windows support [\#33](https://github.com/feathersjs/primus/pull/33) ([corymsmith](https://github.com/corymsmith)) -- Update primus to version 6.0.5 🚀 [\#32](https://github.com/feathersjs/primus/pull/32) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- jshint —\> semistandard [\#30](https://github.com/feathersjs/primus/pull/30) ([corymsmith](https://github.com/corymsmith)) -- adding code coverage [\#29](https://github.com/feathersjs/primus/pull/29) ([ekryski](https://github.com/ekryski)) -- Update feathers-memory to version 0.8.0 🚀 [\#24](https://github.com/feathersjs/primus/pull/24) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Update mocha to version 3.0.0 🚀 [\#22](https://github.com/feathersjs/primus/pull/22) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - -## [v1.4.1](https://github.com/feathersjs/primus/tree/v1.4.1) (2016-05-23) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.4.0...v1.4.1) - -**Merged pull requests:** - -- Update feathers-socket-commons to version 2.0.0 🚀 [\#18](https://github.com/feathersjs/primus/pull/18) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#17](https://github.com/feathersjs/primus/pull/17) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - -## [v1.4.0](https://github.com/feathersjs/primus/tree/v1.4.0) (2016-04-28) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.3.3...v1.4.0) - -**Merged pull requests:** - -- Implement options for setting client timeout [\#16](https://github.com/feathersjs/primus/pull/16) ([daffl](https://github.com/daffl)) -- Update feathers-socket-commons to version 1.0.0 🚀 [\#15](https://github.com/feathersjs/primus/pull/15) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- More tests for error cases [\#14](https://github.com/feathersjs/primus/pull/14) ([daffl](https://github.com/daffl)) - -## [v1.3.3](https://github.com/feathersjs/primus/tree/v1.3.3) (2016-04-16) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.3.2...v1.3.3) - -**Merged pull requests:** - -- Increase the default number of maximum event listeners [\#13](https://github.com/feathersjs/primus/pull/13) ([daffl](https://github.com/daffl)) -- Update feathers-memory to version 0.7.0 🚀 [\#12](https://github.com/feathersjs/primus/pull/12) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Update primus to version 5.0.1 🚀 [\#11](https://github.com/feathersjs/primus/pull/11) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Update primus to version 5.0.0 🚀 [\#10](https://github.com/feathersjs/primus/pull/10) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - -## [v1.3.2](https://github.com/feathersjs/primus/tree/v1.3.2) (2016-02-11) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.3.1...v1.3.2) - -**Merged pull requests:** - -- Allow to instantiate a client instance [\#9](https://github.com/feathersjs/primus/pull/9) ([daffl](https://github.com/daffl)) - -## [v1.3.1](https://github.com/feathersjs/primus/tree/v1.3.1) (2016-02-09) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.3.0...v1.3.1) - -**Merged pull requests:** - -- Update feathers-commons to version 0.7.0 🚀 [\#8](https://github.com/feathersjs/primus/pull/8) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) - -## [v1.3.0](https://github.com/feathersjs/primus/tree/v1.3.0) (2016-02-09) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.2.1...v1.3.0) - -**Merged pull requests:** - -- Update feathers-memory to version 0.6.0 🚀 [\#6](https://github.com/feathersjs/primus/pull/6) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Update lodash to version 4.0.1 🚀 [\#5](https://github.com/feathersjs/primus/pull/5) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) -- Adding nsp check [\#4](https://github.com/feathersjs/primus/pull/4) ([marshallswain](https://github.com/marshallswain)) - -## [v1.2.1](https://github.com/feathersjs/primus/tree/v1.2.1) (2016-01-21) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.2.0...v1.2.1) - -## [v1.2.0](https://github.com/feathersjs/primus/tree/v1.2.0) (2016-01-21) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.1.0...v1.2.0) - -**Merged pull requests:** - -- Refactoring to use feathers-socket-commons that support event filtering [\#3](https://github.com/feathersjs/primus/pull/3) ([daffl](https://github.com/daffl)) - -## [v1.1.0](https://github.com/feathersjs/primus/tree/v1.1.0) (2016-01-10) -[Full Changelog](https://github.com/feathersjs/primus/compare/v1.0.0...v1.1.0) - -**Merged pull requests:** - -- feathers-primus/client service and tests [\#1](https://github.com/feathersjs/primus/pull/1) ([daffl](https://github.com/daffl)) - -## [v1.0.0](https://github.com/feathersjs/primus/tree/v1.0.0) (2016-01-03) - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/packages/primus/LICENSE b/packages/primus/LICENSE deleted file mode 100644 index 7139cac0dd..0000000000 --- a/packages/primus/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2020 Feathers - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/packages/primus/README.md b/packages/primus/README.md deleted file mode 100644 index a0a189f74e..0000000000 --- a/packages/primus/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# @feathersjs/primus - -[![CI](https://github.com/feathersjs/feathers/workflows/Node.js%20CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3A%22Node.js+CI%22) -[![Dependency Status](https://img.shields.io/david/feathersjs/feathers.svg?style=flat-square&path=packages/primus)](https://david-dm.org/feathersjs/feathers?path=packages/primus) -[![Download Status](https://img.shields.io/npm/dm/@feathersjs/primus.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/primus) - -> The Feathers Primus real-time API provider - -## Installation - -``` -npm install @feathersjs/primus --save -``` - -## Documentation - -Refer to the [Feathers Primus API documentation](https://docs.feathersjs.com/api/primus.html) for more details. - -## License - -Copyright (c) 2019 [Feathers contributors](https://github.com/feathersjs/client/graphs/contributors) - -Licensed under the [MIT license](LICENSE). diff --git a/packages/primus/index.d.ts b/packages/primus/index.d.ts deleted file mode 100644 index 7226d5c3ea..0000000000 --- a/packages/primus/index.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Primus removed its typings from the repo -// https://github.com/primus/primus/pull/623, as of 01/2018 there are none on -// DefinitelyTyped. - -declare const configurePrimus: FeathersPrimus; -export = configurePrimus; - -interface FeathersPrimus { - (options?: any, callback?: (primus: any) => void): (app: any) => void; - default: FeathersPrimus; -} diff --git a/packages/primus/lib/index.js b/packages/primus/lib/index.js deleted file mode 100644 index 3ebc343185..0000000000 --- a/packages/primus/lib/index.js +++ /dev/null @@ -1,88 +0,0 @@ -const { socket: commons } = require('@feathersjs/transport-commons'); -const makeDebug = require('debug'); -const Proto = require('uberproto'); -const Primus = require('primus'); -const http = require('http'); -const Emitter = require('primus-emitter'); - -const debug = makeDebug('@feathersjs/primus'); - -function configurePrimus (config, configurer) { - return function (app) { - // Returns the connection object - const getParams = spark => spark.request.feathers; - // Mapping from connection back to its socket - const socketMap = new WeakMap(); - - if (!app.version || app.version < '3.0.0') { - throw new Error('@feathersjs/primus is not compatible with this version of Feathers. Use the latest at @feathersjs/feathers.'); - } - - const done = new Promise(resolve => { - Proto.mixin({ - listen (...args) { - if (typeof this._super === 'function') { - // If `listen` already exists - // usually the case when the app has been expressified - return this._super(...args); - } - - const server = http.createServer(); - - this.setup(server); - - return server.listen(...args); - }, - - setup (server) { - debug('Setting up Primus'); - - if (!this.primus) { - const primus = this.primus = new Primus(server, config); - - primus.plugin('emitter', Emitter); - - primus.use('feathers', function (req, res, next) { - req.feathers = { - headers: Object.keys(req.headers).reduce((result, key) => { - const value = req.headers[key]; - - if (typeof value !== 'object') { - result[key] = value; - } - - return result; - }, {}), - provider: 'primus' - }; - - next(); - }, 0); - - primus.on('connection', spark => socketMap.set(getParams(spark), spark)); - primus.on('disconnection', spark => app.emit('disconnect', getParams(spark))); - } - - if (typeof configurer === 'function') { - debug('Calling Primus configuration function'); - configurer.call(this, this.primus); - } - - resolve(this.primus); - - return this._super.apply(this, arguments); - } - }, app); - }); - - app.configure(commons({ - done, - socketMap, - getParams, - emit: 'send' - })); - }; -} - -module.exports = configurePrimus; -module.exports.default = configurePrimus; diff --git a/packages/primus/package.json b/packages/primus/package.json deleted file mode 100644 index 60e31d2c8f..0000000000 --- a/packages/primus/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "@feathersjs/primus", - "description": "The Feathers Primus real-time API provider", - "version": "4.5.2", - "homepage": "https://feathersjs.com", - "main": "lib/", - "types": "index.d.ts", - "keywords": [ - "feathers", - "feathers-plugin" - ], - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/feathers" - }, - "repository": { - "type": "git", - "url": "git://github.com/feathersjs/feathers.git" - }, - "author": { - "name": "Feathers contributors", - "email": "hello@feathersjs.com", - "url": "https://feathersjs.com" - }, - "contributors": [], - "bugs": { - "url": "https://github.com/feathersjs/feathers/issues" - }, - "engines": { - "node": ">= 10" - }, - "scripts": { - "test": "mocha --config ../../.mocharc.json" - }, - "directories": { - "lib": "lib" - }, - "publishConfig": { - "access": "public" - }, - "dependencies": { - "@feathersjs/transport-commons": "^4.5.2", - "debug": "^4.1.1", - "primus": "^7.3.4", - "primus-emitter": "^3.1.1", - "uberproto": "^2.0.6" - }, - "devDependencies": { - "@feathersjs/commons": "^4.5.2", - "@feathersjs/express": "^4.5.2", - "@feathersjs/feathers": "^4.5.2", - "@feathersjs/tests": "^4.5.2", - "feathers-memory": "^4.1.0", - "lodash": "^4.17.15", - "mocha": "^7.1.1", - "ws": "^7.2.3" - }, - "gitHead": "9b9f0f13387341bdd320f1e66feda828fca2c9f2" -} diff --git a/packages/primus/test/events.js b/packages/primus/test/events.js deleted file mode 100644 index 784303a181..0000000000 --- a/packages/primus/test/events.js +++ /dev/null @@ -1,221 +0,0 @@ -const assert = require('assert'); -const { verify } = require('@feathersjs/tests/lib/fixture'); - -module.exports = function (name, options) { - const call = (method, ...args) => { - return new Promise((resolve, reject) => { - const { socket } = options; - const emitArgs = [ method, name ].concat(args); - - socket.send(...emitArgs, (error, result) => - error ? reject(error) : resolve(result) - ); - }); - }; - - const verifyEvent = (done, callback) => { - return function (data) { - try { - callback(data); - done(); - } catch (error) { - done(error); - } - }; - }; - - describe(`Basic ${name} service events`, () => { - let socket; - let connection; - - before(done => { - setTimeout(() => { - socket = new options.primus.Socket('http://localhost:7888'); - - options.app.once('connection', conn => { - connection = conn; - - options.app.channel('default').join(connection); - options.app.publish(() => options.app.channel('default')); - - done(); - }); - }, 250); - }); - - after(() => { - socket.socket.close(); - }); - - it(`${name} created`, done => { - let original = { - name: `created event` - }; - - socket.once(`${name} created`, verifyEvent(done, data => - verify.create(original, data) - )); - - call('create', original); - }); - - it(`${name} updated`, done => { - let original = { - name: `updated event` - }; - - socket.once(`${name} updated`, verifyEvent(done, data => - verify.update(10, original, data) - )); - - call('update', 10, original); - }); - - it(`${name} patched`, done => { - let original = { - name: `patched event` - }; - - socket.once(`${name} patched`, verifyEvent(done, data => - verify.patch(12, original, data) - )); - - call('patch', 12, original); - }); - - it(`${name} removed`, done => { - socket.once(`${name} removed`, verifyEvent(done, data => - verify.remove(333, data) - )); - - call('remove', 333); - }); - - it(`${name} custom events`, done => { - let service = options.app.service(name); - let original = { - name: `created event` - }; - let old = service.create; - - service.create = function (data) { - this.emit('log', { message: 'Custom log event', data }); - service.create = old; - return old.apply(this, arguments); - }; - - socket.once(`${name} log`, verifyEvent(done, data => { - // Primus does something that makes strict equal fail - assert.deepEqual(data, { // eslint-disable-line - message: `Custom log event`, data: original - }); - service.create = old; - })); - - call('create', original); - }); - }); - - describe('Event channels', () => { - const eventName = `${name} created`; - let connections; - let sockets; - - before(done => { - let counter = 0; - - connections = []; - sockets = []; - - options.app.on('connection', connection => { - if (connection.channel) { - counter++; - - options.app.channel(connection.channel).join(connection); - - connections.push(connection); - - if (counter === 3) { - done(); - } - } - }); - - sockets.push( - new options.primus.Socket('http://localhost:7888?channel=first'), - new options.primus.Socket('http://localhost:7888?channel=second'), - new options.primus.Socket('http://localhost:7888?channel=second') - ); - }); - - after(done => { - let counter = 0; - - sockets.forEach(socket => { - socket.once('close', () => { - if (++counter === sockets.length) { - done(); - } - }); - socket.socket.close(); - }); - }); - - it(`filters '${eventName}' event for a single channel`, done => { - const service = options.app.service(name); - const [ socket, otherSocket ] = sockets; - const onError = () => { - done(new Error('Should not get this event')); - }; - - service.publish('created', data => - options.app.channel(data.room) - ); - - socket.once(eventName, data => { - assert.strictEqual(data.room, 'first'); - otherSocket.removeListener(eventName, onError); - done(); - }); - - otherSocket.once(eventName, onError); - - service.create({ - text: 'Event dispatching test', - room: 'first' - }); - }); - - it(`filters '${name} created' event for a channel with multiple connections`, done => { - let counter = 0; - - const service = options.app.service(name); - const [ otherSocket, socketOne, socketTwo ] = sockets; - const onError = () => { - done(new Error('Should not get this event')); - }; - const onEvent = data => { - counter++; - assert.strictEqual(data.room, 'second'); - - if (++counter === 2) { - otherSocket.removeListener(eventName, onError); - done(); - } - }; - - service.publish('created', data => - options.app.channel(data.room) - ); - - socketOne.once(eventName, onEvent); - socketTwo.once(eventName, onEvent); - otherSocket.once(eventName, onError); - - service.create({ - text: 'Event dispatching test', - room: 'second' - }); - }); - }); -}; diff --git a/packages/primus/test/index.test.js b/packages/primus/test/index.test.js deleted file mode 100644 index 67b0a61ad2..0000000000 --- a/packages/primus/test/index.test.js +++ /dev/null @@ -1,215 +0,0 @@ -const feathers = require('@feathersjs/feathers'); -const express = require('@feathersjs/express'); -const assert = require('assert'); -const axios = require('axios'); -const omit = require('lodash/omit'); -const extend = require('lodash/extend'); -const { Service } = require('@feathersjs/tests/lib/fixture'); - -const primus = require('../lib'); -const methodTests = require('./methods.js'); -const eventTests = require('./events'); - -describe('@feathersjs/primus', () => { - let options = { - socketParams: { - user: { name: 'David' }, - provider: 'primus' - } - }; - - before(done => { - const errorHook = function (hook) { - if (hook.params.query.hookError) { - throw new Error(`Error from ${hook.method}, ${hook.type} hook`); - } - }; - const app = options.app = feathers() - .configure(primus({ - transformer: 'websockets' - }, function (primus) { - primus.authorize(function (req, done) { - req.feathers.user = { name: 'David' }; - options.socketParams.headers = req.feathers.headers; - - const { channel } = req.query; - - if (channel) { - req.feathers.channel = channel; - } - - done(); - }); - - options.primus = primus; - options.socket = new primus.Socket('http://localhost:7888'); - })) - .use('todo', Service); - - app.service('todo').hooks({ - before: { get: errorHook } - }); - - options.server = app.listen(7888, function () { - app.use('tasks', Service); - app.service('tasks').hooks({ - before: { get: errorHook } - }); - done(); - }); - }); - - after(done => { - options.socket.socket.close(); - options.server.close(done); - }); - - it('exports default', () => { - assert.strictEqual(primus, primus.default); - }); - - it('is CommonJS compatible', () => { - assert.strictEqual(typeof require('../lib'), 'function'); - }); - - it('runs primus before setup (#131)', done => { - let counter = 0; - const app = feathers() - .configure(primus({ - transformer: 'websockets' - }, function () { - assert.strictEqual(counter, 0); - counter++; - })) - .use('/todos', { - find () { - return Promise.resolve([]); - }, - setup (app) { - assert.ok(app.primus); - assert.strictEqual(counter, 1, 'Primus configuration ran first'); - } - }); - - const srv = app.listen(9119); - srv.on('listening', () => srv.close(done)); - }); - - it('expressified app works', done => { - const expected = { message: 'Hello world' }; - const app = express(feathers()) - .configure(primus({ - transformer: 'websockets' - })) - .use('/test', (req, res) => res.json(expected)); - - const srv = app.listen(8993).on('listening', async () => { - const url = 'http://localhost:8993/test'; - - const { data } = await axios({ url }); - - assert.deepStrictEqual(data, expected); - srv.close(done); - }); - }); - - it('Passes handshake as service parameters.', function (done) { - const service = options.app.service('todo'); - const old = { - find: service.find, - create: service.create, - update: service.update, - remove: service.remove - }; - - service.find = function (params) { - assert.deepStrictEqual(omit(params, 'query', 'route', 'connection'), options.socketParams, - 'Handshake parameters passed on proper position'); - - return old.find.apply(this, arguments); - }; - - service.create = function (data, params) { - assert.deepStrictEqual(omit(params, 'query', 'route', 'connection'), options.socketParams, - 'Passed handshake parameters'); - - return old.create.apply(this, arguments); - }; - - service.update = function (id, data, params) { - assert.deepStrictEqual(params, extend({ - connection: options.socketParams, - route: {}, - query: { - test: 'param' - } - }, options.socketParams), 'Passed handshake parameters as query'); - - return old.update.apply(this, arguments); - }; - - options.socket.send('create', 'todo', {}, {}, error => { - assert.ok(!error); - - options.socket.send('update', 'todo', 1, {}, { test: 'param' }, () => { - assert.ok(!error); - extend(service, old); - done(); - }); - }); - }); - - it('Missing parameters in socket call works. (#88)', function (done) { - const service = options.app.service('todo'); - const old = { - find: service.find - }; - - service.find = function (params) { - assert.deepStrictEqual(omit(params, 'query', 'route', 'connection'), options.socketParams, - 'Handshake parameters passed on proper position'); - - return old.find.apply(this, arguments); - }; - - options.socket.send('find', 'todo', function () { - extend(service, old); - done(); - }); - }); - - it('connection and disconnect events (#1243, #1238)', (done) => { - const { app, primus } = options; - const mySocket = new primus.Socket('http://localhost:7888?channel=dctest'); - - app.on('connection', connection => { - if (connection.channel === 'dctest') { - assert.strictEqual(connection.channel, 'dctest'); - app.once('disconnect', disconnection => { - assert.strictEqual(disconnection.channel, 'dctest'); - done(); - }); - setTimeout(() => mySocket.end(), 100); - } - }); - - assert.ok(mySocket); - }); - - describe('Service method calls', () => { - describe('(\'method\', \'service\') event format', () => { - describe('Service', () => methodTests('todo', options)); - describe('Dynamic Service', () => methodTests('todo', options)); - }); - - describe('(\'service::method\') legacy event format', () => { - describe('Service', () => methodTests('tasks', options, true)); - describe('Dynamic Service', () => methodTests('tasks', options, true)); - }); - }); - - describe('Service events', () => { - describe('Service', () => eventTests('todo', options)); - describe('Dynamic Service', () => eventTests('tasks', options)); - }); -}); diff --git a/packages/primus/test/methods.js b/packages/primus/test/methods.js deleted file mode 100644 index ed7ab7828b..0000000000 --- a/packages/primus/test/methods.js +++ /dev/null @@ -1,113 +0,0 @@ -const assert = require('assert'); -const { verify } = require('@feathersjs/tests/lib/fixture'); - -module.exports = function (name, options, legacy = false) { - const call = (method, ...args) => - new Promise((resolve, reject) => { - const { socket } = options; - const prefix = legacy ? [ `${name}::${method}` ] - : [ method, name ]; - const emitArgs = prefix.concat(args); - - socket.send(...emitArgs, (error, result) => - error ? reject(error) : resolve(result) - ); - } - ); - - it(`invalid arguments cause an error`, () => - call('find', 1, {}).catch(e => - assert.strictEqual(e.message, 'Too many arguments for \'find\' method') - ) - ); - - it('.find', () => - call('find', {}).then(data => verify.find(data)) - ); - - it('.get', () => - call('get', 'laundry').then(data => verify.get('laundry', data)) - ); - - it('.get with error', () => - call('get', 'laundry', { error: true }) - .then(() => assert.ok(false, 'Should never get here')) - .catch(error => assert.strictEqual(error.message, 'Something for laundry went wrong')) - ); - - it('.get with runtime error', () => - call('get', 'laundry', { runtimeError: true }) - .then(() => assert.ok(false, 'Should never get here')) - .catch(error => assert.strictEqual(error.message, 'thingThatDoesNotExist is not defined')) - ); - - it('.get with error in hook', () => - call('get', 'laundry', { hookError: true }) - .then(() => assert.ok(false, 'Should never get here')) - .catch(error => assert.strictEqual(error.message, 'Error from get, before hook')) - ); - - it(`.create`, () => { - let original = { - name: `creating` - }; - - return call('create', original, {}) - .then(data => verify.create(original, data)); - }); - - it(`.create without parameters`, () => { - let original = { - name: `creating again` - }; - - return call('create', original) - .then(data => verify.create(original, data)); - }); - - it('.update', () => { - let original = { - name: 'updating' - }; - - return call('update', 23, original, {}) - .then(data => verify.update(23, original, data)); - }); - - it('.update many', () => { - const original = { - name: `updating`, - many: true - }; - - return call('update', null, original) - .then(data => verify.update(null, original, data)); - }); - - it('.patch', () => { - let original = { - name: `patching` - }; - - return call('patch', 25, original) - .then(data => verify.patch(25, original, data)); - }); - - it('.patch many', () => { - let original = { - name: `patching`, - many: true - }; - - return call('patch', null, original) - .then(data => verify.patch(null, original, data)); - }); - - it('.remove', () => - call('remove', 11).then(data => verify.remove(11, data)) - ); - - it('.remove many', () => - call('remove', null).then(data => verify.remove(null, data)) - ); -};