From ea31b09ee2ee2440edaf3e057e9e50aa7d7e52af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 11 Jan 2017 20:13:38 +0100 Subject: [PATCH] Add with-featherjs example --- examples/with-featherjs/.editorconfig | 13 +++++ examples/with-featherjs/.gitignore | 35 ++++++++++++ examples/with-featherjs/.jshintrc | 29 ++++++++++ examples/with-featherjs/.npmignore | 30 ++++++++++ examples/with-featherjs/LICENSE | 22 ++++++++ .../with-featherjs/NEDB_BASE_PATH/users.db | 0 examples/with-featherjs/README.md | 52 ++++++++++++++++++ examples/with-featherjs/config/default.json | 11 ++++ .../with-featherjs/config/production.json | 11 ++++ examples/with-featherjs/package.json | 48 ++++++++++++++++ examples/with-featherjs/pages/about.vue | 16 ++++++ examples/with-featherjs/pages/index.vue | 6 ++ examples/with-featherjs/src/app.js | 30 ++++++++++ examples/with-featherjs/src/hooks/index.js | 13 +++++ examples/with-featherjs/src/index.js | 15 +++++ .../with-featherjs/src/middleware/index.js | 12 ++++ .../with-featherjs/src/middleware/nuxt.js | 22 ++++++++ .../src/services/authentication/index.js | 14 +++++ examples/with-featherjs/src/services/index.js | 11 ++++ .../src/services/user/hooks/index.js | 51 +++++++++++++++++ .../with-featherjs/src/services/user/index.js | 35 ++++++++++++ examples/with-featherjs/static/favicon.ico | Bin 0 -> 5533 bytes examples/with-featherjs/test/app.test.js | 38 +++++++++++++ .../test/services/user/index.test.js | 10 ++++ 24 files changed, 524 insertions(+) create mode 100644 examples/with-featherjs/.editorconfig create mode 100644 examples/with-featherjs/.gitignore create mode 100644 examples/with-featherjs/.jshintrc create mode 100644 examples/with-featherjs/.npmignore create mode 100644 examples/with-featherjs/LICENSE create mode 100644 examples/with-featherjs/NEDB_BASE_PATH/users.db create mode 100644 examples/with-featherjs/README.md create mode 100644 examples/with-featherjs/config/default.json create mode 100644 examples/with-featherjs/config/production.json create mode 100644 examples/with-featherjs/package.json create mode 100644 examples/with-featherjs/pages/about.vue create mode 100644 examples/with-featherjs/pages/index.vue create mode 100644 examples/with-featherjs/src/app.js create mode 100644 examples/with-featherjs/src/hooks/index.js create mode 100644 examples/with-featherjs/src/index.js create mode 100644 examples/with-featherjs/src/middleware/index.js create mode 100644 examples/with-featherjs/src/middleware/nuxt.js create mode 100644 examples/with-featherjs/src/services/authentication/index.js create mode 100644 examples/with-featherjs/src/services/index.js create mode 100644 examples/with-featherjs/src/services/user/hooks/index.js create mode 100644 examples/with-featherjs/src/services/user/index.js create mode 100644 examples/with-featherjs/static/favicon.ico create mode 100644 examples/with-featherjs/test/app.test.js create mode 100644 examples/with-featherjs/test/services/user/index.test.js diff --git a/examples/with-featherjs/.editorconfig b/examples/with-featherjs/.editorconfig new file mode 100644 index 0000000000..e717f5eb63 --- /dev/null +++ b/examples/with-featherjs/.editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/examples/with-featherjs/.gitignore b/examples/with-featherjs/.gitignore new file mode 100644 index 0000000000..815b7b2a27 --- /dev/null +++ b/examples/with-featherjs/.gitignore @@ -0,0 +1,35 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript + +lib/ +data/ + +# Nuxt +.nuxt/ +dist/ diff --git a/examples/with-featherjs/.jshintrc b/examples/with-featherjs/.jshintrc new file mode 100644 index 0000000000..1c271e2c7f --- /dev/null +++ b/examples/with-featherjs/.jshintrc @@ -0,0 +1,29 @@ +{ + "node": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": "nofunc", + "newcap": false, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": false, + "strict": false, + "trailing": true, + "smarttabs": true, + "white": false, + "globals": { + "it": true, + "describe": true, + "before": true, + "beforeEach": true, + "after": true, + "afterEach": true + } +} diff --git a/examples/with-featherjs/.npmignore b/examples/with-featherjs/.npmignore new file mode 100644 index 0000000000..40e14ef091 --- /dev/null +++ b/examples/with-featherjs/.npmignore @@ -0,0 +1,30 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript + +data/ diff --git a/examples/with-featherjs/LICENSE b/examples/with-featherjs/LICENSE new file mode 100644 index 0000000000..40b7881afa --- /dev/null +++ b/examples/with-featherjs/LICENSE @@ -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. + diff --git a/examples/with-featherjs/NEDB_BASE_PATH/users.db b/examples/with-featherjs/NEDB_BASE_PATH/users.db new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/with-featherjs/README.md b/examples/with-featherjs/README.md new file mode 100644 index 0000000000..709584aca5 --- /dev/null +++ b/examples/with-featherjs/README.md @@ -0,0 +1,52 @@ +# with-featherjs + +> Nuxt.js with FeatherJS + +## About + +This project uses [Feathers](http://feathersjs.com). An open source web framework for building modern real-time applications. + +## Getting Started + +Getting up and running is as easy as 1, 2, 3. + +1. Make sure you have [NodeJS](https://nodejs.org/) and [npm](https://www.npmjs.com/) installed. +2. Install your dependencies + + ```bash + npm install + ``` + +3. Start your app + + ```bash + npm run dev + ``` + +## Production + +```bash +npm run build +npm start +``` + +## Testing + +Simply run `npm test` and all your tests in the `test/` directory will be run. + +## Scaffolding + +Feathers has a powerful command line interface. Here are a few things it can do: + +```bash +$ npm install -g feathers-cli # Install Feathers CLI + +$ feathers generate service # Generate a new Service +$ feathers generate hook # Generate a new Hook +$ feathers generate model # Generate a new Model +$ feathers help # Show all commands +``` + +## Help + +For more information on all the things you can do with Feathers visit [docs.feathersjs.com](http://docs.feathersjs.com). diff --git a/examples/with-featherjs/config/default.json b/examples/with-featherjs/config/default.json new file mode 100644 index 0000000000..dd3a541a21 --- /dev/null +++ b/examples/with-featherjs/config/default.json @@ -0,0 +1,11 @@ +{ + "host": "localhost", + "port": 3030, + "nedb": "../data/", + "auth": { + "token": { + "secret": "B/UmaCQUlnIn8lNq7h7KjkM5aqlRz+RkiZ/v3cPL72LYavj6d68HtxXfnrb5T70mdZxHjPNsNfBR7YE1sE6Hdg==" + }, + "local": {} + } +} diff --git a/examples/with-featherjs/config/production.json b/examples/with-featherjs/config/production.json new file mode 100644 index 0000000000..6690c58474 --- /dev/null +++ b/examples/with-featherjs/config/production.json @@ -0,0 +1,11 @@ +{ + "host": "with-featherjs-app.feathersjs.com", + "port": 80, + "nedb": "NEDB_BASE_PATH", + "auth": { + "token": { + "secret": "FEATHERS_AUTH_SECRET" + }, + "local": {} + } +} diff --git a/examples/with-featherjs/package.json b/examples/with-featherjs/package.json new file mode 100644 index 0000000000..dbf0274ba0 --- /dev/null +++ b/examples/with-featherjs/package.json @@ -0,0 +1,48 @@ +{ + "name": "with-featherjs", + "description": "Nuxt.js with FeatherJS", + "version": "0.0.0", + "homepage": "", + "main": "src/", + "keywords": [ + "feathers" + ], + "license": "MIT", + "repository": {}, + "author": {}, + "contributors": [], + "bugs": {}, + "engines": { + "node": ">= 0.12.0" + }, + "scripts": { + "test": "npm run jshint && npm run mocha", + "jshint": "jshint src/. test/. --config", + "dev": "DEBUG=nuxt:* node src/", + "build": "nuxt build", + "start": "NODE_ENV=production node src/", + "mocha": "mocha test/ --recursive --timeout=30000" + }, + "dependencies": { + "body-parser": "^1.15.2", + "compression": "^1.6.2", + "cors": "^2.8.1", + "feathers": "^2.0.3", + "feathers-authentication": "^0.7.12", + "feathers-configuration": "^0.3.3", + "feathers-errors": "^2.5.0", + "feathers-hooks": "^1.7.1", + "feathers-nedb": "^2.6.0", + "feathers-rest": "^1.6.0", + "feathers-socketio": "^1.4.2", + "nedb": "^1.8.0", + "nuxt": "^0.9.5", + "passport": "^0.3.2", + "winston": "^2.3.0" + }, + "devDependencies": { + "jshint": "^2.9.4", + "mocha": "^3.2.0", + "request": "^2.79.0" + } +} diff --git a/examples/with-featherjs/pages/about.vue b/examples/with-featherjs/pages/about.vue new file mode 100644 index 0000000000..068bba1b42 --- /dev/null +++ b/examples/with-featherjs/pages/about.vue @@ -0,0 +1,16 @@ + + + diff --git a/examples/with-featherjs/pages/index.vue b/examples/with-featherjs/pages/index.vue new file mode 100644 index 0000000000..9655d7d866 --- /dev/null +++ b/examples/with-featherjs/pages/index.vue @@ -0,0 +1,6 @@ + diff --git a/examples/with-featherjs/src/app.js b/examples/with-featherjs/src/app.js new file mode 100644 index 0000000000..35dc0dc4f0 --- /dev/null +++ b/examples/with-featherjs/src/app.js @@ -0,0 +1,30 @@ +'use strict'; + +const path = require('path'); +const compress = require('compression'); +const cors = require('cors'); +const feathers = require('feathers'); +const configuration = require('feathers-configuration'); +const hooks = require('feathers-hooks'); +const rest = require('feathers-rest'); +const bodyParser = require('body-parser'); +const socketio = require('feathers-socketio'); +const middleware = require('./middleware'); +const services = require('./services'); + +const app = feathers(); + +app.configure(configuration(path.join(__dirname, '..'))); + +app.use(compress()) +.options('*', cors()) +.use(cors()) +.use(bodyParser.json()) +.use(bodyParser.urlencoded({ extended: true })) +.configure(hooks()) +.configure(rest()) +.configure(socketio()) +.configure(services) +.configure(middleware); + +module.exports = app; diff --git a/examples/with-featherjs/src/hooks/index.js b/examples/with-featherjs/src/hooks/index.js new file mode 100644 index 0000000000..1662947e75 --- /dev/null +++ b/examples/with-featherjs/src/hooks/index.js @@ -0,0 +1,13 @@ +'use strict'; + +// Add any common hooks you want to share across services in here. +// +// Below is an example of how a hook is written and exported. Please +// see http://docs.feathersjs.com/hooks/readme.html for more details +// on hooks. + +exports.myHook = function(options) { + return function(hook) { + console.log('My custom global hook ran. Feathers is awesome!'); + }; +}; diff --git a/examples/with-featherjs/src/index.js b/examples/with-featherjs/src/index.js new file mode 100644 index 0000000000..5adedb5981 --- /dev/null +++ b/examples/with-featherjs/src/index.js @@ -0,0 +1,15 @@ +'use strict'; + +const app = require('./app'); +const port = app.get('port'); + +process.on('nuxt:build:done', (err) => { + if (err) { + console.error(err); + process.exit(1); + } + const server = app.listen(port); + server.on('listening', () => + console.log(`Feathers application started on ${app.get('host')}:${port}`) + ); +}); diff --git a/examples/with-featherjs/src/middleware/index.js b/examples/with-featherjs/src/middleware/index.js new file mode 100644 index 0000000000..5b02e5c679 --- /dev/null +++ b/examples/with-featherjs/src/middleware/index.js @@ -0,0 +1,12 @@ +'use strict'; + +const nuxt = require('./nuxt'); + +module.exports = function() { + // Add your custom middleware here. Remember, that + // just like Express the order matters, so error + // handling middleware should go last. + const app = this; + + app.use(nuxt); +}; diff --git a/examples/with-featherjs/src/middleware/nuxt.js b/examples/with-featherjs/src/middleware/nuxt.js new file mode 100644 index 0000000000..d473826111 --- /dev/null +++ b/examples/with-featherjs/src/middleware/nuxt.js @@ -0,0 +1,22 @@ +const resolve = require('path').resolve; +const Nuxt = require('nuxt'); + +// Setup nuxt.js +let config = {}; +try { + config = require('../../nuxt.config.js'); +} catch (e) {} +config.rootDir = resolve(__dirname, '..', '..'); +config.dev = process.env.NODE_ENV !== 'production'; +const nuxt = new Nuxt(config); +if (config.dev) { + nuxt.build().then(() => { + process.emit('nuxt:build:done'); + }); +} else { + process.nextTick(() => process.emit('nuxt:build:done')); +} +// Add nuxt.js middleware +module.exports = function (req, res) { + nuxt.render(req, res); +}; diff --git a/examples/with-featherjs/src/services/authentication/index.js b/examples/with-featherjs/src/services/authentication/index.js new file mode 100644 index 0000000000..d5a66b56a7 --- /dev/null +++ b/examples/with-featherjs/src/services/authentication/index.js @@ -0,0 +1,14 @@ +'use strict'; + +const authentication = require('feathers-authentication'); + + +module.exports = function() { + const app = this; + + let config = app.get('auth'); + + + + app.configure(authentication(config)); +}; diff --git a/examples/with-featherjs/src/services/index.js b/examples/with-featherjs/src/services/index.js new file mode 100644 index 0000000000..dd7c9d040f --- /dev/null +++ b/examples/with-featherjs/src/services/index.js @@ -0,0 +1,11 @@ +'use strict'; +const authentication = require('./authentication'); +const user = require('./user'); + +module.exports = function() { + const app = this; + + + app.configure(authentication); + app.configure(user); +}; diff --git a/examples/with-featherjs/src/services/user/hooks/index.js b/examples/with-featherjs/src/services/user/hooks/index.js new file mode 100644 index 0000000000..1cbed8a51a --- /dev/null +++ b/examples/with-featherjs/src/services/user/hooks/index.js @@ -0,0 +1,51 @@ +'use strict'; + +const globalHooks = require('../../../hooks'); +const hooks = require('feathers-hooks'); +const auth = require('feathers-authentication').hooks; + +exports.before = { + all: [], + find: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated() + ], + get: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated(), + auth.restrictToOwner({ ownerField: '_id' }) + ], + create: [ + auth.hashPassword() + ], + update: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated(), + auth.restrictToOwner({ ownerField: '_id' }) + ], + patch: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated(), + auth.restrictToOwner({ ownerField: '_id' }) + ], + remove: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated(), + auth.restrictToOwner({ ownerField: '_id' }) + ] +}; + +exports.after = { + all: [hooks.remove('password')], + find: [], + get: [], + create: [], + update: [], + patch: [], + remove: [] +}; diff --git a/examples/with-featherjs/src/services/user/index.js b/examples/with-featherjs/src/services/user/index.js new file mode 100644 index 0000000000..b3c4e89a42 --- /dev/null +++ b/examples/with-featherjs/src/services/user/index.js @@ -0,0 +1,35 @@ +'use strict'; + +const path = require('path'); +const NeDB = require('nedb'); +const service = require('feathers-nedb'); +const hooks = require('./hooks'); + +module.exports = function(){ + const app = this; + + const db = new NeDB({ + filename: path.join(app.get('nedb'), 'users.db'), + autoload: true + }); + + let options = { + Model: db, + paginate: { + default: 5, + max: 25 + } + }; + + // Initialize our service with any options it requires + app.use('/users', service(options)); + + // Get our initialize service to that we can bind hooks + const userService = app.service('/users'); + + // Set up our before hooks + userService.before(hooks.before); + + // Set up our after hooks + userService.after(hooks.after); +}; diff --git a/examples/with-featherjs/static/favicon.ico b/examples/with-featherjs/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..7ed25a60b04996fb9f339aa73cbfd25dd394430e GIT binary patch literal 5533 zcmV;O6=Ld%P)Px~S4l)c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*EtZ_yA|V{u75mw3H0 zSwNcq!fhbjNDp0&KQGl%3o}2XeiG%>lXn>QT&z^_NDUKS`Zr1U^6$AHN&RvJ$>TAx z3&d3`weXLnp~gZR%od6vDyD$JGukN*#rp#`)+ fS9<5lsoMVwztWhI*cqZ+00000NkvXXu0mjf9$Six literal 0 HcmV?d00001 diff --git a/examples/with-featherjs/test/app.test.js b/examples/with-featherjs/test/app.test.js new file mode 100644 index 0000000000..211eebcad4 --- /dev/null +++ b/examples/with-featherjs/test/app.test.js @@ -0,0 +1,38 @@ +'use strict'; + +const assert = require('assert'); +const request = require('request'); +const app = require('../src/app'); + +describe('Feathers application tests', function() { + before(function(done) { + this.server = app.listen(3030); + this.server.once('listening', () => done()); + }); + + after(function(done) { + this.server.close(done); + }); + + it('starts and shows the index page', function(done) { + request('http://localhost:3030', function(err, res, body) { + assert.ok(body.indexOf('

Welcome!

') !== -1); + done(err); + }); + }); + + describe('404', function() { + it('shows a 404 HTML page', function(done) { + request({ + url: 'http://localhost:3030/path/to/nowhere', + headers: { + 'Accept': 'text/html' + } + }, function(err, res, body) { + assert.equal(res.statusCode, 404); + assert.ok(body.indexOf('This page could not be found.') !== -1); + done(err); + }); + }); + }); +}); diff --git a/examples/with-featherjs/test/services/user/index.test.js b/examples/with-featherjs/test/services/user/index.test.js new file mode 100644 index 0000000000..a43dcaef23 --- /dev/null +++ b/examples/with-featherjs/test/services/user/index.test.js @@ -0,0 +1,10 @@ +'use strict'; + +const assert = require('assert'); +const app = require('../../../src/app'); + +describe('user service', function() { + it('registered the users service', () => { + assert.ok(app.service('users')); + }); +});