Merge branch 'master' of github.com:Human-Connection/Human-Connection into 399-user-profile-image-uploads

This commit is contained in:
Matt Rider 2019-05-15 07:44:08 -03:00
commit 87debd2a92
9 changed files with 112 additions and 127 deletions

View File

@ -10,14 +10,14 @@ import permissionsMiddleware from './permissionsMiddleware'
import userMiddleware from './userMiddleware'
import includedFieldsMiddleware from './includedFieldsMiddleware'
import orderByMiddleware from './orderByMiddleware'
import validUrlMiddleware from './validUrlMiddleware'
import validationMiddleware from './validation'
import notificationsMiddleware from './notifications'
export default schema => {
let middleware = [
passwordMiddleware,
dateTimeMiddleware,
validUrlMiddleware,
validationMiddleware,
sluggifyMiddleware,
excerptMiddleware,
notificationsMiddleware,

View File

@ -1,5 +1,4 @@
import dotenv from 'dotenv'
import { UserInputError } from 'apollo-server'
import createOrUpdateLocations from './nodes/locations'
@ -13,10 +12,6 @@ export default {
return result
},
UpdateUser: async (resolve, root, args, context, info) => {
const USERNAME_MIN_LENGTH = 3 // TODO move to the correct place
if (!args.name || args.name.length < USERNAME_MIN_LENGTH) {
throw new UserInputError(`Username must be at least ${USERNAME_MIN_LENGTH} characters long!`)
}
const result = await resolve(root, args, context, info)
await createOrUpdateLocations(args.id, args.locationName, context.driver)
return result

View File

@ -1,18 +0,0 @@
const validURL = str => {
const isValid = str.match(/^(?:https?:\/\/)(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g)
return !!isValid
}
export default {
Mutation: {
CreateSocialMedia: async (resolve, root, args, context, info) => {
let socialMedia
if (validURL(args.url)) {
socialMedia = await resolve(root, args, context, info)
} else {
throw Error('Input is not a URL')
}
return socialMedia
}
}
}

View File

@ -0,0 +1,31 @@
import { UserInputError } from 'apollo-server'
const USERNAME_MIN_LENGTH = 3
const validateUsername = async (resolve, root, args, context, info) => {
if (args.name && args.name.length >= USERNAME_MIN_LENGTH) {
/* eslint-disable-next-line no-return-await */
return await resolve(root, args, context, info)
} else {
throw new UserInputError(`Username must be at least ${USERNAME_MIN_LENGTH} characters long!`)
}
}
const validateUrl = async (resolve, root, args, context, info) => {
const { url } = args
const isValid = url.match(/^(?:https?:\/\/)(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g)
if (isValid) {
/* eslint-disable-next-line no-return-await */
return await resolve(root, args, context, info)
} else {
throw new UserInputError('Input is not a URL')
}
}
export default {
Mutation: {
CreateUser: validateUsername,
UpdateUser: validateUsername,
CreateSocialMedia: validateUrl
}
}

View File

@ -5,15 +5,15 @@ import Factory from '../seed/factories'
const factory = Factory()
let client
afterAll(async () => {
afterEach(async () => {
await factory.cleanDatabase()
})
describe('userMiddleware', () => {
describe('create User', () => {
describe('users', () => {
describe('CreateUser', () => {
const mutation = `
mutation($id: ID, $password: String!, $email: String!) {
CreateUser(id: $id, password: $password, email: $email) {
mutation($name: String, $password: String!, $email: String!) {
CreateUser(name: $name, password: $password, email: $email) {
id
}
}
@ -22,6 +22,7 @@ describe('userMiddleware', () => {
it('with password and email', async () => {
const variables = {
name: 'John Doe',
password: '123',
email: '123@123.de'
}
@ -35,34 +36,39 @@ describe('userMiddleware', () => {
})
})
describe('update User', () => {
describe('UpdateUser', () => {
beforeEach(async () => {
await factory.create('User', { id: 'u47', name: 'John Doe' })
})
const mutation = `
mutation($id: ID!, $name: String) {
UpdateUser(id: $id, name: $name) {
id
name
}
}
`
client = new GraphQLClient(host)
// TODO why is this failing - it returns { UpdateUser: null } - that should not be
/* it('name within specifications', async () => {
it('name within specifications', async () => {
const variables = {
id: 'u1',
name: 'Peter Lustig'
id: 'u47',
name: 'James Doe'
}
const expected = {
UpdateUser: {
name: 'Peter Lustig'
id: 'u47',
name: 'James Doe'
}
}
await expect(client.request(mutation, variables))
.resolves.toEqual(expected)
}) */
})
it('with no name', async () => {
const variables = {
id: 'u1'
id: 'u47'
}
const expected = 'Username must be at least 3 characters long!'
await expect(client.request(mutation, variables))
@ -71,7 +77,8 @@ describe('userMiddleware', () => {
it('with too short name', async () => {
const variables = {
id: 'u1'
id: 'u47',
name: ' '
}
const expected = 'Username must be at least 3 characters long!'
await expect(client.request(mutation, variables))

View File

@ -23,7 +23,7 @@
"cross-env": "^5.2.0",
"cypress": "^3.2.0",
"cypress-cucumber-preprocessor": "^1.11.0",
"cypress-plugin-retries": "^1.2.0",
"cypress-plugin-retries": "^1.2.1",
"dotenv": "^8.0.0",
"faker": "^4.1.0",
"graphql-request": "^1.8.2",

View File

@ -51,7 +51,7 @@
},
"dependencies": {
"@human-connection/styleguide": "0.5.17",
"@nuxtjs/apollo": "4.0.0-rc4",
"@nuxtjs/apollo": "4.0.0-rc4.1",
"@nuxtjs/axios": "~5.4.1",
"@nuxtjs/dotenv": "~1.3.0",
"@nuxtjs/style-resources": "~0.1.2",
@ -70,8 +70,8 @@
"nuxt-env": "~0.1.0",
"stack-utils": "^1.0.2",
"string-hash": "^1.1.3",
"tiptap": "1.19.0",
"tiptap-extensions": "1.19.1",
"tiptap": "1.19.2",
"tiptap-extensions": "1.19.2",
"v-tooltip": "~2.0.2",
"vue-count-to": "~1.0.13",
"vue-izitoast": "1.1.2",
@ -94,7 +94,7 @@
"eslint": "~5.16.0",
"eslint-config-prettier": "~4.2.0",
"eslint-loader": "~2.1.2",
"eslint-plugin-prettier": "~3.0.1",
"eslint-plugin-prettier": "~3.1.0",
"eslint-plugin-vue": "~5.2.2",
"fuse.js": "^3.4.4",
"jest": "~24.8.0",

View File

@ -1103,16 +1103,17 @@
webpack-node-externals "^1.7.2"
webpackbar "^3.2.0"
"@nuxtjs/apollo@4.0.0-rc4":
version "4.0.0-rc4"
resolved "https://registry.yarnpkg.com/@nuxtjs/apollo/-/apollo-4.0.0-rc4.tgz#21e444f9b027bbb379f04feb04ee999aa94d2568"
integrity sha512-kdqjlUSpYZMKIF6InNZox3lqwWnJSyscj1hGNnHLVpspooLs4l+MlOtUGQeS7kSZAW0hrPG3yjQeVwx80rJR5g==
"@nuxtjs/apollo@4.0.0-rc4.1":
version "4.0.0-rc4.1"
resolved "https://registry.yarnpkg.com/@nuxtjs/apollo/-/apollo-4.0.0-rc4.1.tgz#c9d27d0ad95c36805efdfceceb6150ed0eded81e"
integrity sha512-FAWpGlq6vcD5IHX8yElO6p73vVK8OabQB/ddc5z0idm3lv8ZQnG+RHvzwQ7qrqQseGUzCbMu/haehmaWA78JzA==
dependencies:
cookie "^0.3.1"
isomorphic-fetch "^2.2.1"
js-cookie "^2.2.0"
vue-apollo "^3.0.0-beta.28"
vue-cli-plugin-apollo "^0.19.1"
vue-apollo "^3.0.0-beta.29"
vue-cli-plugin-apollo "^0.20.0"
webpack-node-externals "^1.7.2"
"@nuxtjs/axios@~5.4.1":
version "5.4.1"
@ -4153,10 +4154,10 @@ eslint-loader@~2.1.2:
object-hash "^1.1.4"
rimraf "^2.6.1"
eslint-plugin-prettier@^3.0.0, eslint-plugin-prettier@~3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.1.tgz#19d521e3981f69dd6d14f64aec8c6a6ac6eb0b0d"
integrity sha512-/PMttrarPAY78PLvV3xfWibMOdMDl57hmlQ2XqFeA37wd+CJ7WSxV7txqjVPHi/AAFKd2lX0ZqfsOc/i5yFCSQ==
eslint-plugin-prettier@^3.0.0, eslint-plugin-prettier@~3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.0.tgz#8695188f95daa93b0dc54b249347ca3b79c4686d"
integrity sha512-XWX2yVuwVNLOUhQijAkXz+rMPPoCr7WFiAl8ig6I7Xn+pPVhDhzg4DxHpmbeb0iqjO9UronEA3Tb09ChnFVHHA==
dependencies:
prettier-linter-helpers "^1.0.0"
@ -8774,20 +8775,15 @@ prosemirror-transform@^1.0.0, prosemirror-transform@^1.1.0, prosemirror-transfor
dependencies:
prosemirror-model "^1.0.0"
prosemirror-utils@^0.7.6:
version "0.7.7"
resolved "https://registry.yarnpkg.com/prosemirror-utils/-/prosemirror-utils-0.7.7.tgz#a9bda2468113d34f3721ba15eaa2fd04b81d7dc8"
integrity sha512-0cSWive9oCOr4nnTlEQ9scr8g8kj126glAigb6cKLB4sq/eSyumVu8Ogqus6KEoLInBy6WONXJbgm/2xJ8MShw==
prosemirror-utils@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/prosemirror-utils/-/prosemirror-utils-0.8.1.tgz#a9cb9f5ce292dc20c21ec996af02879651395a65"
integrity sha512-u1tCdkj4I5T7sBmL6IvBAnH8p0a//vJ2N3g7pVKbfxPVDQ7gcC9UibbPijpvhb6PALxX/oeccvo+PJXHm6j4vA==
prosemirror-utils@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/prosemirror-utils/-/prosemirror-utils-0.8.0.tgz#fbec60512fd8a4544e1d8d95a9706c58699c505a"
integrity sha512-GRhxIYosyfDNivcxOzJw42O1gS6mq7zyCGUXKMdfOk/RAcimYRzL20Z0ll38mX+xU7xRH+0a8WoPb3+XDeiyxg==
prosemirror-view@^1.0.0, prosemirror-view@^1.1.0, prosemirror-view@^1.9.2:
version "1.9.2"
resolved "https://registry.yarnpkg.com/prosemirror-view/-/prosemirror-view-1.9.2.tgz#4ccc0085fe49b1f400845d78837e4ab4bb321ce4"
integrity sha512-UzeKJB+WNUZky/OgRdHymQE32XsRXPsE6WLFgvGVj7IKDAAQZRToydq85poYWCcCl07V8eEj30gqpaHI9YxJmA==
prosemirror-view@^1.0.0, prosemirror-view@^1.1.0, prosemirror-view@^1.9.4:
version "1.9.4"
resolved "https://registry.yarnpkg.com/prosemirror-view/-/prosemirror-view-1.9.4.tgz#d0490846c9e8c88e1460e5f8ed5ee0c8d8f47298"
integrity sha512-3l6pzxEjgSZawW0Y0iUeKSW4pCCfSNxCNZT3q0C6MOqE30dVpA+0acTFOEZz6Gf8D3Lo20FwwaCSH6ld1P+8Lw==
dependencies:
prosemirror-model "^1.1.0"
prosemirror-state "^1.0.0"
@ -10279,22 +10275,22 @@ tippy.js@^4.3.1:
dependencies:
popper.js "^1.14.7"
tiptap-commands@^1.10.0, tiptap-commands@^1.10.1:
version "1.10.1"
resolved "https://registry.yarnpkg.com/tiptap-commands/-/tiptap-commands-1.10.1.tgz#d2dde3e0a70093f2e08b5ba1b7de5a1e827ea6aa"
integrity sha512-0+HNWkLx4TBJ170uN2jMQm88bRVHUR0qfeKrnspxR1xU24Wl3VgRX77QbRH9tpUZ1uk0CQnXVytiVouDd1taDQ==
tiptap-commands@^1.10.2:
version "1.10.2"
resolved "https://registry.yarnpkg.com/tiptap-commands/-/tiptap-commands-1.10.2.tgz#34a9534126331d65bd3bad7fcb3893ceef34d5ee"
integrity sha512-OTNMBx1SVnUnZlnUOnx2HC/IFop2QpRJreuvEt/XzqE3eNLExLgQLVELkGkrrLnIDU61MOva010La+6RaoF5NQ==
dependencies:
prosemirror-commands "^1.0.7"
prosemirror-inputrules "^1.0.2"
prosemirror-model "^1.7.0"
prosemirror-schema-list "^1.0.3"
prosemirror-state "^1.2.3"
tiptap-utils "^1.5.1"
tiptap-utils "^1.5.2"
tiptap-extensions@1.19.1:
version "1.19.1"
resolved "https://registry.yarnpkg.com/tiptap-extensions/-/tiptap-extensions-1.19.1.tgz#890220dae85f61a41629c2a43c1d33e1930b2b86"
integrity sha512-JlRwlhR3R6DP2ipW6Se9N5iR2BrW3BhxsrjqyLQHxq+RXRXcDLQmfdfQFLAlCFijJh9/KPapywAwHh37UjTnfw==
tiptap-extensions@1.19.2:
version "1.19.2"
resolved "https://registry.yarnpkg.com/tiptap-extensions/-/tiptap-extensions-1.19.2.tgz#54313fa82cf5966ae3ee85f3acca819a1c215d90"
integrity sha512-0f/+3qOzAY71GO837puJSpe08gQdzNsQgSa3+RFVgY1HFo9+YHX/AGHZu6PhZTxDBlaUgCLJGtcPpdXW4OrTzw==
dependencies:
lowlight "^1.11.0"
prosemirror-collab "^1.1.1"
@ -10303,35 +10299,25 @@ tiptap-extensions@1.19.1:
prosemirror-state "^1.2.3"
prosemirror-tables "^0.8.0"
prosemirror-transform "^1.1.3"
prosemirror-utils "^0.8.0"
prosemirror-view "^1.9.2"
tiptap "^1.19.1"
tiptap-commands "^1.10.1"
prosemirror-utils "^0.8.1"
prosemirror-view "^1.9.4"
tiptap "^1.19.2"
tiptap-commands "^1.10.2"
tiptap-utils@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/tiptap-utils/-/tiptap-utils-1.5.0.tgz#fa2ebb454629f34cc6a6bcd0e0e38159634c9227"
integrity sha512-IocewIa2FdkKdA2VNr8uNidhbpgvvuWUp3hFOPqVU5hymEhi9CwrnD/uyz/ng5DMMdKPmZ7l95Fa6CH0CgDPLQ==
tiptap-utils@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/tiptap-utils/-/tiptap-utils-1.5.2.tgz#6a2c459c4bcc2c3f4d14c31601cc41fe49b88311"
integrity sha512-Upw5ImtgzkrcNnKh6T+IwER8HZWOkposST5GnT07AjnyKddbn2yYCH9xxSODzao66pu0PhlwSoCR+9mXs3Tb6Q==
dependencies:
prosemirror-model "^1.7.0"
prosemirror-state "^1.2.3"
prosemirror-tables "^0.8.0"
prosemirror-utils "^0.7.6"
prosemirror-utils "^0.8.1"
tiptap-utils@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/tiptap-utils/-/tiptap-utils-1.5.1.tgz#0126cd4ebe35d2850c69d994de56b0436afd9bab"
integrity sha512-zKdjeXiOR4CL1JmLh3ivgTw5scAFSmpytqza9a7EJPcTqjCWuBn9chGJGZIKjsk7zDPgBWMg5/2ciGvu17Ywjg==
dependencies:
prosemirror-model "^1.7.0"
prosemirror-state "^1.2.3"
prosemirror-tables "^0.8.0"
prosemirror-utils "^0.8.0"
tiptap@1.19.0:
version "1.19.0"
resolved "https://registry.yarnpkg.com/tiptap/-/tiptap-1.19.0.tgz#f4c362cb5c247b11a04bdea62b81d2faa59ef4f9"
integrity sha512-2HXnbTvcLf2SajPA9RWeNvWrC/AvFiYe6YRydaasGZh5VD1B+BlDID9AlT5CoTNrhU3hs/kn1oPfJbiuQM0+Ew==
tiptap@1.19.2, tiptap@^1.19.2:
version "1.19.2"
resolved "https://registry.yarnpkg.com/tiptap/-/tiptap-1.19.2.tgz#6d349c32185b358d9f9326c461f4993a99c0374d"
integrity sha512-RQxvHZznQYMaYe935ihueGbepWGASn8fM+BQG1LMQEvqjlPZ6+F95lJ5vBFahE/CV9w0A9ddN06RacbF4P+6EA==
dependencies:
prosemirror-commands "^1.0.7"
prosemirror-dropcursor "^1.1.1"
@ -10340,25 +10326,9 @@ tiptap@1.19.0:
prosemirror-keymap "^1.0.1"
prosemirror-model "^1.7.0"
prosemirror-state "^1.2.3"
prosemirror-view "^1.9.2"
tiptap-commands "^1.10.0"
tiptap-utils "^1.5.0"
tiptap@^1.19.1:
version "1.19.1"
resolved "https://registry.yarnpkg.com/tiptap/-/tiptap-1.19.1.tgz#5db4591e5ac949f19bee00aaa1461c14167f012b"
integrity sha512-GCc+2Z5Iz4hfc2U7snwLaPToLAr4TLNkaBEEBuXU5sfCBTdgwCqVuPYqrwj55XJf0E9yJ55GLJmZpL+plTMCcw==
dependencies:
prosemirror-commands "^1.0.7"
prosemirror-dropcursor "^1.1.1"
prosemirror-gapcursor "^1.0.3"
prosemirror-inputrules "^1.0.2"
prosemirror-keymap "^1.0.1"
prosemirror-model "^1.7.0"
prosemirror-state "^1.2.3"
prosemirror-view "^1.9.2"
tiptap-commands "^1.10.1"
tiptap-utils "^1.5.1"
prosemirror-view "^1.9.4"
tiptap-commands "^1.10.2"
tiptap-utils "^1.5.2"
tmp@^0.0.33:
version "0.0.33"
@ -10845,7 +10815,7 @@ vm-browserify@0.0.4:
dependencies:
indexof "0.0.1"
vue-apollo@^3.0.0-beta.28:
vue-apollo@^3.0.0-beta.29:
version "3.0.0-beta.29"
resolved "https://registry.yarnpkg.com/vue-apollo/-/vue-apollo-3.0.0-beta.29.tgz#a331b4a506e6ff0a5a13cb989441daaf8edef2e7"
integrity sha512-iyyrE1xzTDZnSDN8XJkmBTs67m1pzR5QUJTdoz1VlLLQq/arvKV22AZUpR7zzU5anvfo/jc9tCyDKLxJsWkmTA==
@ -10853,10 +10823,10 @@ vue-apollo@^3.0.0-beta.28:
chalk "^2.4.2"
throttle-debounce "^2.1.0"
vue-cli-plugin-apollo@^0.19.1:
version "0.19.2"
resolved "https://registry.yarnpkg.com/vue-cli-plugin-apollo/-/vue-cli-plugin-apollo-0.19.2.tgz#ec6a6bdc98fcfa886a616e3a64eaaff71bbeb911"
integrity sha512-gWZsSbfHR2CmMLgpHxj6viwLczUdZ3zdwkXPoEUa7yn34Z8mZJW/fokwhPONgQNTrs3KNcq+zNQA7ED09+fP4A==
vue-cli-plugin-apollo@^0.20.0:
version "0.20.0"
resolved "https://registry.yarnpkg.com/vue-cli-plugin-apollo/-/vue-cli-plugin-apollo-0.20.0.tgz#0539ec96d8502cbe2fd9ab6a431f5b989145e396"
integrity sha512-Ey/luK5HtP4ZQhua5RKETR672pE7BPymaso//Ccl/wxQI1BqVTxg9o/wYeXuURBIw2Et9JaVLXmh0e9uKgk8Jw==
dependencies:
apollo-cache-inmemory "^1.5.1"
apollo-client "^2.5.1"

View File

@ -1810,10 +1810,10 @@ cypress-cucumber-preprocessor@^1.11.0:
glob "^7.1.2"
through "^2.3.8"
cypress-plugin-retries@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/cypress-plugin-retries/-/cypress-plugin-retries-1.2.0.tgz#a4e120c1bc417d1be525632e7d38e52a87bc0578"
integrity sha512-seQFI/0j5WCqX7IVN2k0tbd3FLdhbPuSCWdDtdzDmU9oJfUkRUlluV47TYD+qQ/l+fJYkQkpw8csLg8/LohfRg==
cypress-plugin-retries@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/cypress-plugin-retries/-/cypress-plugin-retries-1.2.1.tgz#0ae296e41c00c1aa1c2da83750e84c8a684e1c6b"
integrity sha512-iZ00NmeVfHleZ6fcDvzoUr2vPpCm+fzqzHpUF5ceY0PEJRs8BzdmIN/4AVUwLTDYdb3F1B8qK+s3GSoGe2WPQQ==
cypress@^3.2.0:
version "3.2.0"