merged master in

This commit is contained in:
Grzegorz Leoniec 2018-11-30 10:09:43 +01:00
commit ea18ad8e1f
34 changed files with 1660 additions and 663 deletions

View File

@ -1,7 +1,7 @@
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=letmein
GRAPHQL_LISTEN_PORT=4000
GRAPHQL_PORT=4000
GRAPHQL_URI=http://localhost:4000
MOCK=false

31
.travis.yml Normal file
View File

@ -0,0 +1,31 @@
language: node_js
node_js:
- "10"
services:
- docker
cache:
yarn: true
directories:
- node_modules
install:
- docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT -t humanconnection/nitro-backend .
script:
# TODO: re-add when testing is setup properly
# - docker run humanconnection/nitro-backend yarn run db:seed
after_success:
# - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
# - chmod +x send.sh
# - ./send.sh success $WEBHOOK_URL
- if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_EVENT_TYPE == "push" ]; then
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
docker tag humanconnection/nitro-backend humanconnection/nitro-backend:latest;
docker push humanconnection/nitro-backend:latest;
fi
after_failure:
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh failure $WEBHOOK_URL

View File

@ -1,18 +1,19 @@
FROM node:10-alpine
LABEL Description="Server part of the social network Human Connection" Vendor="Human-Connection gGmbH" Version="0.0.1" Maintainer="Human-Connection gGmbH (developer@human-connection.org)"
LABEL Description="Backend of the Social Network Human-Connection.org" Vendor="Human Connection gGmbH" Version="0.0.1" Maintainer="Human Connection gGmbH (developer@human-connection.org)"
# expose the app port
# Expose the app port
EXPOSE 4000
ARG WORKDIR=/backend
ARG WORKDIR=/nitro-backend
RUN mkdir -p $WORKDIR
WORKDIR $WORKDIR
# Install the Application Dependencies
COPY package.json .
COPY yarn.lock .
RUN yarn install --production=false --frozen-lockfile --non-interactive
COPY . .
COPY .env.template .env
CMD ["yarn", "run", "start"]

View File

@ -105,9 +105,16 @@ Optionally you can seed the GraphQL service by executing mutations that
will write sample data to the database:
```bash
yarn seedDb
yarn run db:seed
# -or-
npm run seedDb
npm run db:seed
```
## Run Tests
```bash
yarn run test
# -or-
npm run test
```
## Todo`s

View File

@ -2,7 +2,7 @@ version: "3.7"
services:
backend:
image: humanconnection/backend:latest
image: humanconnection/nitro-backend:latest
build: .
networks:
- hc-network
@ -12,7 +12,7 @@ services:
- 4000:4000
environment:
- NEO4J_URI=bolt://neo4j:7687
- GRAPHQL_LISTEN_PORT=4000
- GRAPHQL_PORT=4000
- GRAPHQL_URI=http://localhost:4000
- CLIENT_URI=http://localhost:3000
- JWT_SECRET=b/&&7b78BF&fv/Vd

View File

@ -27,7 +27,7 @@ git clone https://github.com/Human-Connection/Nitro-Web.git
Build Docker images, using the Minikube Docker daemon:
```sh
eval $(minikube docker-env)
docker build -t humanconnection/backend:latest Nitro-Backend/
docker build -t humanconnection/nitro-backend:latest Nitro-Backend/
docker build -t humanconnection/neo4j:latest -f Nitro-Backend/Dockerfile.neo4j Nitro-Backend/
```

View File

@ -21,7 +21,7 @@ spec:
- env:
- name: CLIENT_URI
value: http://localhost:3000
- name: GRAPHQL_LISTEN_PORT
- name: GRAPHQL_PORT
value: "4000"
- name: GRAPHQL_URI
value: http://localhost:4000
@ -31,7 +31,7 @@ spec:
value: "false"
- name: NEO4J_URI
value: bolt://neo4j:7687
image: humanconnection/backend:latest
image: humanconnection/nitro-backend:latest
name: backend
ports:
- containerPort: 4000

View File

@ -7,7 +7,7 @@
"test": "mocha --require @babel/register src/**/*.test.js",
"start": "./node_modules/.bin/nodemon --exec babel-node src/index.js",
"start:debug": "./node_modules/.bin/nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js",
"seedDb": "./node_modules/.bin/babel-node src/seed/seed-db.js"
"db:seed": "concurrently --kill-others --success first 'cross-env GRAPHQL_URI=http://localhost:4001 PERMISSIONS=disabled GRAPHQL_PORT=4001 yarn run start' 'wait-on tcp:4001 && cross-env GRAPHQL_URI=http://localhost:4001 ./node_modules/.bin/babel-node src/seed/seed-db.js'"
},
"author": "Human Connection gGmbh",
"license": "MIT",
@ -24,6 +24,7 @@
"apollo-server": "^2.0.4",
"bcryptjs": "^2.4.3",
"cheerio": "^1.0.0-rc.2",
"cross-env": "^5.2.0",
"date-fns": "^2.0.0-alpha.24",
"dotenv": "^6.0.0",
"graphql-custom-directives": "^0.2.13",
@ -48,8 +49,10 @@
"devDependencies": {
"apollo-server-testing": "^2.2.2",
"chai": "^4.2.0",
"concurrently": "^4.1.0",
"faker": "^4.1.0",
"mocha": "^5.2.0",
"nodemon": "^1.18.4"
"nodemon": "^1.18.7",
"wait-on": "^3.2.0"
}
}

20
src/bootstrap/neo4j.js Normal file
View File

@ -0,0 +1,20 @@
import { v1 as neo4j } from 'neo4j-driver'
let driver
export default function () {
return {
getDriver() {
if (!driver) {
driver = neo4j.driver(
process.env.NEO4J_URI || 'bolt://localhost:7687',
neo4j.auth.basic(
process.env.NEO4J_USER || 'neo4j',
process.env.NEO4J_PASSWORD || 'neo4j'
)
)
}
return driver
}
}
}

View File

@ -1,7 +1,7 @@
import server from './server'
const serverConfig = {
port: 4000
port: process.env.GRAPHQL_PORT || 4000
// cors: {
// credentials: true,
// origin: [process.env.CLIENT_URI] // your frontend url.
@ -9,5 +9,5 @@ const serverConfig = {
}
server.start(serverConfig, options => {
console.log(`Server ready at ${process.env.GRAPHQL_URI} 🚀`);
console.log(`Server ready at ${process.env.GRAPHQL_URI} 🚀`)
})

View File

@ -3,28 +3,28 @@ import format from 'date-fns/format'
export default {
Mutation: {
CreateUser: async (resolve, root, args, context, info) => {
args.createdAt = format(new Date())
args.createdAt = (new Date()).toISOString()
args.disabled = false
args.deleted = false
const result = await resolve(root, args, context, info)
return result
},
CreatePost: async (resolve, root, args, context, info) => {
args.createdAt = format(new Date())
args.createdAt = (new Date()).toISOString()
args.disabled = false
args.deleted = false
const result = await resolve(root, args, context, info)
return result
},
CreateComment: async (resolve, root, args, context, info) => {
args.createdAt = format(new Date())
args.createdAt = (new Date()).toISOString()
args.disabled = false
args.deleted = false
const result = await resolve(root, args, context, info)
return result
},
CreateOrganization: async (resolve, root, args, context, info) => {
args.createdAt = format(new Date())
args.createdAt = (new Date()).toISOString()
args.disabled = false
args.deleted = false
const result = await resolve(root, args, context, info)

View File

@ -1,9 +1,14 @@
const urlSearchAlpha = 'https://api-alpha.human-connection.org'
const urlSearchLocal = 'http://localhost:3000'
export const fixUrl = (url) => {
return url.replace('https://api-alpha.human-connection.org', 'http://localhost:3000')
url = url.replace(urlSearchAlpha, '')
url = url.replace(urlSearchLocal, '')
return url
}
const fixImageURLs = (result, recursive) => {
if (result && typeof result === 'string' && result.indexOf('https://api-alpha.human-connection.org') === 0) {
if (result && typeof result === 'string' && (result.indexOf(urlSearchAlpha) === 0 || result.indexOf(urlSearchLocal) === 0)) {
result = fixUrl(result)
} else if (result && Array.isArray(result)) {
result.forEach((res, index) => {

View File

@ -7,13 +7,21 @@ import dateTimeMiddleware from './dateTimeMiddleware';
import xssMiddleware from './xssMiddleware';
import permissionsMiddleware from './permissionsMiddleware';
export default schema => [
permissionsMiddleware.generate(schema),
passwordMiddleware,
dateTimeMiddleware,
sluggifyMiddleware,
excerptMiddleware,
xssMiddleware,
fixImageUrlsMiddleware,
softDeleteMiddleware
]
export default schema => {
let middleware = [
passwordMiddleware,
dateTimeMiddleware,
sluggifyMiddleware,
excerptMiddleware,
xssMiddleware,
fixImageUrlsMiddleware,
softDeleteMiddleware
]
// add permisions middleware at the first position (unless we're seeding)
// NOTE: DO NOT SET THE PERMISSION FLAT YOUR SELF
if (process.env.PERMISSIONS !== 'disabled' && process.env.NODE_ENV !== 'production') {
middleware.unshift(permissionsMiddleware.generate(schema))
}
return middleware
}

View File

@ -4,7 +4,6 @@ const isAuthenticated = rule()(async (parent, args, ctx, info) => {
return ctx.user !== null
})
const isOwner = rule()(async (parent, args, ctx, info) => {
console.log('parent', parent)
return ctx.user.id === parent.id
})
const isAdmin = rule()(async (parent, args, ctx, info) => {
@ -17,18 +16,19 @@ const isModerator = rule()(async (parent, args, ctx, info) => {
// Permissions
const permissions = shield({
Query: {
statistics: isAdmin
statistics: allow
// fruits: and(isAuthenticated, or(isAdmin, isModerator)),
// customers: and(isAuthenticated, isAdmin)
},
Mutation: {
// addFruitToBasket: isAuthenticated
// CreateUser: allow
},
User: {
email: isOwner,
password: isOwner
},
Post: isAuthenticated
}
// Post: isAuthenticated
})
export default permissions

View File

@ -11,12 +11,12 @@ export default {
return result
},
Comment: async (resolve, root, args, context, info) => {
// if (typeof args.deleted !== 'boolean') {
// args.deleted = false
// }
// if (typeof args.disabled !== 'boolean') {
// args.disabled = false
// }
if (typeof args.deleted !== 'boolean') {
args.deleted = false
}
if (typeof args.disabled !== 'boolean') {
args.disabled = false
}
const result = await resolve(root, args, context, info)
return result
},

View File

@ -44,21 +44,6 @@ enum UserGroupEnum {
user
}
type WrittenPost @relation(name: "WROTE") {
from: User
to: Post
timestamp: Int # TODO: change that to custom Date Type
}
# type WrittenPost2 {
# Post: Post!
# timestamp: Int # TODO: change that to custom Date Type
# }
type WrittenComment @relation(name: "WROTE") {
from: User
to: Comment
timestamp: Int # TODO: change that to custom Date Type
}
type User {
id: ID!
name: String
@ -94,7 +79,7 @@ type User {
RETURN COUNT(r)"""
)
comments: [WrittenComment]!
comments: [Comment]! @relation(name: "WROTE", direction: "OUT")
commentsCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment) WHERE NOT r.deleted = true RETURN COUNT(r)")
shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT")
@ -111,7 +96,7 @@ type User {
type Post {
id: ID!
author: WrittenPost
author: User @relation(name: "WROTE", direction: "IN")
title: String!
slug: String
content: String!
@ -141,12 +126,12 @@ type Post {
type Comment {
id: ID!
author: WrittenComment
author: User @relation(name: "WROTE", direction: "IN")
content: String!
contentExcerpt: String
post: Post @relation(name: "COMMENT", direction: "OUT")
createdAt: String,
updatedAt: String,
post: Post @relation(name: "COMMENTS", direction: "OUT")
createdAt: String
updatedAt: String
deleted: Boolean
disabled: Boolean
}

12
src/seed/data/badges.js Normal file
View File

@ -0,0 +1,12 @@
export default function (data) {
return `
mutation {
b1: CreateBadge(id: "b1", key: "indiegogo_en_racoon", type: crowdfunding, status: permanent, icon: "/img/badges/indiegogo_en_racoon.svg") { id }
b2: CreateBadge(id: "b2", key: "indiegogo_en_rabbit", type: crowdfunding, status: permanent, icon: "/img/badges/indiegogo_en_rabbit.svg") { id }
b3: CreateBadge(id: "b3", key: "indiegogo_en_wolf", type: crowdfunding, status: permanent, icon: "/img/badges/indiegogo_en_wolf.svg") { id }
b4: CreateBadge(id: "b4", key: "indiegogo_en_bear", type: crowdfunding, status: permanent, icon: "/img/badges/indiegogo_en_bear.svg") { id }
b5: CreateBadge(id: "b5", key: "indiegogo_en_turtle", type: crowdfunding, status: permanent, icon: "/img/badges/indiegogo_en_turtle.svg") { id }
b6: CreateBadge(id: "b6", key: "indiegogo_en_rhino", type: crowdfunding, status: permanent, icon: "/img/badges/indiegogo_en_rhino.svg") { id }
}
`
}

View File

@ -0,0 +1,22 @@
export default function (data) {
return `
mutation {
cat1: CreateCategory( id: "cat1", name: "Just For Fun", slug: "justforfun", icon: "categories-justforfun" ) { name }
cat2: CreateCategory( id: "cat2", name: "Happyness & Values", slug: "happyness-values", icon: "categories-luck" ) { name }
cat3: CreateCategory( id: "cat3", name: "Health & Wellbeing", slug: "health-wellbeing", icon: "categories-health" ) { name }
cat4: CreateCategory( id: "cat4", name: "Environment & Nature", slug: "environment-nature", icon: "categories-environment" ) { name }
cat5: CreateCategory( id: "cat5", name: "Animal Protection", slug: "animalprotection", icon: "categories-animal-justice" ) { name }
cat6: CreateCategory( id: "cat6", name: "Humanrights Justice", slug: "humanrights-justice", icon: "categories-human-rights" ) { name }
cat7: CreateCategory( id: "cat7", name: "Education & Sciences", slug: "education-sciences", icon: "categories-education" ) { name }
cat8: CreateCategory( id: "cat8", name: "Cooperation & Development", slug: "cooperation-development", icon: "categories-cooperation" ) { name }
cat9: CreateCategory( id: "cat9", name: "Democracy & Politics", slug: "democracy-politics", icon: "categories-politics" ) { name }
cat10: CreateCategory( id: "cat10", name: "Economy & Finances", slug: "economy-finances", icon: "categories-economy" ) { name }
cat11: CreateCategory( id: "cat11", name: "Energy & Technology", slug: "energy-technology", icon: "categories-technology" ) { name }
cat12: CreateCategory( id: "cat12", name: "IT, Internet & Data Privacy", slug: "it-internet-dataprivacy", icon: "categories-internet" ) { name }
cat13: CreateCategory( id: "cat13", name: "Art, Curlure & Sport", slug: "art-culture-sport", icon: "categories-art" ) { name }
cat14: CreateCategory( id: "cat14", name: "Freedom of Speech", slug: "freedomofspeech", icon: "categories-freedom-of-speech" ) { name }
cat15: CreateCategory( id: "cat15", name: "Consumption & Sustainability", slug: "consumption-sustainability", icon: "categories-sustainability" ) { name }
cat16: CreateCategory( id: "cat16", name: "Global Peace & Nonviolence", slug: "globalpeace-nonviolence", icon: "categories-peace" ) { name }
}
`
}

80
src/seed/data/comments.js Normal file
View File

@ -0,0 +1,80 @@
import faker from 'faker'
/**
* TODO: add a comment automatically to the correct post and relate it to the current user
*/
export default function (data) {
return `
mutation {
c1: CreateComment(
id: "c1",
content: "<p>da stimm ich dir zu. Mir ging das auch nie in den kopf, und hatte jesus nie als gott gesehen </p>"
) { id }
c1_u1: AddCommentAuthor(from: { id: "u3" }, to: { id: "c1" }) { from { id } }
c1_p1: AddCommentPost(
from: { id: "c1" },
to: { id: "p1" }
) { from { id } }
c2: CreateComment(
id: "c2",
content: "<p>Schön das es dich gibt ❤️❤️❤️❤️❤️❤️❤️❤️❤️</p>"
) { id }
c2_u1: AddCommentAuthor(from: { id: "u1" }, to: { id: "c2" }) { from { id } }
c2_p1: AddCommentPost(
from: { id: "c2" },
to: { id: "p1" }
) { from { id } }
c3: CreateComment(
id: "c3",
content: "<p>Hi Dieter,</p><p>danke für Deine Info. Hast Du mal ein Foto von Deinem Cabrio mit dem Logo drauf?</p>"
) { id }
c3_u2: AddCommentAuthor(from: { id: "u1" }, to: { id: "c3" }) { from { id } }
c3_p3: AddCommentPost(
from: { id: "c3" },
to: { id: "p3" }
) { from { id } }
c4: CreateComment(
id: "c4",
content: "<p>Das Zusammenführen aller Gruppen, die mit uns am gleichen Strang in die gleiche Richtung ziehen, in eine gemeinsame Adressenstruktur sehe ich auch als Haupt - Aufgabe für unsere neue Netzwerkbildung an.</p>"
) { id }
c4_u3: AddCommentAuthor(from: { id: "u4" }, to: { id: "c4" }) { from { id } }
c4_p2: AddCommentPost(
from: { id: "c4" },
to: { id: "p2" }
) { from { id } }
c5: CreateComment(
id: "c5",
content: "${faker.lorem.paragraph()}"
) { id }
c5_u4: AddCommentAuthor(from: { id: "u4" }, to: { id: "c5" }) { from { id } }
c5_p3: AddCommentPost(
from: { id: "c5" },
to: { id: "p3" }
) { from { id } }
c6: CreateComment(
id: "c6",
content: "${faker.lorem.paragraph()}"
) { id }
c6_u3: AddCommentAuthor(from: { id: "u3" }, to: { id: "c6" }) { from { id } }
c6_p4: AddCommentPost(
from: { id: "c6" },
to: { id: "p4" }
) { from { id } }
c7: CreateComment(
id: "c7",
content: "${faker.lorem.paragraph()}"
) { id }
c7_u2: AddCommentAuthor(from: { id: "u2" }, to: { id: "c7" }) { from { id } }
c7_p2: AddCommentPost(
from: { id: "c7" },
to: { id: "p2" }
) { from { id } }
}
`
}

38
src/seed/data/index.js Normal file
View File

@ -0,0 +1,38 @@
import gql from 'graphql-tag'
import helper from '../seed-helpers'
const seed = {
Badge: require('./badges.js').default,
Category: require('./categories.js').default,
Tags: require('./tags.js').default,
User: require('./users.js').default,
UserBadges: require('./users-badges.js').default,
UserBlacklist: require('./users-blacklist.js').default,
UserFollows: require('./users-follows.js').default,
UserFriends: require('./users-friends.js').default,
Organization: require('./organizations.js').default,
Post: require('./posts.js').default,
Comment: require('./comments.js').default,
UserShouts: require('./users-shouts.js').default
}
let data = {}
export default async function (client) {
// iterate through seeds
await helper.asyncForEach(Object.keys(seed), async key => {
const mutations = seed[key]
try {
const res = await client
.mutate({
mutation: gql(mutations(data))
})
data[key] = Object.assign(data[key] || {}, res.data)
} catch (err) {
console.error(err)
}
})
console.log('Seeded Data', data)
}

View File

@ -0,0 +1,53 @@
import faker from 'faker'
export default () => {
return `mutation {
o1: CreateOrganization(
id: "o1",
name: "Democracy Deutschland",
description: "Description for democracy-deutschland.",
disabled: false,
deleted: false
) { name }
o2: CreateOrganization(
id: "o2",
name: "Human-Connection",
description: "Description for human-connection.",
disabled: false,
deleted: false
) { name }
o3: CreateOrganization(
id: "o3",
name: "Pro Veg",
description: "Description for pro-veg.",
disabled: false,
deleted: false
) { name }
o4: CreateOrganization(
id: "o4",
name: "Greenpeace",
description: "Description for greenpeace.",
disabled: false,
deleted: false
) { name }
u1_c_o1: AddOrganizationCreatedBy(
from: { id: "u1" },
to: { id: "o1" }
) { from { id } }
u1_c_o2: AddOrganizationCreatedBy(
from: { id: "u1" },
to: { id: "o2" }
) { from { id } }
u2_o_o1: AddOrganizationOwnedBy(
from: { id: "u2" },
to: { id: "o2" }
) { from { id } }
u2_c_o3: AddOrganizationOwnedBy(
from: { id: "u2" },
to: { id: "o3" }
) { from { id } }
}
`
}

112
src/seed/data/posts.js Normal file
View File

@ -0,0 +1,112 @@
import faker from 'faker'
export default function (data) {
return `
mutation {
p1: CreatePost(
id: "p1",
title: "Gedanken eines Polizisten zum Einsatz im Hambacher Forst",
content: "<p><strong>Diese Zukunftsstadt ist real und keine Computer-Animation</strong> sondern sie ist das Lebenswerk des mittlerweile über 100 Jahre alten Futuristen und Architekten Jacque Fresco aus Florida. In 35 Jahren (seit seinem 13. Lebensjahr) hat dieser zusammen mit seiner Frau seinen futuristischen Traum von einer besonderen Zukunftsstadt auf 85.000 Quadratmetern realisiert. In den Gebäuden und Gärten befinden sich u.a. ein Forschungszentrum, Vortragsräume und unzählige seiner Modelle &amp; Architekturentwürfe.</p><br /><p>Sein zentrales Anliegen ist eine resourcenbasierte Wirtschaft und die Abschaffung von Geld und Privatbesitz. Mit Hilfe von Roboterarbeit und dem Bedingungslosen Grundeinkommen (da nach seiner Ansicht in den kommenden Jahren fast alle Jobs automatisiert werden), möchte er eine ökologische Landwirtschaft mit Permakulturen etc. und eine effiziente Energiegewinnung (ausschließlich durch regenerative Energien) schaffen. Wenige kompatible Formen in einer sparsamen Modulbauweise (in die u.a. bereits variable Service- und Reparaturelemente integriert sind) sollen insgesamt eine soziale &amp; ökologische Utopie im Einklang mit der Natur ermöglichen.</p><br /><p>Nachfolgend der Direkt-Link auf den interessanten Artikel von Zoltan Istvan, der den Architekten und seine Frau in Florida besuchen durfte und seinen Artikel Ende 2016 auf „MOTHERBOARD“ veröffentlicht hatte:</p><br /><p>https://motherboard.vice.com/de/article/vv34nb/ich-habe-die-zukunft-besucht-in-der-wir-ohne-geld-steuern-und-besitz-leben </p><br /><p>Da soll noch jemand behaupten, es gäbe keine Utopien mehr bzw. keine Futuristen, die ihre kreativen und zukunftsfähigen Ideen (auch in ganz großem Stil) selbst in die Tat umsetzen. LG @all :) </p><br /><p><strong>Wir sind eine Menschheitsfamilie. • Wir sind eins. • Wir sind HUMAN CONNECTION</strong> ❤️</p>",
image: "https://picsum.photos/1280/1024?image=352",
visibility: public,
disabled: false,
deleted: false
) { title }
p1_cat1: AddPostCategories(from: {id: "p1"}, to: {id: "cat1"}) { from { id } }
p1_cat2: AddPostCategories(from: {id: "p1"}, to: {id: "cat2"}) { from { id } }
ur1: AddUserContributions(from: { id: "u1" }, to: { id: "p1" }) { from { id } }
p1_t1: AddPostTags(
from: { id: "p1" }
to: { id: "t1" }
) { from { id } }
p1_t2: AddPostTags(
from: { id: "p1" }
to: { id: "t2" }
) { from { id } }
p1_t3: AddPostTags(
from: { id: "p1" }
to: { id: "t3" }
) { from { id } }
p2: CreatePost(
id: "p2",
title: "Julian Assange",
content: "<p><strong>Diese Zukunftsstadt ist real und keine Computer-Animation</strong> sondern sie ist das Lebenswerk des mittlerweile über 100 Jahre alten Futuristen und Architekten Jacque Fresco aus Florida. In 35 Jahren (seit seinem 13. Lebensjahr) hat dieser zusammen mit seiner Frau seinen futuristischen Traum von einer besonderen Zukunftsstadt auf 85.000 Quadratmetern realisiert. In den Gebäuden und Gärten befinden sich u.a. ein Forschungszentrum, Vortragsräume und unzählige seiner Modelle &amp; Architekturentwürfe.</p><br /><p>Sein zentrales Anliegen ist eine resourcenbasierte Wirtschaft und die Abschaffung von Geld und Privatbesitz. Mit Hilfe von Roboterarbeit und dem Bedingungslosen Grundeinkommen (da nach seiner Ansicht in den kommenden Jahren fast alle Jobs automatisiert werden), möchte er eine ökologische Landwirtschaft mit Permakulturen etc. und eine effiziente Energiegewinnung (ausschließlich durch regenerative Energien) schaffen. Wenige kompatible Formen in einer sparsamen Modulbauweise (in die u.a. bereits variable Service- und Reparaturelemente integriert sind) sollen insgesamt eine soziale &amp; ökologische Utopie im Einklang mit der Natur ermöglichen.</p><br /><p>Nachfolgend der Direkt-Link auf den interessanten Artikel von Zoltan Istvan, der den Architekten und seine Frau in Florida besuchen durfte und seinen Artikel Ende 2016 auf „MOTHERBOARD“ veröffentlicht hatte:</p><br /><p>https://motherboard.vice.com/de/article/vv34nb/ich-habe-die-zukunft-besucht-in-der-wir-ohne-geld-steuern-und-besitz-leben </p><br /><p>Da soll noch jemand behaupten, es gäbe keine Utopien mehr bzw. keine Futuristen, die ihre kreativen und zukunftsfähigen Ideen (auch in ganz großem Stil) selbst in die Tat umsetzen. LG @all :) </p><br /><p><strong>Wir sind eine Menschheitsfamilie. • Wir sind eins. • Wir sind HUMAN CONNECTION</strong> ❤️</p>",
image: "https://picsum.photos/1280/1024?image=72",
visibility: public,
disabled: false,
deleted: false
) { title }
p2_cat1: AddPostCategories(from: {id: "p2"}, to: {id: "cat1"}) { from { id } }
p2_cat16: AddPostCategories(from: {id: "p2"}, to: {id: "cat16"}) { from { id } }
ur2: AddUserContributions(from: { id: "u2" }, to: { id: "p2" }) { from { id } }
p2_t4: AddPostTags(
from: { id: "p2" }
to: { id: "t4" }
) { from { id } }
p3: CreatePost(
id: "p3",
title: "Hacker, Freaks und Funktionäre...Der CCC",
content: "${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()}",
image: "https://picsum.photos/1280/1024?image=121",
visibility: public,
disabled: false,
deleted: false
) { title }
p3_cat1: AddPostCategories(from: {id: "p3"}, to: {id: "cat1"}) { from { id } }
p3_cat3: AddPostCategories(from: {id: "p3"}, to: {id: "cat3"}) { from { id } }
p3_cat14: AddPostCategories(from: {id: "p3"}, to: {id: "cat14"}) { from { id } }
ur3: AddUserContributions(from: { id: "u3" }, to: { id: "p3" }) { from { id } }
p3_t2: AddPostTags(
from: { id: "p3" }
to: { id: "t2" }
) { from { id } }
p3_t4: AddPostTags(
from: { id: "p3" }
to: { id: "t4" }
) { from { id } }
p4: CreatePost(
id: "p4",
title: "Lebensmittel (?)",
content: "${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()}",
image: "https://picsum.photos/1280/1024?image=142",
visibility: public,
disabled: false,
deleted: false
) { title }
p4_cat1: AddPostCategories(from: {id: "p4"}, to: {id: "cat1"}) { from { id } }
p4_cat9: AddPostCategories(from: {id: "p4"}, to: {id: "cat9"}) { from { id } }
p4_cat4: AddPostCategories(from: {id: "p4"}, to: {id: "cat4"}) { from { id } }
ur4: AddUserContributions(from: { id: "u4" }, to: { id: "p4" }) { from { id } }
p5: CreatePost(
id: "p5",
title: "${faker.lorem.sentence()}",
content: "${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()}",
image: "https://picsum.photos/1280/1024?image=231",
visibility: public,
disabled: false,
deleted: false
) { title }
p5_cat8: AddPostCategories(from: {id: "p5"}, to: {id: "cat8"}) { from { id } }
p5_cat12: AddPostCategories(from: {id: "p5"}, to: {id: "cat12"}) { from { id } }
ur5: AddUserContributions(from: { id: "u2" }, to: { id: "p5" }) { from { id } }
p6: CreatePost(
id: "p6",
title: "${faker.lorem.sentence()}",
content: "${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()}",
image: "https://picsum.photos/1280/1024?image=424",
visibility: public,
disabled: false,
deleted: false
) { title }
p6_cat1: AddPostCategories(from: {id: "p6"}, to: {id: "cat1"}) { from { id } }
p6_cat2: AddPostCategories(from: {id: "p6"}, to: {id: "cat2"}) { from { id } }
p6_cat5: AddPostCategories(from: {id: "p6"}, to: {id: "cat5"}) { from { id } }
ur6: AddUserContributions(from: { id: "u4" }, to: { id: "p6" }) { from { id } }
}
`
}

22
src/seed/data/tags.js Normal file
View File

@ -0,0 +1,22 @@
export default function (data) {
return `
mutation {
t1: CreateTag(
id: "t1",
name: "Umwelt"
) { name }
t2: CreateTag(
id: "t2",
name: "Naturschutz"
) { name }
t3: CreateTag(
id: "t3",
name: "Demokratie"
) { name }
t4: CreateTag(
id: "t4",
name: "Freiheit"
) { name }
}
`
}

View File

@ -0,0 +1,12 @@
export default function (data) {
return `
mutation {
b1_u1: AddUserBadges(from: {id: "b1"}, to: {id: "u1"}) { from { id } }
b2_u1: AddUserBadges(from: {id: "b2"}, to: {id: "u1"}) { from { id } }
b3_u1: AddUserBadges(from: {id: "b3"}, to: {id: "u1"}) { from { id } }
b6_u2: AddUserBadges(from: {id: "b6"}, to: {id: "u2"}) { from { id } }
b3_u3: AddUserBadges(from: {id: "b3"}, to: {id: "u3"}) { from { id } }
b5_u4: AddUserBadges(from: {id: "b5"}, to: {id: "u4"}) { from { id } }
}
`
}

View File

@ -0,0 +1,7 @@
export default function (data) {
return `
mutation {
u1_blacklist_u4: AddUserBlacklisted(from: { id: "u1" }, to: { id: "u4" }) { from { id } }
}
`
}

View File

@ -0,0 +1,26 @@
export default function (data) {
return `
mutation {
u1_follow_u2: AddUserFollowing(
from: { id: "u1" },
to: { id: "u2" }
) { from { id } }
u2_follow_u1: AddUserFollowing(
from: { id: "u2" },
to: { id: "u1" }
) { from { id } }
u2_follow_u3: AddUserFollowing(
from: { id: "u2" },
to: { id: "u3" }
) { from { id } }
u2_follow_u4: AddUserFollowing(
from: { id: "u2" },
to: { id: "u4" }
) { from { id } }
u4_follow_u2: AddUserFollowing(
from: { id: "u4" },
to: { id: "u2" }
) { from { id } }
}
`
}

View File

@ -0,0 +1,14 @@
export default function (data) {
return `
mutation {
u1_friends_u2: AddUserFriends(
from: { id: "u1" },
to: { id: "u2" }
) { from { id } }
u1_friends_u3: AddUserFriends(
from: { id: "u1" },
to: { id: "u3" }
) { from { id } }
}
`
}

View File

@ -0,0 +1,30 @@
export default function (data) {
return `
mutation {
u1s2: AddUserShouted(
from: { id: "u1" },
to: { id: "p2" }
) { from { id } }
u1s3: AddUserShouted(
from: { id: "u1" },
to: { id: "p3" }
) { from { id } }
u2s1: AddUserShouted(
from: { id: "u2" },
to: { id: "p1" }
) { from { id } }
u3s1: AddUserShouted(
from: { id: "u3" },
to: { id: "p1" }
) { from { id } }
u3s4: AddUserShouted(
from: { id: "u3" },
to: { id: "p4" }
) { from { id } }
u4s1: AddUserShouted(
from: { id: "u4" },
to: { id: "p1" }
) { from { id } }
}
`
}

68
src/seed/data/users.js Normal file
View File

@ -0,0 +1,68 @@
import faker from 'faker'
export default function (data) {
return `
mutation {
u1: CreateUser(
id: "u1",
name: "Peter Lustig",
password: "1234",
email: "admin@example.org",
avatar: "${faker.internet.avatar()}",
role: admin,
disabled: false,
deleted: false) {
id
name
email
avatar
role
}
u2: CreateUser(
id: "u2",
name: "Bob der Bausmeister",
password: "1234",
email: "moderator@example.org",
avatar: "${faker.internet.avatar()}",
role: moderator,
disabled: false,
deleted: false) {
id
name
email
avatar
role
}
u3: CreateUser(
id: "u3",
name: "Jenny Rostock",
password: "1234",
email: "user@example.org",
avatar: "${faker.internet.avatar()}",
role: user,
disabled: false,
deleted: false) {
id
name
email
avatar
role
}
u4: CreateUser(
id: "u4",
name: "Angie Banjie",
password: "1234",
email: "angie@example.org",
avatar: "${faker.internet.avatar()}",
role: user,
disabled: false,
deleted: false) {
id
name
email
avatar
role
}
}
`
}

View File

@ -1,21 +1,20 @@
import ApolloClient from "apollo-client";
import dotenv from "dotenv";
import gql from 'graphql-tag'
import seedMutations from "./seed-mutations";
import fetch from "node-fetch";
import { HttpLink } from "apollo-link-http";
import { InMemoryCache } from "apollo-cache-inmemory";
import Seed from './data/index'
dotenv.config();
if (process.env.NODE_ENV === 'production') {
throw new Error('YOU CAN`T SEED IN PRODUCTION MODE')
}
const client = new ApolloClient({
link: new HttpLink({ uri: process.env.GRAPHQL_URI, fetch }),
cache: new InMemoryCache()
});
client
.mutate({
mutation: gql(seedMutations)
})
.then(data => console.log(data))
.catch(error => console.error(error));
Seed(client)

145
src/seed/seed-helpers.js Normal file
View File

@ -0,0 +1,145 @@
const _ = require('lodash')
const faker = require('faker')
const unsplashTopics = [
'love',
'family',
'spring',
'business',
'nature',
'travel',
'happy',
'landscape',
'health',
'friends',
'computer',
'autumn',
'space',
'animal',
'smile',
'face',
'people',
'portrait',
'amazing'
]
let unsplashTopicsTmp = []
const ngoLogos = [
'http://www.fetchlogos.com/wp-content/uploads/2015/11/Girl-Scouts-Of-The-Usa-Logo.jpg',
'http://logos.textgiraffe.com/logos/logo-name/Ngo-designstyle-friday-m.png',
'http://seeklogo.com/images/N/ngo-logo-BD53A3E024-seeklogo.com.png',
'https://dcassetcdn.com/design_img/10133/25833/25833_303600_10133_image.jpg',
'https://cdn.tutsplus.com/vector/uploads/legacy/articles/08bad_ngologos/20.jpg',
'https://cdn.tutsplus.com/vector/uploads/legacy/articles/08bad_ngologos/33.jpg',
null
]
const difficulties = ['easy', 'medium', 'hard']
export default {
randomItem: (items, filter) => {
let ids = filter
? Object.keys(items)
.filter(id => {
return filter(items[id])
})
: _.keys(items)
let randomIds = _.shuffle(ids)
return items[randomIds.pop()]
},
randomItems: (items, key = '_id', min = 1, max = 1) => {
let randomIds = _.shuffle(_.keys(items))
let res = []
const count = _.random(min, max)
for (let i = 0; i < count; i++) {
let r = items[randomIds.pop()][key]
if (key === '_id') {
r = r.toString()
}
res.push(r)
}
return res
},
random: (items) => {
return _.shuffle(items).pop()
},
randomDifficulty: () => {
return _.shuffle(difficulties).pop()
},
randomLogo: () => {
return _.shuffle(ngoLogos).pop()
},
randomUnsplashUrl: () => {
if (Math.random() < 0.6) {
// do not attach images in 60 percent of the cases (faster seeding)
return
}
if (unsplashTopicsTmp.length < 2) {
unsplashTopicsTmp = _.shuffle(unsplashTopics)
}
return 'https://source.unsplash.com/daily?' + unsplashTopicsTmp.pop() + ',' + unsplashTopicsTmp.pop()
},
randomCategories: (seederstore, allowEmpty = false) => {
let count = Math.round(Math.random() * 3)
if (allowEmpty === false && count === 0) {
count = 1
}
let categorieIds = _.shuffle(_.keys(seederstore.categories))
let ids = []
for (let i = 0; i < count; i++) {
ids.push(categorieIds.pop())
}
return ids
},
randomAddresses: () => {
const count = Math.round(Math.random() * 3)
let addresses = []
for (let i = 0; i < count; i++) {
addresses.push({
city: faker.address.city(),
zipCode: faker.address.zipCode(),
street: faker.address.streetAddress(),
country: faker.address.countryCode(),
lat: 54.032726 - (Math.random() * 10),
lng: 6.558838 + (Math.random() * 10)
})
}
return addresses
},
/**
* Get array of ids from the given seederstore items after mapping them by the key in the values
*
* @param items items from the seederstore
* @param values values for which you need the ids
* @param key the field key that is represented in the values (slug, name, etc.)
*/
mapIdsByKey: (items, values, key) => {
let res = []
values.forEach(value => {
res.push(_.find(items, [key, value])._id.toString())
})
return res
},
/**
* Provide a way to iterate for each element in an array while waiting for async functions to finish
*
* @param array
* @param callback
* @returns {Promise<void>}
*/
asyncForEach: async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
},
genInviteCode: () => {
const chars = '23456789abcdefghkmnpqrstuvwxyzABCDEFGHJKLMNPRSTUVWXYZ'
let code = ''
for (let i = 0; i < 8; i++) {
const n = _.random(0, chars.length-1)
code += chars.substr(n, 1)
}
return code
}
}

View File

@ -1,420 +0,0 @@
import faker from 'faker'
export default `
mutation {
# Users
u1: CreateUser(
id: "u1",
name: "Peter Lustig",
password: "1234",
email: "admin@example.org",
avatar: "${faker.internet.avatar()}",
role: admin,
disabled: false,
deleted: false) {
id
name
email
avatar
role
}
u2: CreateUser(
id: "u2",
name: "Bob der Bausmeister",
password: "1234",
email: "moderator@example.org",
avatar: "${faker.internet.avatar()}",
role: moderator,
disabled: false,
deleted: false) {
id
name
email
avatar
role
}
u3: CreateUser(
id: "u3",
name: "Jenny Rostock",
password: "1234",
email: "user@example.org",
avatar: "${faker.internet.avatar()}",
role: user,
disabled: false,
deleted: false) {
id
name
email
avatar
role
}
u4: CreateUser(
id: "u4",
name: "Angie Banjie",
password: "1234",
email: "angie@example.org",
avatar: "${faker.internet.avatar()}",
role: user,
disabled: false,
deleted: false) {
id
name
email
avatar
role
}
u1_blacklist_u4: AddUserBlacklisted(from: { id: "u1" }, to: { id: "u4" }) { from { id } }
# Badges
b1: CreateBadge(id: "b1", key: "indiegogo_en_racoon", type: crowdfunding, status: permanent, icon: "http://localhost:3000/img/badges/indiegogo_en_racoon.svg") { id }
b2: CreateBadge(id: "b2", key: "indiegogo_en_rabbit", type: crowdfunding, status: permanent, icon: "http://localhost:3000/img/badges/indiegogo_en_rabbit.svg") { id }
b3: CreateBadge(id: "b3", key: "indiegogo_en_wolf", type: crowdfunding, status: permanent, icon: "http://localhost:3000/img/badges/indiegogo_en_wolf.svg") { id }
b4: CreateBadge(id: "b4", key: "indiegogo_en_bear", type: crowdfunding, status: permanent, icon: "http://localhost:3000/img/badges/indiegogo_en_bear.svg") { id }
b5: CreateBadge(id: "b5", key: "indiegogo_en_turtle", type: crowdfunding, status: permanent, icon: "http://localhost:3000/img/badges/indiegogo_en_turtle.svg") { id }
b6: CreateBadge(id: "b6", key: "indiegogo_en_rhino", type: crowdfunding, status: permanent, icon: "http://localhost:3000/img/badges/indiegogo_en_rhino.svg") { id }
b1_u1: AddUserBadges(from: {id: "b1"}, to: {id: "u1"}) { from { id } }
b2_u1: AddUserBadges(from: {id: "b2"}, to: {id: "u1"}) { from { id } }
b3_u1: AddUserBadges(from: {id: "b3"}, to: {id: "u1"}) { from { id } }
b6_u2: AddUserBadges(from: {id: "b6"}, to: {id: "u2"}) { from { id } }
b3_u3: AddUserBadges(from: {id: "b3"}, to: {id: "u3"}) { from { id } }
b5_u4: AddUserBadges(from: {id: "b5"}, to: {id: "u4"}) { from { id } }
# categories
cat1: CreateCategory( id: "cat1", name: "Just For Fun", slug: "justforfun", icon: "categories-justforfun" ) { name }
cat2: CreateCategory( id: "cat2", name: "Happyness & Values", slug: "happyness-values", icon: "categories-luck" ) { name }
cat3: CreateCategory( id: "cat3", name: "Health & Wellbeing", slug: "health-wellbeing", icon: "categories-health" ) { name }
cat4: CreateCategory( id: "cat4", name: "Environment & Nature", slug: "environment-nature", icon: "categories-environment" ) { name }
cat5: CreateCategory( id: "cat5", name: "Animal Protection", slug: "animalprotection", icon: "categories-animal-justice" ) { name }
cat6: CreateCategory( id: "cat6", name: "Humanrights Justice", slug: "humanrights-justice", icon: "categories-human-rights" ) { name }
cat7: CreateCategory( id: "cat7", name: "Education & Sciences", slug: "education-sciences", icon: "categories-education" ) { name }
cat8: CreateCategory( id: "cat8", name: "Cooperation & Development", slug: "cooperation-development", icon: "categories-cooperation" ) { name }
cat9: CreateCategory( id: "cat9", name: "Democracy & Politics", slug: "democracy-politics", icon: "categories-politics" ) { name }
cat10: CreateCategory( id: "cat10", name: "Economy & Finances", slug: "economy-finances", icon: "categories-economy" ) { name }
cat11: CreateCategory( id: "cat11", name: "Energy & Technology", slug: "energy-technology", icon: "categories-technology" ) { name }
cat12: CreateCategory( id: "cat12", name: "IT, Internet & Data Privacy", slug: "it-internet-dataprivacy", icon: "categories-internet" ) { name }
cat13: CreateCategory( id: "cat13", name: "Art, Curlure & Sport", slug: "art-culture-sport", icon: "categories-art" ) { name }
cat14: CreateCategory( id: "cat14", name: "Freedom of Speech", slug: "freedomofspeech", icon: "categories-freedom-of-speech" ) { name }
cat15: CreateCategory( id: "cat15", name: "Consumption & Sustainability", slug: "consumption-sustainability", icon: "categories-sustainability" ) { name }
cat16: CreateCategory( id: "cat16", name: "Global Peace & Nonviolence", slug: "globalpeace-nonviolence", icon: "categories-peace" ) { name }
# Posts
p1: CreatePost(
id: "p1",
title: "Gedanken eines Polizisten zum Einsatz im Hambacher Forst",
content: "<p><strong>Diese Zukunftsstadt ist real und keine Computer-Animation</strong> sondern sie ist das Lebenswerk des mittlerweile über 100 Jahre alten Futuristen und Architekten Jacque Fresco aus Florida. In 35 Jahren (seit seinem 13. Lebensjahr) hat dieser zusammen mit seiner Frau seinen futuristischen Traum von einer besonderen Zukunftsstadt auf 85.000 Quadratmetern realisiert. In den Gebäuden und Gärten befinden sich u.a. ein Forschungszentrum, Vortragsräume und unzählige seiner Modelle &amp; Architekturentwürfe.</p><br /><p>Sein zentrales Anliegen ist eine resourcenbasierte Wirtschaft und die Abschaffung von Geld und Privatbesitz. Mit Hilfe von Roboterarbeit und dem Bedingungslosen Grundeinkommen (da nach seiner Ansicht in den kommenden Jahren fast alle Jobs automatisiert werden), möchte er eine ökologische Landwirtschaft mit Permakulturen etc. und eine effiziente Energiegewinnung (ausschließlich durch regenerative Energien) schaffen. Wenige kompatible Formen in einer sparsamen Modulbauweise (in die u.a. bereits variable Service- und Reparaturelemente integriert sind) sollen insgesamt eine soziale &amp; ökologische Utopie im Einklang mit der Natur ermöglichen.</p><br /><p>Nachfolgend der Direkt-Link auf den interessanten Artikel von Zoltan Istvan, der den Architekten und seine Frau in Florida besuchen durfte und seinen Artikel Ende 2016 auf „MOTHERBOARD“ veröffentlicht hatte:</p><br /><p>https://motherboard.vice.com/de/article/vv34nb/ich-habe-die-zukunft-besucht-in-der-wir-ohne-geld-steuern-und-besitz-leben </p><br /><p>Da soll noch jemand behaupten, es gäbe keine Utopien mehr bzw. keine Futuristen, die ihre kreativen und zukunftsfähigen Ideen (auch in ganz großem Stil) selbst in die Tat umsetzen. LG @all :) </p><br /><p><strong>Wir sind eine Menschheitsfamilie. • Wir sind eins. • Wir sind HUMAN CONNECTION</strong> ❤️</p>",
image: "https://picsum.photos/1280/1024?image=352",
visibility: public,
disabled: false,
deleted: false
) { title }
p1_cat1: AddPostCategories(from: {id: "p1"}, to: {id: "cat1"}) { from { id } }
p1_cat2: AddPostCategories(from: {id: "p1"}, to: {id: "cat2"}) { from { id } }
ur1: AddUserContributions(from: { id: "u1" }, to: { id: "p1" }) { from { id } }
p2: CreatePost(
id: "p2",
title: "Julian Assange",
content: "<p><strong>Diese Zukunftsstadt ist real und keine Computer-Animation</strong> sondern sie ist das Lebenswerk des mittlerweile über 100 Jahre alten Futuristen und Architekten Jacque Fresco aus Florida. In 35 Jahren (seit seinem 13. Lebensjahr) hat dieser zusammen mit seiner Frau seinen futuristischen Traum von einer besonderen Zukunftsstadt auf 85.000 Quadratmetern realisiert. In den Gebäuden und Gärten befinden sich u.a. ein Forschungszentrum, Vortragsräume und unzählige seiner Modelle &amp; Architekturentwürfe.</p><br /><p>Sein zentrales Anliegen ist eine resourcenbasierte Wirtschaft und die Abschaffung von Geld und Privatbesitz. Mit Hilfe von Roboterarbeit und dem Bedingungslosen Grundeinkommen (da nach seiner Ansicht in den kommenden Jahren fast alle Jobs automatisiert werden), möchte er eine ökologische Landwirtschaft mit Permakulturen etc. und eine effiziente Energiegewinnung (ausschließlich durch regenerative Energien) schaffen. Wenige kompatible Formen in einer sparsamen Modulbauweise (in die u.a. bereits variable Service- und Reparaturelemente integriert sind) sollen insgesamt eine soziale &amp; ökologische Utopie im Einklang mit der Natur ermöglichen.</p><br /><p>Nachfolgend der Direkt-Link auf den interessanten Artikel von Zoltan Istvan, der den Architekten und seine Frau in Florida besuchen durfte und seinen Artikel Ende 2016 auf „MOTHERBOARD“ veröffentlicht hatte:</p><br /><p>https://motherboard.vice.com/de/article/vv34nb/ich-habe-die-zukunft-besucht-in-der-wir-ohne-geld-steuern-und-besitz-leben </p><br /><p>Da soll noch jemand behaupten, es gäbe keine Utopien mehr bzw. keine Futuristen, die ihre kreativen und zukunftsfähigen Ideen (auch in ganz großem Stil) selbst in die Tat umsetzen. LG @all :) </p><br /><p><strong>Wir sind eine Menschheitsfamilie. • Wir sind eins. • Wir sind HUMAN CONNECTION</strong> ❤️</p>",
image: "https://picsum.photos/1280/1024?image=72",
visibility: public,
disabled: false,
deleted: false
) { title }
p2_cat1: AddPostCategories(from: {id: "p2"}, to: {id: "cat1"}) { from { id } }
p2_cat16: AddPostCategories(from: {id: "p2"}, to: {id: "cat16"}) { from { id } }
ur2: AddUserContributions(from: { id: "u2" }, to: { id: "p2" }) { from { id } }
p3: CreatePost(
id: "p3",
title: "Hacker, Freaks und Funktionäre...Der CCC",
content: "${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()}",
image: "https://picsum.photos/1280/1024?image=121",
visibility: public,
disabled: false,
deleted: false
) { title }
p3_cat1: AddPostCategories(from: {id: "p3"}, to: {id: "cat1"}) { from { id } }
p3_cat3: AddPostCategories(from: {id: "p3"}, to: {id: "cat3"}) { from { id } }
p3_cat14: AddPostCategories(from: {id: "p3"}, to: {id: "cat14"}) { from { id } }
ur3: AddUserContributions(from: { id: "u3" }, to: { id: "p3" }) { from { id } }
p4: CreatePost(
id: "p4",
title: "Lebensmittel (?)",
content: "${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()}",
image: "https://picsum.photos/1280/1024?image=142",
visibility: public,
disabled: false,
deleted: false
) { title }
p4_cat1: AddPostCategories(from: {id: "p4"}, to: {id: "cat1"}) { from { id } }
p4_cat9: AddPostCategories(from: {id: "p4"}, to: {id: "cat9"}) { from { id } }
p4_cat4: AddPostCategories(from: {id: "p4"}, to: {id: "cat4"}) { from { id } }
ur4: AddUserContributions(from: { id: "u4" }, to: { id: "p4" }) { from { id } }
p5: CreatePost(
id: "p5",
title: "${faker.lorem.sentence()}",
content: "${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()}",
image: "https://picsum.photos/1280/1024?image=231",
visibility: public,
disabled: false,
deleted: false
) { title }
p5_cat8: AddPostCategories(from: {id: "p5"}, to: {id: "cat8"}) { from { id } }
p5_cat12: AddPostCategories(from: {id: "p5"}, to: {id: "cat12"}) { from { id } }
ur5: AddUserContributions(from: { id: "u2" }, to: { id: "p5" }) { from { id } }
p6: CreatePost(
id: "p6",
title: "${faker.lorem.sentence()}",
content: "${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()} ${faker.lorem.sentence()}",
image: "https://picsum.photos/1280/1024?image=424",
visibility: public,
disabled: false,
deleted: false
) { title }
p6_cat1: AddPostCategories(from: {id: "p6"}, to: {id: "cat1"}) { from { id } }
p6_cat2: AddPostCategories(from: {id: "p6"}, to: {id: "cat2"}) { from { id } }
p6_cat5: AddPostCategories(from: {id: "p6"}, to: {id: "cat5"}) { from { id } }
ur6: AddUserContributions(from: { id: "u4" }, to: { id: "p6" }) { from { id } }
# Comments
c1: CreateComment(
id: "c1",
content: "<p>da stimm ich dir zu. Mir ging das auch nie in den kopf, und hatte jesus nie als gott gesehen. </p>",
disabled: false,
deleted: false
) { id }
c1_u1: AddCommentAuthor(from: { id: "u3" }, to: { id: "c1" }, data: { timestamp: 1538655020 }) { from { id } }
c2: CreateComment(
id: "c2",
content: "<p>Schön das es dich gibt ❤️❤️❤️❤️❤️❤️❤️❤️❤️</p>",
disabled: false,
deleted: false
) { id }
c2_u1: AddCommentAuthor(from: { id: "u1" }, to: { id: "c2" }, data: { timestamp: 1538655020 }) { from { id } }
c3: CreateComment(
id: "c3",
content: "<p>Hi Dieter,</p><p>danke für Deine Info. Hast Du mal ein Foto von Deinem Cabrio mit dem Logo drauf?</p>",
disabled: false,
deleted: false
) { id }
c3_u2: AddCommentAuthor(from: { id: "u1" }, to: { id: "c3" }, data: { timestamp: 1538655020 }) { from { id } }
c4: CreateComment(
id: "c4",
content: "<p>Das Zusammenführen aller Gruppen, die mit uns am gleichen Strang in die gleiche Richtung ziehen, in eine gemeinsame Adressenstruktur sehe ich auch als Haupt - Aufgabe für unsere neue Netzwerkbildung an.</p>",
disabled: false,
deleted: false
) { id }
c4_u3: AddCommentAuthor(from: { id: "u4" }, to: { id: "c4" }, data: { timestamp: 1538655020 }) { from { id } }
c5: CreateComment(
id: "c5",
content: "${faker.lorem.paragraph()}",
disabled: false,
deleted: false
) { id }
c5_u4: AddCommentAuthor(from: { id: "u4" }, to: { id: "c5" }, data: { timestamp: 1538655020 }) { from { id } }
c6: CreateComment(
id: "c6",
content: "${faker.lorem.paragraph()}",
disabled: false,
deleted: false
) { id }
c6_u3: AddCommentAuthor(from: { id: "u3" }, to: { id: "c6" }, data: { timestamp: 1538655020 }) { from { id } }
c7: CreateComment(
id: "c7",
content: "${faker.lorem.paragraph()}",
disabled: false,
deleted: false
) { id }
c7_u2: AddCommentAuthor(from: { id: "u2" }, to: { id: "c7" }, data: { timestamp: 1538655020 }) { from { id } }
c1_p1: AddCommentPost(
from: { id: "c1" },
to: { id: "p1" }
) { from { id } }
c2_p1: AddCommentPost(
from: { id: "c2" },
to: { id: "p1" }
) { from { id } }
c3_p3: AddCommentPost(
from: { id: "c3" },
to: { id: "p3" }
) { from { id } }
c4_p2: AddCommentPost(
from: { id: "c4" },
to: { id: "p2" }
) { from { id } }
c5_p3: AddCommentPost(
from: { id: "c5" },
to: { id: "p3" }
) { from { id } }
c6_p4: AddCommentPost(
from: { id: "c6" },
to: { id: "p4" }
) { from { id } }
c6_p1: AddCommentPost(
from: { id: "c6" },
to: { id: "p1" }
) { from { id } }
c7_p2: AddCommentPost(
from: { id: "c7" },
to: { id: "p2" }
) { from { id } }
# Tags
t1: CreateTag(
id: "t1",
name: "Umwelt"
) { name }
t2: CreateTag(
id: "t2",
name: "Naturschutz"
) { name }
t3: CreateTag(
id: "t3",
name: "Demokratie"
) { name }
t4: CreateTag(
id: "t4",
name: "Freiheit"
) { name }
p1_t1: AddPostTags(
from: { id: "p1" }
to: { id: "t1" }
) { from { id } }
p1_t2: AddPostTags(
from: { id: "p1" }
to: { id: "t2" }
) { from { id } }
p1_t3: AddPostTags(
from: { id: "p1" }
to: { id: "t3" }
) { from { id } }
p2_t4: AddPostTags(
from: { id: "p2" }
to: { id: "t4" }
) { from { id } }
p3_t2: AddPostTags(
from: { id: "p3" }
to: { id: "t2" }
) { from { id } }
p3_t4: AddPostTags(
from: { id: "p3" }
to: { id: "t4" }
) { from { id } }
o1: CreateOrganization(
id: "o1",
name: "Democracy Deutschland",
description: "Description for democracy-deutschland.",
disabled: false,
deleted: false
) { name }
o2: CreateOrganization(
id: "o2",
name: "Human-Connection",
description: "Description for human-connection.",
disabled: false,
deleted: false
) { name }
o3: CreateOrganization(
id: "o3",
name: "Pro Veg",
description: "Description for pro-veg.",
disabled: false,
deleted: false
) { name }
o4: CreateOrganization(
id: "o4",
name: "Greenpeace",
description: "Description for greenpeace.",
disabled: false,
deleted: false
) { name }
u1_c_o1: AddOrganizationCreatedBy(
from: { id: "u1" },
to: { id: "o1" }
) { from { id } }
u1_c_o2: AddOrganizationCreatedBy(
from: { id: "u1" },
to: { id: "o2" }
) { from { id } }
u2_o_o1: AddOrganizationOwnedBy(
from: { id: "u2" },
to: { id: "o2" }
) { from { id } }
u2_c_o3: AddOrganizationOwnedBy(
from: { id: "u2" },
to: { id: "o3" }
) { from { id } }
u1_friends_u2: AddUserFriends(
from: { id: "u1" },
to: { id: "u2" }
) { from { id } }
u1_friends_u3: AddUserFriends(
from: { id: "u1" },
to: { id: "u3" }
) { from { id } }
u1_follow_u2: AddUserFollowing(
from: { id: "u1" },
to: { id: "u2" }
) { from { id } }
u2_follow_u1: AddUserFollowing(
from: { id: "u2" },
to: { id: "u1" }
) { from { id } }
u2_follow_u3: AddUserFollowing(
from: { id: "u2" },
to: { id: "u3" }
) { from { id } }
u2_follow_u4: AddUserFollowing(
from: { id: "u2" },
to: { id: "u4" }
) { from { id } }
u4_follow_u2: AddUserFollowing(
from: { id: "u4" },
to: { id: "u2" }
) { from { id } }
u1s2: AddUserShouted(
from: { id: "u1" },
to: { id: "p2" }
) { from { id } }
u1s3: AddUserShouted(
from: { id: "u1" },
to: { id: "p3" }
) { from { id } }
u2s1: AddUserShouted(
from: { id: "u2" },
to: { id: "p1" }
) { from { id } }
u3s1: AddUserShouted(
from: { id: "u3" },
to: { id: "p1" }
) { from { id } }
u3s4: AddUserShouted(
from: { id: "u3" },
to: { id: "p4" }
) { from { id } }
u4s1: AddUserShouted(
from: { id: "u4" },
to: { id: "p1" }
) { from { id } }
}
`

View File

@ -2,12 +2,12 @@ import { GraphQLServer } from 'graphql-yoga'
import { makeExecutableSchema } from 'apollo-server'
import { augmentSchema } from 'neo4j-graphql-js'
import { typeDefs, resolvers } from './graphql-schema'
import { v1 as neo4j } from 'neo4j-driver'
import dotenv from 'dotenv'
import mocks from './mocks'
import middleware from './middleware'
import applyDirectives from './bootstrap/directives'
import applyScalars from './bootstrap/scalars'
import neo4j from './bootstrap/neo4j'
import passport from 'passport'
import jwtStrategy from './jwt/strategy'
@ -20,13 +20,7 @@ let schema = makeExecutableSchema({
resolvers
})
const driver = neo4j.driver(
process.env.NEO4J_URI || 'bolt://localhost:7687',
neo4j.auth.basic(
process.env.NEO4J_USER || 'neo4j',
process.env.NEO4J_PASSWORD || 'neo4j'
)
)
const driver = neo4j().getDriver()
const MOCK = (process.env.MOCK === 'true')
console.log('MOCK:', MOCK)

1053
yarn.lock

File diff suppressed because it is too large Load Diff