Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
foxhound87 committed Jan 11, 2017
1 parent 5770f46 commit 9c9090d
Show file tree
Hide file tree
Showing 64 changed files with 766 additions and 468 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"rules": {
"react/forbid-prop-types": 0,
"react/require-default-props": 0,
"import/extensions": 0,
"import/prefer-default-export": 0,
"import/no-unresolved": [2, { "ignore": ["^[~]", "^[@]"] }],
Expand Down
11 changes: 5 additions & 6 deletions config/feathers/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
}
},
"auth": {
"idField": "uuid",
"userEndpoint": "/user",
"token": {
"secret": "JNoSF4uRkGB1zhccVkpX3ulB/1KErbj/tuhCTY0dkpVNyYTU8bJiNC4ErCUK4sDSe/YMjuC0kqtlYnWuK8tHsQ=="
},
"local": {}
"path": "/authentication",
"header": "Authorization",
"entity": "user",
"service": "user",
"secret": "JNoSF4uRkGB1zhccVkpX3ulB/1KErbj/tuhCTY0dkpVNyYTU8bJiNC4ErCUK4sDSe/YMjuC0kqtlYnWuK8tHsQ=="
}
}
7 changes: 1 addition & 6 deletions config/feathers/production.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"auth": {
"idField": "uuid",
"userEndpoint": "/user",
"token": {
"secret": "JNoSF4uRkGB1zhccVkpX3ulB/1KErbj/tuhCTY0dkpVNyYTU8bJiNC4ErCUK4sDSe/YMjuC0kqtlYnWuK8tHsQ=="
},
"local": {}
"secret": "JNoSF4uRkGB1zhccVkpX3ulB/1KErbj/tuhCTY0dkpVNyYTU8bJiNC4ErCUK4sDSe/YMjuC0kqtlYnWuK8tHsQ=="
}
}
71 changes: 39 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,87 +26,93 @@
"animate.css": "3.5.2",
"autoprefixer": "6.5.3",
"babel-register": "6.18.0",
"bluebird": "3.4.6",
"body-parser": "1.15.2",
"browser-sync-webpack-plugin": "1.1.3",
"classnames": "2.2.5",
"compression": "1.6.2",
"connect-history-api-fallback": "1.3.0",
"cookie-parser": "1.4.3",
"cors": "2.8.1",
"cross-env": "3.1.3",
"css-modules-require-hook": "4.0.5",
"dotenv": "2.0.0",
"ejs": "2.5.5",
"faker": "3.1.0",
"feathers": "2.0.2",
"feathers-authentication": "0.7.12",
"feathers": "2.0.3",
"feathers-authentication": "1.0.2",
"feathers-authentication-client": "0.1.6",
"feathers-authentication-jwt": "0.3.1",
"feathers-authentication-local": "0.3.2",
"feathers-configuration": "0.4.1",
"feathers-errors": "2.5.0",
"feathers-hooks": "1.7.0",
"feathers-hooks": "1.7.1",
"feathers-hooks-common": "2.0.3",
"feathers-mongoose": "3.6.1",
"feathers-rest": "1.5.2",
"feathers-permissions": "0.1.1",
"feathers-rest": "1.6.0",
"feathers-socketio": "1.4.2",
"font-awesome": "4.7.0",
"getenv": "0.7.0",
"globule": "1.1.0",
"isdev": "1.0.1",
"isomorphic-fetch": "2.2.1",
"js-cookie": "2.1.3",
"jwt-decode": "2.1.0",
"lodash": "4.17.2",
"material-ui": "0.16.4",
"mobx": "2.6.5",
"mobx-react": "4.0.3",
"mobx": "2.7",
"mobx-react": "4.0",
"mobx-react-devtools": "4.2.10",
"mobx-react-form": "1.16.6",
"mobx-react-form": "^1.18.2",
"mobx-react-matchmedia": "1.2.0",
"moment": "2.17.1",
"mongoose": "4.7.1",
"morgan": "1.7.0",
"node-uuid": "1.4.7",
"normalize.css": "5.0.0",
"react": "15.4.1",
"react-dom": "15.4.1",
"react-helmet": "3.2.3",
"react": "15.4.2",
"react-dom": "15.4.2",
"react-helmet": "3.3.0",
"react-hot-loader": "3.0.0-beta.6",
"react-modal": "1.6.1",
"react-modal": "1.6.5",
"react-pagify": "2.1.1",
"react-parallax": "1.2.0",
"react-parallax": "1.2.2",
"react-router": "3.0.0",
"react-tap-event-plugin": "2.0.1",
"react-timeago": "3.1.3",
"rfx-core": "1.5.1",
"serve-static": "1.11.1",
"socket.io-client": "1.7.1",
"tachyons": "4.5.6",
"validatorjs": "3.9.0",
"whatwg-fetch": "2.0.1",
"socket.io-client": "1.7.2",
"tachyons": "4.6.1",
"uuid": "3.0.1",
"validatorjs": "3.11.0",
"winston": "2.3.0"
},
"peerDependencies": {
"react": "15.4.1",
"react-dom": "15.4.1"
"react": "15.4.2",
"react-dom": "15.4.2"
},
"devDependencies": {
"babel-core": "6.18.2",
"babel-core": "6.21.0",
"babel-eslint": "7.1.1",
"babel-loader": "6.2.8",
"babel-loader": "6.2.10",
"babel-plugin-system-import-transformer": "2.4.0",
"babel-plugin-transform-class-properties": "6.19.0",
"babel-plugin-transform-decorators-legacy": "1.3.4",
"babel-plugin-transform-runtime": "6.15.0",
"babel-polyfill": "6.16.0",
"babel-polyfill": "6.20.0",
"babel-preset-es2015": "6.18.0",
"babel-preset-react": "6.16.0",
"babel-preset-stage-0": "6.16.0",
"babel-root-import": "4.1.5",
"bluebird": "3.4.6",
"browser-sync": "2.18.2",
"css-loader": "0.26.1",
"cssnano": "3.8.1",
"eslint": "3.11.1",
"eslint-config-airbnb": "13.0.0",
"eslint": "3.13.1",
"eslint-config-airbnb": "14.0.0",
"eslint-loader": "1.6.1",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "2.2.3",
"eslint-plugin-react": "6.8.0",
"eslint-plugin-jsx-a11y": "3.0.2",
"eslint-plugin-react": "6.9.0",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "0.9.0",
"friendly-errors-webpack-plugin": "1.1.2",
Expand All @@ -126,9 +132,10 @@
"style-loader": "0.13.1",
"url-loader": "0.5.7",
"webpack": "2.1.0-beta.27",
"webpack-dev-middleware": "1.8.4",
"webpack-hot-middleware": "2.13.2",
"webpack-merge": "1.0.2",
"webpack-node-externals": "1.5.4"
"webpack-dev-middleware": "1.9.0",
"webpack-hot-middleware": "2.15.0",
"webpack-merge": "2.3.1",
"webpack-node-externals": "1.5.4",
"whatwg-fetch": "2.0.1"
}
}
14 changes: 12 additions & 2 deletions src/api/auth.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import authentication from 'feathers-authentication';
import auth from 'feathers-authentication';
import { setupJWTPayload } from '@/api/hooks/setupJWTPayload';

// import { Strategy as FacebookStrategy } from 'passport-facebook';
// import FacebookTokenStrategy from 'passport-facebook-token';
Expand All @@ -16,5 +17,14 @@ export default function () {
// config.github.tokenStrategy = GithubTokenStrategy;

app.set('auth', config);
app.configure(authentication(config));
app.configure(auth(config));

app.service('authentication').hooks({
before: {
create: [
auth.hooks.authenticate(['jwt', 'local']),
setupJWTPayload(app),
],
},
});
}
Empty file modified src/api/autoloader.js
100644 → 100755
Empty file.
Empty file modified src/api/connector.js
100644 → 100755
Empty file.
Empty file modified src/api/hooks/addDelay.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/api/hooks/setUUID.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid from 'node-uuid';
import uuid from 'uuid';

function assignUUID(item) {
item.uuid = uuid.v4(); // eslint-disable-line no-param-reassign
Expand Down
10 changes: 10 additions & 0 deletions src/api/hooks/setupJWTPayload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function setupJWTPayload() {
return (hook) => {
// eslint-disable-next-line
hook.data.payload = {
userId: hook.params.user.id,
};

return Promise.resolve(hook);
};
}
Empty file modified src/api/hooks/timestamp.js
100644 → 100755
Empty file.
17 changes: 0 additions & 17 deletions src/api/middleware/api/after.js

This file was deleted.

13 changes: 0 additions & 13 deletions src/api/middleware/api/before.js

This file was deleted.

Empty file modified src/api/middleware/logger.js
100644 → 100755
Empty file.
Empty file modified src/api/middleware/notFound.js
100644 → 100755
Empty file.
33 changes: 24 additions & 9 deletions src/api/server.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import compression from 'compression';
import cors from 'cors';
import feathers from 'feathers';
import configuration from 'feathers-configuration';
import local from 'feathers-authentication-local';
import jwt from 'feathers-authentication-jwt';
import hooks from 'feathers-hooks';
import rest from 'feathers-rest';
import socketio from 'feathers-socketio';
import adapter from 'feathers-mongoose';
import errorHandler from 'feathers-errors/handler';

import compression from 'compression';
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import cors from 'cors';

import { setupServices, initServices } from '@/utils/services.autoload';
import { setupServer, startServer } from '@/utils/server.start';
import { logServerConfig } from '@/utils/logger';

import apiBeforeMiddleware from './middleware/api/before';
import apiAfterMiddleware from './middleware/api/after';

import auth from './auth';
import { connector } from './connector';
import { autoloader } from './autoloader';

import loggerMiddleware from './middleware/logger';
import notFoundMiddleware from './middleware/notFound';

setupServer({
namespace: 'api',
logger: logServerConfig,
Expand All @@ -30,15 +36,24 @@ setupServices({
autoloader,
});

feathers()
const app = feathers();

app
.configure(configuration())
.use(compression())
.options('*', cors())
.configure(apiBeforeMiddleware)
.configure(hooks())
.use(cors({ origin: true }))
.configure(rest())
.configure(socketio(io => io.set('origins', '*:*')))
.configure(hooks())
.use(cookieParser())
.use(bodyParser.json())
.use(bodyParser.urlencoded({ extended: true }))
.configure(auth)
.configure(local())
.configure(jwt())
.configure(initServices)
.configure(apiAfterMiddleware)
.use(notFoundMiddleware())
.use(loggerMiddleware(app))
.use(errorHandler({ html: false }))
.configure(startServer);
Empty file modified src/api/services/post/config.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/api/services/post/hooks.after.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import hooks from 'feathers-hooks';
*/
export default {
all: [
hooks.remove('_id', '__v'),
hooks.remove('__v', '_id'),
],
find: [],
get: [],
Expand Down
4 changes: 2 additions & 2 deletions src/api/services/post/hooks.before.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import { hooks as auth } from 'feathers-authentication';
import { hooks as auth } from 'feathers-authentication';
import { setUUID } from '@/api/hooks/setUUID';

/**
Expand All @@ -7,7 +7,7 @@ import { setUUID } from '@/api/hooks/setUUID';
*/
export default {
all: [
// auth.verifyToken(),
auth.authenticate(['jwt', 'local']),
],
find: [],
get: [],
Expand Down
Empty file modified src/api/services/post/model.js
100644 → 100755
Empty file.
Empty file modified src/api/services/user/config.js
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion src/api/services/user/hooks.after.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default {
all: [
hooks.remove('__v', 'password'),
],
find: [],
find: [
],
get: [],
create: [],
update: [],
Expand Down
33 changes: 13 additions & 20 deletions src/api/services/user/hooks.before.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { hooks as auth } from 'feathers-authentication';
import { hooks as local } from 'feathers-authentication-local';
import { hooks as perms } from 'feathers-permissions';
import { setUUID } from '@/api/hooks/setUUID';

/**
Expand All @@ -8,36 +10,27 @@ import { setUUID } from '@/api/hooks/setUUID';
export default {
all: [],
find: [
auth.verifyToken(),
auth.populateUser(),
auth.restrictToAuthenticated(),
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),
],
get: [
auth.verifyToken(),
auth.populateUser(),
auth.restrictToAuthenticated(),
auth.restrictToOwner({ ownerField: '_id' }),
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),
],
create: [
setUUID(),
auth.hashPassword(),
local.hashPassword(),
],
update: [
auth.verifyToken(),
auth.populateUser(),
auth.restrictToAuthenticated(),
auth.restrictToOwner({ ownerField: '_id' }),
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),
],
patch: [
auth.verifyToken(),
auth.populateUser(),
auth.restrictToAuthenticated(),
auth.restrictToOwner({ ownerField: '_id' }),
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),
],
remove: [
auth.verifyToken(),
auth.populateUser(),
auth.restrictToAuthenticated(),
auth.restrictToOwner({ ownerField: '_id' }),
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),
],
};
Empty file modified src/api/services/user/model.js
100644 → 100755
Empty file.
Loading

0 comments on commit 9c9090d

Please sign in to comment.