Skip to content

Commit

Permalink
packages: Adding @feathersjs/client package (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl authored Sep 21, 2018
1 parent af97818 commit aa4276f
Show file tree
Hide file tree
Showing 39 changed files with 4,716 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .codeclimate.yml
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/*"

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ node_modules

# IDEs
.idea

# Distributables
dist/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ install: npm install
script:
- npm test
- npm run test:generators
- npm run test:client
services: mongodb
node_js:
- node
Expand Down
53 changes: 53 additions & 0 deletions Gruntfile.js
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' ]);
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"install": "lerna bootstrap",
"lint": "semistandard packages/**/*.js --fix",
"test": "npm run lint && nyc lerna run test --ignore generator-**",
"test:client": "grunt",
"test:generators": "lerna run test --scope generator-** --stream --concurrency 1"
},
"semistandard": {
Expand All @@ -33,6 +34,9 @@
"lerna": "^3.4.0",
"mocha": "^5.2.0",
"nyc": "^13.0.1",
"semistandard": "^12.0.1"
"semistandard": "^12.0.1",
"grunt": "^1.0.3",
"grunt-cli": "^1.3.1",
"grunt-saucelabs": "^9.0.0"
}
}
8 changes: 8 additions & 0 deletions packages/client/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": [
[
"@babel/preset-env",
{ "loose": true }
]
]
}
4 changes: 4 additions & 0 deletions packages/client/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/
test/
browser/
!dist/
735 changes: 735 additions & 0 deletions packages/client/CHANGELOG.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions packages/client/LICENSE
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.

51 changes: 51 additions & 0 deletions packages/client/README.md
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).
1 change: 1 addition & 0 deletions packages/client/authentication.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/authentication');
51 changes: 51 additions & 0 deletions packages/client/browser/index.html
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>
Loading

0 comments on commit aa4276f

Please sign in to comment.