diff --git a/backend/package.json b/backend/package.json index b514e7a70..e2abde493 100644 --- a/backend/package.json +++ b/backend/package.json @@ -47,7 +47,7 @@ "apollo-client": "~2.5.1", "apollo-link-context": "~1.0.14", "apollo-link-http": "~1.5.14", - "apollo-server": "~2.5.1", + "apollo-server": "~2.6.1", "bcryptjs": "~2.4.3", "cheerio": "~1.0.0-rc.3", "cors": "~2.8.5", @@ -88,7 +88,7 @@ "@babel/plugin-proposal-throw-expressions": "^7.2.0", "@babel/preset-env": "~7.4.5", "@babel/register": "~7.4.4", - "apollo-server-testing": "~2.5.1", + "apollo-server-testing": "~2.6.1", "babel-core": "~7.0.0-0", "babel-eslint": "~10.0.1", "babel-jest": "~24.8.0", diff --git a/backend/src/middleware/index.js b/backend/src/middleware/index.js index cdc1d298c..754c59bbb 100644 --- a/backend/src/middleware/index.js +++ b/backend/src/middleware/index.js @@ -1,42 +1,63 @@ -import activityPubMiddleware from './activityPubMiddleware' -import passwordMiddleware from './passwordMiddleware' -import softDeleteMiddleware from './softDeleteMiddleware' -import sluggifyMiddleware from './sluggifyMiddleware' -import fixImageUrlsMiddleware from './fixImageUrlsMiddleware' -import excerptMiddleware from './excerptMiddleware' -import dateTimeMiddleware from './dateTimeMiddleware' -import xssMiddleware from './xssMiddleware' -import permissionsMiddleware from './permissionsMiddleware' -import userMiddleware from './userMiddleware' -import includedFieldsMiddleware from './includedFieldsMiddleware' -import orderByMiddleware from './orderByMiddleware' -import validationMiddleware from './validation' -import notificationsMiddleware from './notifications' import CONFIG from './../config' +import activityPub from './activityPubMiddleware' +import password from './passwordMiddleware' +import softDelete from './softDeleteMiddleware' +import sluggify from './sluggifyMiddleware' +import fixImageUrls from './fixImageUrlsMiddleware' +import excerpt from './excerptMiddleware' +import dateTime from './dateTimeMiddleware' +import xss from './xssMiddleware' +import permissions from './permissionsMiddleware' +import user from './userMiddleware' +import includedFields from './includedFieldsMiddleware' +import orderBy from './orderByMiddleware' +import validation from './validation' +import notifications from './notifications' export default schema => { - let middleware = [ - passwordMiddleware, - dateTimeMiddleware, - validationMiddleware, - sluggifyMiddleware, - excerptMiddleware, - notificationsMiddleware, - xssMiddleware, - fixImageUrlsMiddleware, - softDeleteMiddleware, - userMiddleware, - includedFieldsMiddleware, - orderByMiddleware, + const middlewares = { + permissions: permissions, + activityPub: activityPub, + password: password, + dateTime: dateTime, + validation: validation, + sluggify: sluggify, + excerpt: excerpt, + notifications: notifications, + xss: xss, + fixImageUrls: fixImageUrls, + softDelete: softDelete, + user: user, + includedFields: includedFields, + orderBy: orderBy, + } + + let order = [ + 'permissions', + 'activityPub', + 'password', + 'dateTime', + 'validation', + 'sluggify', + 'excerpt', + 'notifications', + 'xss', + 'fixImageUrls', + 'softDelete', + 'user', + 'includedFields', + 'orderBy', ] // add permisions middleware at the first position (unless we're seeding) - // NOTE: DO NOT SET THE PERMISSION FLAT YOUR SELF if (CONFIG.DEBUG) { - const disabled = CONFIG.DISABLED_MIDDLEWARES.split(',') - if (!disabled.includes('activityPub')) middleware.unshift(activityPubMiddleware) - if (!disabled.includes('permissions')) - middleware.unshift(permissionsMiddleware.generate(schema)) + const disabledMiddlewares = CONFIG.DISABLED_MIDDLEWARES.split(',') + order = order.filter(key => { + return !disabledMiddlewares.includes(key) + }) + /* eslint-disable-next-line no-console */ + console.log(`Warning: "${disabledMiddlewares}" middlewares have been disabled.`) } - return middleware + + return order.map(key => middlewares[key]) } diff --git a/backend/src/middleware/permissionsMiddleware.js b/backend/src/middleware/permissionsMiddleware.js index b1a08a14d..ea4ba3dd2 100644 --- a/backend/src/middleware/permissionsMiddleware.js +++ b/backend/src/middleware/permissionsMiddleware.js @@ -16,11 +16,15 @@ const isAdmin = rule()(async (parent, args, { user }, info) => { return user && user.role === 'admin' }) -const isMyOwn = rule({ cache: 'no_cache' })(async (parent, args, context, info) => { +const isMyOwn = rule({ + cache: 'no_cache', +})(async (parent, args, context, info) => { return context.user.id === parent.id }) -const belongsToMe = rule({ cache: 'no_cache' })(async (_, args, context) => { +const belongsToMe = rule({ + cache: 'no_cache', +})(async (_, args, context) => { const { driver, user: { id: userId }, @@ -32,7 +36,10 @@ const belongsToMe = rule({ cache: 'no_cache' })(async (_, args, context) => { MATCH (u:User {id: $userId})<-[:NOTIFIED]-(n:Notification {id: $notificationId}) RETURN n `, - { userId, notificationId }, + { + userId, + notificationId, + }, ) const [notification] = result.records.map(record => { return record.get('n') @@ -41,12 +48,16 @@ const belongsToMe = rule({ cache: 'no_cache' })(async (_, args, context) => { return Boolean(notification) }) -const onlyEnabledContent = rule({ cache: 'strict' })(async (parent, args, ctx, info) => { +const onlyEnabledContent = rule({ + cache: 'strict', +})(async (parent, args, ctx, info) => { const { disabled, deleted } = args return !(disabled || deleted) }) -const isAuthor = rule({ cache: 'no_cache' })(async (parent, args, { user, driver }) => { +const isAuthor = rule({ + cache: 'no_cache', +})(async (parent, args, { user, driver }) => { if (!user) return false const session = driver.session() const { id: postId } = args @@ -55,7 +66,9 @@ const isAuthor = rule({ cache: 'no_cache' })(async (parent, args, { user, driver MATCH (post:Post {id: $postId})<-[:WROTE]-(author) RETURN author `, - { postId }, + { + postId, + }, ) const [author] = result.records.map(record => { return record.get('author') @@ -100,6 +113,7 @@ const permissions = shield({ enable: isModerator, disable: isModerator, CreateComment: isAuthenticated, + DeleteComment: isAuthenticated, // CreateUser: allow, }, User: { diff --git a/backend/src/schema/resolvers/comments.js b/backend/src/schema/resolvers/comments.js index 949b77041..7f3b11da4 100644 --- a/backend/src/schema/resolvers/comments.js +++ b/backend/src/schema/resolvers/comments.js @@ -53,6 +53,11 @@ export default { ) session.close() + return comment + }, + DeleteComment: async (object, params, context, resolveInfo) => { + const comment = await neo4jgraphql(object, params, context, resolveInfo, false) + return comment }, }, diff --git a/backend/src/schema/resolvers/comments.spec.js b/backend/src/schema/resolvers/comments.spec.js index 9fc162c6f..44b5d5be4 100644 --- a/backend/src/schema/resolvers/comments.spec.js +++ b/backend/src/schema/resolvers/comments.spec.js @@ -1,3 +1,4 @@ +import gql from 'graphql-tag' import { GraphQLClient } from 'graphql-request' import Factory from '../../seed/factories' import { host, login } from '../../jest/helpers' @@ -5,6 +6,7 @@ import { host, login } from '../../jest/helpers' const factory = Factory() let client let createCommentVariables +let deleteCommentVariables let createPostVariables let createCommentVariablesSansPostId let createCommentVariablesWithNonExistentPost @@ -21,22 +23,22 @@ afterEach(async () => { }) describe('CreateComment', () => { - const createCommentMutation = ` - mutation($postId: ID, $content: String!) { - CreateComment(postId: $postId, content: $content) { - id - content + const createCommentMutation = gql` + mutation($postId: ID, $content: String!) { + CreateComment(postId: $postId, content: $content) { + id + content + } } - } ` - const createPostMutation = ` - mutation($id: ID!, $title: String!, $content: String!) { - CreatePost(id: $id, title: $title, content: $content) { - id + const createPostMutation = gql` + mutation($id: ID!, $title: String!, $content: String!) { + CreatePost(id: $id, title: $title, content: $content) { + id + } } - } ` - const commentQueryForPostId = ` + const commentQueryForPostId = gql` query($content: String) { Comment(content: $content) { postId @@ -59,8 +61,13 @@ describe('CreateComment', () => { describe('authenticated', () => { let headers beforeEach(async () => { - headers = await login({ email: 'test@example.org', password: '1234' }) - client = new GraphQLClient(host, { headers }) + headers = await login({ + email: 'test@example.org', + password: '1234', + }) + client = new GraphQLClient(host, { + headers, + }) createCommentVariables = { postId: 'p1', content: "I'm authorised to comment", @@ -88,15 +95,25 @@ describe('CreateComment', () => { it('assigns the authenticated user as author', async () => { await client.request(createCommentMutation, createCommentVariables) - const { User } = await client.request(`{ + const { User } = await client.request(gql` + { User(email: "test@example.org") { comments { content } } - }`) + } + `) - expect(User).toEqual([{ comments: [{ content: "I'm authorised to comment" }] }]) + expect(User).toEqual([ + { + comments: [ + { + content: "I'm authorised to comment", + }, + ], + }, + ]) }) it('throw an error if an empty string is sent from the editor as content', async () => { @@ -186,7 +203,92 @@ describe('CreateComment', () => { commentQueryForPostId, commentQueryVariablesByContent, ) - expect(Comment).toEqual([{ postId: null }]) + expect(Comment).toEqual([ + { + postId: null, + }, + ]) }) }) }) + +describe('DeleteComment', () => { + const createCommentMutation = gql` + mutation($postId: ID, $content: String!) { + CreateComment(postId: $postId, content: $content) { + id + content + } + } + ` + const deleteCommentMutation = gql` + mutation($id: ID!) { + DeleteComment(id: $id) { + id + } + } + ` + const createPostMutation = gql` + mutation($id: ID!, $title: String!, $content: String!) { + CreatePost(id: $id, title: $title, content: $content) { + id + } + } + ` + describe('unauthenticated', () => { + it('throws authorization error', async () => { + deleteCommentVariables = { + id: 'c1', + } + client = new GraphQLClient(host) + await expect(client.request(deleteCommentMutation, deleteCommentVariables)).rejects.toThrow( + 'Not Authorised', + ) + }) + }) + + describe('authenticated', () => { + let headers + beforeEach(async () => { + headers = await login({ + email: 'test@example.org', + password: '1234', + }) + client = new GraphQLClient(host, { + headers, + }) + createCommentVariables = { + id: 'c1', + postId: 'p1', + content: "I'm authorised to comment", + } + deleteCommentVariables = { + id: 'c1', + } + createPostVariables = { + id: 'p1', + title: 'post to comment on', + content: 'please comment on me', + } + await client.request(createPostMutation, createPostVariables) + }) + + it('deletes the authors comment', async () => { + const { CreateComment } = await client.request(createCommentMutation, createCommentVariables) + + deleteCommentVariables = { + id: CreateComment.id, + } + const expected = { + DeleteComment: { + id: CreateComment.id, + }, + } + await expect( + client.request(deleteCommentMutation, deleteCommentVariables), + ).resolves.toMatchObject(expected) + }) + + it.todo('throws an error if it tries to delete a comment not from this author') + }) +}) diff --git a/backend/src/schema/resolvers/socialMedia.spec.js b/backend/src/schema/resolvers/socialMedia.spec.js index 231598062..18c12851c 100644 --- a/backend/src/schema/resolvers/socialMedia.spec.js +++ b/backend/src/schema/resolvers/socialMedia.spec.js @@ -1,13 +1,15 @@ +import gql from 'graphql-tag' import { GraphQLClient } from 'graphql-request' import Factory from '../../seed/factories' import { host, login } from '../../jest/helpers' + const factory = Factory() -describe('CreateSocialMedia', () => { +describe('SocialMedia', () => { let client let headers - const mutationC = ` + const mutationC = gql` mutation($url: String!) { CreateSocialMedia(url: $url) { id @@ -15,7 +17,7 @@ describe('CreateSocialMedia', () => { } } ` - const mutationD = ` + const mutationD = gql` mutation($id: ID!) { DeleteSocialMedia(id: $id) { id @@ -42,19 +44,28 @@ describe('CreateSocialMedia', () => { describe('unauthenticated', () => { it('throws authorization error', async () => { client = new GraphQLClient(host) - const variables = { url: 'http://nsosp.org' } + const variables = { + url: 'http://nsosp.org', + } await expect(client.request(mutationC, variables)).rejects.toThrow('Not Authorised') }) }) describe('authenticated', () => { beforeEach(async () => { - headers = await login({ email: 'test@example.org', password: '1234' }) - client = new GraphQLClient(host, { headers }) + headers = await login({ + email: 'test@example.org', + password: '1234', + }) + client = new GraphQLClient(host, { + headers, + }) }) it('creates social media with correct URL', async () => { - const variables = { url: 'http://nsosp.org' } + const variables = { + url: 'http://nsosp.org', + } await expect(client.request(mutationC, variables)).resolves.toEqual( expect.objectContaining({ CreateSocialMedia: { @@ -66,11 +77,15 @@ describe('CreateSocialMedia', () => { }) it('deletes social media', async () => { - const creationVariables = { url: 'http://nsosp.org' } + const creationVariables = { + url: 'http://nsosp.org', + } const { CreateSocialMedia } = await client.request(mutationC, creationVariables) const { id } = CreateSocialMedia - const deletionVariables = { id } + const deletionVariables = { + id, + } const expected = { DeleteSocialMedia: { id: id, @@ -81,12 +96,16 @@ describe('CreateSocialMedia', () => { }) it('rejects empty string', async () => { - const variables = { url: '' } + const variables = { + url: '', + } await expect(client.request(mutationC, variables)).rejects.toThrow('Input is not a URL') }) it('validates URLs', async () => { - const variables = { url: 'not-a-url' } + const variables = { + url: 'not-a-url', + } await expect(client.request(mutationC, variables)).rejects.toThrow('Input is not a URL') }) }) diff --git a/backend/yarn.lock b/backend/yarn.lock index 35c7b740b..d56871d83 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -9,13 +9,6 @@ dependencies: apollo-env "0.5.1" -"@apollographql/apollo-tools@^0.3.6-alpha.1": - version "0.3.6-alpha.1" - resolved "https://registry.yarnpkg.com/@apollographql/apollo-tools/-/apollo-tools-0.3.6-alpha.1.tgz#5199b36c65c2fddc4f8bc8bb97642f74e9fb00c5" - integrity sha512-fq74In3Vw9OmtKHze0L5/Ns/pdTZOqUeFVC6Um9NRgziVehXz/qswsh2r3+dsn82uqoa/AlvckHtd6aPPPYj9g== - dependencies: - apollo-env "0.4.1-alpha.1" - "@apollographql/graphql-playground-html@1.6.20": version "1.6.20" resolved "https://registry.yarnpkg.com/@apollographql/graphql-playground-html/-/graphql-playground-html-1.6.20.tgz#bf9f2acdf319c0959fad8ec1239741dd2ead4e8d" @@ -1288,13 +1281,13 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" -apollo-cache-control@0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/apollo-cache-control/-/apollo-cache-control-0.6.1.tgz#c73ff521fe606faf18edcbd3463c421a966f3e5d" - integrity sha512-M3cDeQDXtRxYPQ/sL4pu3IVE5Q/9jpBlENB2IjwxTDir+WFZbJV1CAnvVwyJdL1DvS6ESR35DFOurJH4Ws/OPA== +apollo-cache-control@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/apollo-cache-control/-/apollo-cache-control-0.7.1.tgz#3d4fba232f561f096f61051e103bf58ee4bf8b54" + integrity sha512-3h1TEoMnzex6IIiFb5Ja3owTyLwT5YzK69cRgrSpSscdpYc3ID4KVs0Ht9cbOUmb/L/UKtYVkRC8KeVAYmHEjQ== dependencies: - apollo-server-env "2.3.0" - graphql-extensions "0.6.1" + apollo-server-env "2.4.0" + graphql-extensions "0.7.1" apollo-cache-control@^0.1.0: version "0.1.1" @@ -1345,13 +1338,13 @@ apollo-client@~2.5.1: tslib "^1.9.3" zen-observable "^0.8.0" -apollo-datasource@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/apollo-datasource/-/apollo-datasource-0.4.0.tgz#f042641fd2593fa5f4f002fc30d1fb1a20284df8" - integrity sha512-6QkgnLYwQrW0qv+yXIf617DojJbGmza2XJXUlgnzrGGhxzfAynzEjaLyYkc8rYS1m82vjrl9EOmLHTcnVkvZAQ== +apollo-datasource@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/apollo-datasource/-/apollo-datasource-0.5.0.tgz#7a8c97e23da7b9c15cb65103d63178ab19eca5e9" + integrity sha512-SVXxJyKlWguuDjxkY/WGlC/ykdsTmPxSF0z8FenagcQ91aPURXzXP1ZDz5PbamY+0iiCRubazkxtTQw4GWTFPg== dependencies: apollo-server-caching "0.4.0" - apollo-server-env "2.3.0" + apollo-server-env "2.4.0" apollo-engine-reporting-protobuf@0.3.0: version "0.3.0" @@ -1360,26 +1353,17 @@ apollo-engine-reporting-protobuf@0.3.0: dependencies: protobufjs "^6.8.6" -apollo-engine-reporting@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/apollo-engine-reporting/-/apollo-engine-reporting-1.1.1.tgz#f5a3240bc5c5afb210ff8c45d72995de7b0d2a13" - integrity sha512-K7BDsj99jr8ftd9NIuHL4oF/S7CBFcgMGjL0ChhfxpkgUv80FPxJ+9Fs+9ZkKIVylV3PCi2WnihpDeEO10eZAw== +apollo-engine-reporting@1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/apollo-engine-reporting/-/apollo-engine-reporting-1.2.1.tgz#0b77fad2e9221d62f4a29b8b4fab8f7f47dcc1d6" + integrity sha512-DVXZhz/nSZR4lphakjb1guAD0qJ7Wm1PVtZEBjN097cnOor4XSOzQlPfTaYtVuhlxUKUuCx1syiBbOuV8sKqXg== dependencies: apollo-engine-reporting-protobuf "0.3.0" - apollo-graphql "^0.2.1-alpha.1" - apollo-server-core "2.5.1" - apollo-server-env "2.3.0" + apollo-graphql "^0.3.0" + apollo-server-core "2.6.1" + apollo-server-env "2.4.0" async-retry "^1.2.1" - graphql-extensions "0.6.1" - -apollo-env@0.4.1-alpha.1: - version "0.4.1-alpha.1" - resolved "https://registry.yarnpkg.com/apollo-env/-/apollo-env-0.4.1-alpha.1.tgz#10d3ea508b8f3ba03939ef4e6ec4b2b5db77e8f1" - integrity sha512-4qWiaUKWh92jvKxxRsiZSjmW9YH9GWSG1W6X+S1BcC1uqtPiHsem7ExG9MMTt+UrzHsbpQLctj12xk8lI4lgCg== - dependencies: - core-js "3.0.0-beta.13" - node-fetch "^2.2.0" - sha.js "^2.4.11" + graphql-extensions "0.7.1" apollo-env@0.5.1: version "0.5.1" @@ -1398,12 +1382,12 @@ apollo-errors@^1.9.0: assert "^1.4.1" extendable-error "^0.1.5" -apollo-graphql@^0.2.1-alpha.1: - version "0.2.1-alpha.1" - resolved "https://registry.yarnpkg.com/apollo-graphql/-/apollo-graphql-0.2.1-alpha.1.tgz#a0cc0bd65e03c7e887c96c9f53421f3c6dd7b599" - integrity sha512-kObCSpYRHEf4IozJV+TZAXEL2Yni2DpzQckohJNYXg5/KRAF20jJ7lHxuJz+kMQrc7QO4wYGSa29HuFZH2AtQA== +apollo-graphql@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/apollo-graphql/-/apollo-graphql-0.3.1.tgz#d13b80cc0cae3fe7066b81b80914c6f983fac8d7" + integrity sha512-tbhtzNAAhNI34v4XY9OlZGnH7U0sX4BP1cJrUfSiNzQnZRg1UbQYZ06riHSOHpi5RSndFcA9LDM5C1ZKKOUeBg== dependencies: - apollo-env "0.4.1-alpha.1" + apollo-env "0.5.1" lodash.sortby "^4.7.0" apollo-link-context@~1.0.14: @@ -1456,24 +1440,24 @@ apollo-server-caching@0.4.0: dependencies: lru-cache "^5.0.0" -apollo-server-core@2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.5.1.tgz#0fdb6cfca56a0f5b5b3aecffb48db17b3c8e1d71" - integrity sha512-4QNrW1AUM3M/p0+hbBX/MsjSjZTy+2rt7JpiKKkG9RmeEIzd/VG7hwwwloAZSLjYx3twz0+BnASJ9y+rGEPC8A== +apollo-server-core@2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.6.1.tgz#d0d878b0a4959b6c661fc43300ce45b29996176a" + integrity sha512-jO2BtcP7ozSSK5qtw1gGDwO66WSNtzhvpDJD7erkA9byv8Z0jB2QIPNWN6iaj311LaPahM05k+8hMIhFy9oHWg== dependencies: "@apollographql/apollo-tools" "^0.3.6" "@apollographql/graphql-playground-html" "1.6.20" "@types/ws" "^6.0.0" - apollo-cache-control "0.6.1" - apollo-datasource "0.4.0" - apollo-engine-reporting "1.1.1" + apollo-cache-control "0.7.1" + apollo-datasource "0.5.0" + apollo-engine-reporting "1.2.1" apollo-server-caching "0.4.0" - apollo-server-env "2.3.0" + apollo-server-env "2.4.0" apollo-server-errors "2.3.0" - apollo-server-plugin-base "0.4.1" - apollo-tracing "0.6.1" + apollo-server-plugin-base "0.5.1" + apollo-tracing "0.7.1" fast-json-stable-stringify "^2.0.0" - graphql-extensions "0.6.1" + graphql-extensions "0.7.1" graphql-subscriptions "^1.0.0" graphql-tag "^2.9.2" graphql-tools "^4.0.0" @@ -1491,10 +1475,10 @@ apollo-server-core@^1.3.6, apollo-server-core@^1.4.0: apollo-tracing "^0.1.0" graphql-extensions "^0.0.x" -apollo-server-env@2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/apollo-server-env/-/apollo-server-env-2.3.0.tgz#f0bf4484a6cc331a8c13763ded56e91beb16ba17" - integrity sha512-WIwlkCM/gir0CkoYWPMTCH8uGCCKB/aM074U1bKayvkFOBVO2VgG5x2kgsfkyF05IMQq2/GOTsKhNY7RnUEhTA== +apollo-server-env@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/apollo-server-env/-/apollo-server-env-2.4.0.tgz#6611556c6b627a1636eed31317d4f7ea30705872" + integrity sha512-7ispR68lv92viFeu5zsRUVGP+oxsVI3WeeBNniM22Cx619maBUwcYTIC3+Y3LpXILhLZCzA1FASZwusgSlyN9w== dependencies: node-fetch "^2.1.2" util.promisify "^1.0.0" @@ -1504,10 +1488,10 @@ apollo-server-errors@2.3.0: resolved "https://registry.yarnpkg.com/apollo-server-errors/-/apollo-server-errors-2.3.0.tgz#700622b66a16dffcad3b017e4796749814edc061" integrity sha512-rUvzwMo2ZQgzzPh2kcJyfbRSfVKRMhfIlhY7BzUfM4x6ZT0aijlgsf714Ll3Mbf5Fxii32kD0A/DmKsTecpccw== -apollo-server-express@2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/apollo-server-express/-/apollo-server-express-2.5.1.tgz#b112d9795f2fb39076d9cbc109f5eeb7835bed6b" - integrity sha512-528wDQnOMIenDaICkYPFWQykdXQZwpygxd+Ar0PmZiaST042NSVExV4iRWI09p1THqfsuyHygqpkK+K94bUtBA== +apollo-server-express@2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/apollo-server-express/-/apollo-server-express-2.6.1.tgz#1e2649d3fd38c0c0a2c830090fd41e086b259c9f" + integrity sha512-TVu68LVp+COMGOXuxc0OFeCUQiPApxy7Isv2Vk85nikZV4t4FXlODB6PrRKf5rfvP31dvGsfE6GHPJTLLbKfyg== dependencies: "@apollographql/graphql-playground-html" "1.6.20" "@types/accepts" "^1.3.5" @@ -1515,7 +1499,7 @@ apollo-server-express@2.5.1: "@types/cors" "^2.8.4" "@types/express" "4.16.1" accepts "^1.3.5" - apollo-server-core "2.5.1" + apollo-server-core "2.6.1" body-parser "^1.18.3" cors "^2.8.4" graphql-subscriptions "^1.0.0" @@ -1543,36 +1527,36 @@ apollo-server-module-graphiql@^1.3.4, apollo-server-module-graphiql@^1.4.0: resolved "https://registry.yarnpkg.com/apollo-server-module-graphiql/-/apollo-server-module-graphiql-1.4.0.tgz#c559efa285578820709f1769bb85d3b3eed3d8ec" integrity sha512-GmkOcb5he2x5gat+TuiTvabnBf1m4jzdecal3XbXBh/Jg+kx4hcvO3TTDFQ9CuTprtzdcVyA11iqG7iOMOt7vA== -apollo-server-plugin-base@0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-0.4.1.tgz#be380b28d71ad3b6b146d0d6a8f7ebf5675b07ff" - integrity sha512-D2G6Ca/KBdQgEbmSfYqZqYbdVJnk/rrSv7Vj2NntwjfL7WJf0TjufxYJlrTH5jF6xCbsszDNGqfmt2Nm8x/o4g== +apollo-server-plugin-base@0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-0.5.1.tgz#b81056666763879bdc98d8d58f3c4c43cbb30da6" + integrity sha512-UejnBk6XDqYQ+Ydkbm+gvlOzP+doQA8glVUULs8rCi0/MshsFSsBVl6rtzruELDBVgZhJgGsd4pUexcvNc3aZA== -apollo-server-testing@~2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/apollo-server-testing/-/apollo-server-testing-2.5.1.tgz#9f210caa738a275a30269b6d8a3b29bce01b69a1" - integrity sha512-npaj92Z33sNt4beBuoLJqlicqtawqI/41CA9/IrcswI9WwlWIxNKhfpcMYo9MpQWRT8aCIGOOAkBdG2jZlhH4Q== +apollo-server-testing@~2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/apollo-server-testing/-/apollo-server-testing-2.6.1.tgz#447f34980819fa52b120f26c632fab4efc55435b" + integrity sha512-Qq0u79uKw3g14bq0nGxtUUiueFOv2ETkAax2mum+3f9Lm85VXELkY6c9bCWDVGjkUtt9Aog5qwSzWELb1KiUug== dependencies: - apollo-server-core "2.5.1" + apollo-server-core "2.6.1" -apollo-server@~2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/apollo-server/-/apollo-server-2.5.1.tgz#bfcfbebc123f692c0e6d85b0c56739646bd1bb7e" - integrity sha512-eH3ubq300xhpFAxek28kb+5WZINXpWcwzyNqBQDbuasTlW8qSsqY7xrV6IIz6WUYKdX+ET0mx+Ta1DdaYQPrqw== +apollo-server@~2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/apollo-server/-/apollo-server-2.6.1.tgz#1b1fc6020b75c0913550da5fa0f2005c62f1bc53" + integrity sha512-Ed0zZjluRYPMC3Yr6oXQjcR11izu86nkjiS2MhjJA1mF8IXJfxbPp2hnX4Jf4vXPSkOP2e5ZHw0cdaIcu9GnRw== dependencies: - apollo-server-core "2.5.1" - apollo-server-express "2.5.1" + apollo-server-core "2.6.1" + apollo-server-express "2.6.1" express "^4.0.0" graphql-subscriptions "^1.0.0" graphql-tools "^4.0.0" -apollo-tracing@0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/apollo-tracing/-/apollo-tracing-0.6.1.tgz#48a6d6040f9b2f2b4365a890c2e97cb763eb2392" - integrity sha512-rrDBgTHa9GDA3wY8O7rDsFwC6ePIVzRGxpUsThgmLvIVkkCr0KS4wJJ4C01c+v4xsOXNuQwx0IyYhxZt4twwcA== +apollo-tracing@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/apollo-tracing/-/apollo-tracing-0.7.1.tgz#6a7356b619f3aa0ca22c623b5d8bb1af5ca1c74c" + integrity sha512-1BYQua+jCWFkZZJP0/rSpzY4XbLLbCrRHCYu8sJn0RCH/hs34BMdFXscS9uSglgIpXwUAIafgsU0hAVCrJjbTw== dependencies: - apollo-server-env "2.3.0" - graphql-extensions "0.6.1" + apollo-server-env "2.4.0" + graphql-extensions "0.7.1" apollo-tracing@^0.1.0: version "0.1.4" @@ -2441,11 +2425,6 @@ core-js-pure@3.1.2: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.1.2.tgz#62fc435f35b7374b9b782013cdcb2f97e9f6dffa" integrity sha512-5ckIdBF26B3ldK9PM177y2ZcATP2oweam9RskHSoqfZCrJ2As6wVg8zJ1zTriFsZf6clj/N1ThDFRGaomMsh9w== -core-js@3.0.0-beta.13: - version "3.0.0-beta.13" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.0.0-beta.13.tgz#7732c69be5e4758887917235fe7c0352c4cb42a1" - integrity sha512-16Q43c/3LT9NyePUJKL8nRIQgYWjcBhjJSMWg96PVSxoS0PeE0NHitPI3opBrs9MGGHjte1KoEVr9W63YKlTXQ== - core-js@^2.4.0, core-js@^2.5.3, core-js@^2.5.7: version "2.6.2" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.2.tgz#267988d7268323b349e20b4588211655f0e83944" @@ -3749,12 +3728,12 @@ graphql-deduplicator@^2.0.1: resolved "https://registry.yarnpkg.com/graphql-deduplicator/-/graphql-deduplicator-2.0.2.tgz#d8608161cf6be97725e178df0c41f6a1f9f778f3" integrity sha512-0CGmTmQh4UvJfsaTPppJAcHwHln8Ayat7yXXxdnuWT+Mb1dBzkbErabCWzjXyKh/RefqlGTTA7EQOZHofMaKJA== -graphql-extensions@0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.6.1.tgz#e61c4cb901e336dc5993a61093a8678a021dda59" - integrity sha512-vB2WNQJn99pncHfvxgcdyVoazmG3cD8XzkgcaDrHTvV+xJGJEBP6056EWi0mNt1d6ukYyRS2zexdekmMCjcq0w== +graphql-extensions@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.7.1.tgz#f55b01ac8ddf09a215e21f34caeee3ae66a88f21" + integrity sha512-4NkAz/f0j5a1DSPl3V77OcesBmwhHz56Soj0yTImlcDdRv9knyO2e+ehi1TIeKBOyIKS7d3A7zqOW/4ieGxlVA== dependencies: - "@apollographql/apollo-tools" "^0.3.6-alpha.1" + "@apollographql/apollo-tools" "^0.3.6" graphql-extensions@^0.0.x, graphql-extensions@~0.0.9: version "0.0.10" diff --git a/deployment/legacy-migration/maintenance-worker/migration/mongo/.env b/deployment/legacy-migration/maintenance-worker/migration/mongo/.env index 602f51fc4..4c5f9e18c 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/mongo/.env +++ b/deployment/legacy-migration/maintenance-worker/migration/mongo/.env @@ -12,5 +12,6 @@ # On Windows this resolves to C:\Users\dornhoeschen\AppData\Local\Temp\mongo-export (MinGW) EXPORT_PATH='/tmp/mongo-export/' EXPORT_MONGOEXPORT_BIN='mongoexport' +MONGO_EXPORT_SPLIT_SIZE=100 # On Windows use something like this -# EXPORT_MONGOEXPORT_BIN='C:\Program Files\MongoDB\Server\3.6\bin\mongoexport.exe' \ No newline at end of file +# EXPORT_MONGOEXPORT_BIN='C:\Program Files\MongoDB\Server\3.6\bin\mongoexport.exe' diff --git a/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh b/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh index 257bc4c61..abed9b0f5 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh @@ -10,7 +10,7 @@ set +o allexport function export_collection () { "${EXPORT_MONGOEXPORT_BIN}" --db ${MONGODB_DATABASE} --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONGODB_USERNAME} --password ${MONGODB_PASSWORD} --authenticationDatabase ${MONGODB_AUTH_DB} --collection $1 --collection $1 --out "${EXPORT_PATH}$1.json" mkdir -p ${EXPORT_PATH}splits/$1/ - split -l 1000 -a 3 ${EXPORT_PATH}$1.json ${EXPORT_PATH}splits/$1/ + split -l ${MONGO_EXPORT_SPLIT_SIZE} -a 3 ${EXPORT_PATH}$1.json ${EXPORT_PATH}splits/$1/ } # Delete old export & ensure directory diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh index 08c05c8cc..ac256e3f0 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh @@ -83,17 +83,17 @@ import_collection "contributions" import_collection "shouts" import_collection "comments" -import_collection "emotions" -import_collection "invites" -import_collection "notifications" -import_collection "organizations" -import_collection "pages" -import_collection "projects" -import_collection "settings" -import_collection "status" -import_collection "systemnotifications" -import_collection "userscandos" -import_collection "usersettings" +# import_collection "emotions" +# import_collection "invites" +# import_collection "notifications" +# import_collection "organizations" +# import_collection "pages" +# import_collection "projects" +# import_collection "settings" +# import_collection "status" +# import_collection "systemnotifications" +# import_collection "userscandos" +# import_collection "usersettings" echo "DONE" diff --git a/docker-compose.maintenance.yml b/docker-compose.maintenance.yml index ad599e153..e536b1157 100644 --- a/docker-compose.maintenance.yml +++ b/docker-compose.maintenance.yml @@ -30,6 +30,7 @@ services: - "MONGODB_AUTH_DB=${MONGODB_AUTH_DB}" - "MONGODB_DATABASE=${MONGODB_DATABASE}" - "UPLOADS_DIRECTORY=${UPLOADS_DIRECTORY}" + - "MONGO_EXPORT_SPLIT_SIZE=${MONGO_EXPORT_SPLIT_SIZE}" ports: - 7687:7687 - 7474:7474 diff --git a/scripts/docker_push.sh b/scripts/docker_push.sh index 1f627cf1a..9aa9a8e2a 100755 --- a/scripts/docker_push.sh +++ b/scripts/docker_push.sh @@ -2,5 +2,7 @@ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-backend:latest $TRAVIS_BUILD_DIR/backend docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-web:latest $TRAVIS_BUILD_DIR/webapp +docker build -t humanconnection/nitro-maintenance-worker:latest $TRAVIS_BUILD_DIR/deployment/legacy-migration/maintenance-worker docker push humanconnection/nitro-backend:latest docker push humanconnection/nitro-web:latest +docker push humanconnection/nitro-maintenance-worker:latest diff --git a/webapp/.eslintrc.js b/webapp/.eslintrc.js index 0400fe5f2..f5aa82c81 100644 --- a/webapp/.eslintrc.js +++ b/webapp/.eslintrc.js @@ -10,7 +10,7 @@ module.exports = { }, extends: [ 'standard', - 'plugin:vue/recommended', + 'plugin:vue/essential', 'plugin:prettier/recommended' ], // required to lint *.vue files @@ -25,7 +25,9 @@ module.exports = { 'no-console': ['error'], 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'vue/component-name-in-template-casing': ['error', 'kebab-case'], - 'prettier/prettier': ['error'], + 'prettier/prettier': ['error', { + htmlWhitespaceSensitivity: 'ignore' + }], // 'newline-per-chained-call': [2] } } diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 7274693a4..fc3b17779 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -1,4 +1,4 @@ -FROM node:10-alpine as base +FROM node:12.3.1-alpine as base LABEL Description="Web Frontend of the Social Network Human-Connection.org" Vendor="Human-Connection gGmbH" Version="0.0.1" Maintainer="Human-Connection gGmbH (developer@human-connection.org)" EXPOSE 3000 @@ -18,7 +18,7 @@ COPY . . FROM base as build-and-test RUN cp .env.template .env -RUN yarn install --production=false --frozen-lockfile --non-interactive +RUN yarn install --ignore-engines --production=false --frozen-lockfile --non-interactive RUN yarn run build FROM base as production diff --git a/webapp/components/Avatar/Avatar.vue b/webapp/components/Avatar/Avatar.vue index 2c5cf1ddc..0d997c745 100644 --- a/webapp/components/Avatar/Avatar.vue +++ b/webapp/components/Avatar/Avatar.vue @@ -1,10 +1,5 @@ diff --git a/webapp/components/ContentMenu.vue b/webapp/components/ContentMenu.vue index a2e73b8af..69289cb6d 100644 --- a/webapp/components/ContentMenu.vue +++ b/webapp/components/ContentMenu.vue @@ -1,32 +1,13 @@