-
-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
packages: Adding @feathersjs/client package (#1013)
- Loading branch information
Showing
39 changed files
with
4,716 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
version: "2" # required to adjust maintainability checks | ||
checks: | ||
argument-count: | ||
config: | ||
threshold: 6 | ||
complex-logic: | ||
config: | ||
threshold: 6 | ||
file-lines: | ||
config: | ||
threshold: 250 | ||
method-complexity: | ||
config: | ||
threshold: 6 | ||
method-count: | ||
config: | ||
threshold: 20 | ||
method-lines: | ||
config: | ||
threshold: 80 | ||
nested-control-flow: | ||
config: | ||
threshold: 6 | ||
return-statements: | ||
config: | ||
threshold: 6 | ||
similar-code: | ||
config: | ||
threshold: 3 | ||
identical-code: | ||
config: | ||
threshold: 3 | ||
exclude_patterns: | ||
- "lib/foundation.js" | ||
- "**/test/*" | ||
- "**/dist/*" | ||
- "**/*.dist.js" | ||
- "**/templates/*" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,6 @@ node_modules | |
|
||
# IDEs | ||
.idea | ||
|
||
# Distributables | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const server = require('./packages/client/test/server'); | ||
|
||
module.exports = function (grunt) { | ||
const browsers = [{ | ||
browserName: 'firefox', | ||
platform: 'Windows 10' | ||
}, { | ||
browserName: 'googlechrome', | ||
platform: 'linux' | ||
}, { | ||
browserName: 'safari', | ||
platform: 'OS X 10.11', | ||
version: '9.0' | ||
}, { | ||
browserName: 'internet explorer', | ||
platform: 'Windows 8', | ||
version: '10' | ||
}, { | ||
browserName: 'internet explorer', | ||
platform: 'Windows 10', | ||
version: '11' | ||
}]; | ||
|
||
grunt.registerTask('server', 'Start the test server', function () { | ||
server.on('listening', () => { | ||
console.log('Test server listening on port 3000'); | ||
}); | ||
}); | ||
|
||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
server: {}, | ||
|
||
'saucelabs-mocha': { | ||
all: { | ||
options: { | ||
urls: [ | ||
'http://127.0.0.1:3000/packages/client/browser/index.html' | ||
], | ||
browsers: browsers, | ||
build: process.env.TRAVIS_JOB_ID, | ||
testname: 'feathers-client mocha tests', | ||
throttled: 1 | ||
} | ||
} | ||
}, | ||
watch: {} | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-saucelabs'); | ||
|
||
grunt.registerTask('default', [ 'server', 'saucelabs-mocha' ]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ "loose": true } | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
src/ | ||
test/ | ||
browser/ | ||
!dist/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# @feathersjs/client | ||
|
||
[![Greenkeeper badge](https://badges.greenkeeper.io/feathersjs/client.svg)](https://greenkeeper.io/) | ||
|
||
[![Build Status](https://travis-ci.org/feathersjs/client.png?branch=master)](https://travis-ci.org/feathersjs/client) | ||
[![Dependency Status](https://img.shields.io/david/feathersjs/client.svg?style=flat-square)](https://david-dm.org/feathersjs/client) | ||
[![Download Status](https://img.shields.io/npm/dm/@feathersjs/client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/client) | ||
|
||
[![Sauce Test Status](https://saucelabs.com/browser-matrix/feathersjs.svg)](https://saucelabs.com/u/feathersjs) | ||
|
||
> A client for Feathers services supporting many different transport libraries. | ||
## About | ||
|
||
While Feathers and its modules can be used on the client with an NPM compatible module loader like [Browserify](http://browserify.org/), [Webpack](https://webpack.github.io/) or [StealJS](http://stealjs.com), `@feathersjs/client` consolidates a standard set of client plugins into a single distributable that can be used standalone in the browser or with other module loaders (like [RequireJS](http://requirejs.org/)) that don't support NPM. The following modules are included: | ||
|
||
- [@feathersjs/feathers](https://github.com/feathersjs/feathers) as `feathers` (or the default module export) | ||
- [@feathersjs/errors](https://github.com/feathersjs/errors) as `feathers.errors` | ||
- [@feathersjs/rest-client](https://github.com/feathersjs/rest-client) as `feathers.rest` | ||
- [@feathersjs/socketio-client](https://github.com/feathersjs/socketio-client) as `feathers.socketio` | ||
- [@feathers/primus-client](https://github.com/feathersjs/primus-client) as `feathers.primus` | ||
- [@feathersjs/authentication-client](https://github.com/feathersjs/authentication-client) as `feathers.authentication` | ||
|
||
In the browser a client that connects to the local server via websockets can be initialized like this: | ||
|
||
```html | ||
<script type="text/javascript" src="//unpkg.com/socket.io-client@1.7.3/dist/socket.io.js"></script> | ||
<script type="text/javascript" src="//unpkg.com/@feathersjs/client@^3.0.0/dist/feathers.js"></script> | ||
<script type="text/javascript"> | ||
var socket = io(); | ||
var client = feathers() | ||
.configure(feathers.socketio(socket)); | ||
var todoService = client.service('todos'); | ||
todoService.on('created', function(todo) { | ||
console.log('Someone created a todo', todo); | ||
}); | ||
todoService.create({ | ||
description: 'Todo from client' | ||
}); | ||
</script> | ||
``` | ||
|
||
For the full documentation see [the Feathers documentation](http://docs.feathersjs.com/clients/feathers.html). | ||
|
||
## License | ||
|
||
Copyright (c) 2018 [Feathers contributors](https://github.com/feathersjs/client/graphs/contributors) | ||
|
||
Licensed under the [MIT license](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./dist/authentication'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Mocha</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" /> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/core-js/2.5.7/core.min.js" type="text/javascript"></script> | ||
<script src="/socket.io/socket.io.js" type="text/javascript"></script> | ||
<script src="/node_modules/mocha/mocha.js" type="text/javascript"></script> | ||
<script>mocha.setup('bdd');</script> | ||
<script src="../dist/feathers.js" type="text/javascript"></script> | ||
<script src="./test.dist.js" type="text/javascript"></script> | ||
<script> | ||
onload = function(){ | ||
var runner = mocha.run(); | ||
var failedTests = []; | ||
|
||
runner.on('end', function(){ | ||
window.mochaResults = runner.stats; | ||
window.mochaResults.reports = failedTests; | ||
}); | ||
|
||
runner.on('fail', logFailure); | ||
|
||
function logFailure(test, err) { | ||
var flattenTitles = function(test) { | ||
var titles = []; | ||
|
||
while (test.parent.title) { | ||
titles.push(test.parent.title); | ||
test = test.parent; | ||
} | ||
|
||
return titles.reverse(); | ||
}; | ||
|
||
failedTests.push({ | ||
name: test.title, | ||
result: false, | ||
message: err.message, | ||
stack: err.stack, | ||
titles: flattenTitles(test) | ||
}); | ||
} | ||
}; | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.