mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge branch 'master' into locations
This commit is contained in:
commit
a562578657
13
.babelrc
13
.babelrc
@ -1 +1,12 @@
|
||||
{ "presets": ["@babel/preset-env"] }
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": {
|
||||
"node": "10"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
2
.codecov.yml
Normal file
2
.codecov.yml
Normal file
@ -0,0 +1,2 @@
|
||||
coverage:
|
||||
range: "60...100"
|
||||
@ -1,9 +1,16 @@
|
||||
.vscode/
|
||||
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
.nyc_output/
|
||||
.github/
|
||||
.travis.yml
|
||||
.graphqlconfig
|
||||
.env
|
||||
|
||||
Dockerfile
|
||||
docker-compose*.yml
|
||||
|
||||
.env
|
||||
./*.png
|
||||
./*.log
|
||||
|
||||
kubernetes/
|
||||
node_modules/
|
||||
scripts/
|
||||
dist/
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,3 +2,6 @@ node_modules/
|
||||
.env
|
||||
.vscode
|
||||
yarn-error.log
|
||||
dist/*
|
||||
coverage.lcov
|
||||
.nyc_output/
|
||||
|
||||
20
.travis.yml
20
.travis.yml
@ -18,12 +18,13 @@ before_install:
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
|
||||
install:
|
||||
- docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT -t humanconnection/nitro-backend:latest .
|
||||
- docker-compose up -d
|
||||
- docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-backend:latest .
|
||||
- docker-compose -f docker-compose.yml -f docker-compose.travis.yml up -d
|
||||
|
||||
script:
|
||||
- docker-compose exec backend yarn run eslint
|
||||
- docker-compose exec backend yarn run mocha
|
||||
- docker-compose exec backend yarn run lint
|
||||
- docker-compose exec backend yarn run test
|
||||
- docker-compose exec backend yarn run test:coverage
|
||||
- docker-compose exec backend yarn run db:reset
|
||||
- docker-compose exec backend yarn run db:seed
|
||||
|
||||
@ -31,11 +32,6 @@ 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
|
||||
@ -43,6 +39,10 @@ after_failure:
|
||||
- ./send.sh failure $WEBHOOK_URL
|
||||
|
||||
deploy:
|
||||
- provider: script
|
||||
script: scripts/docker_push.sh
|
||||
on:
|
||||
branch: master
|
||||
- provider: script
|
||||
script: scripts/deploy.sh nitro.human-connection.org
|
||||
on:
|
||||
@ -53,7 +53,7 @@ deploy:
|
||||
on:
|
||||
branch: master
|
||||
- provider: script
|
||||
script: scripts/deploy.sh "nitro-$(git rev-parse --short HEAD).human-connection.org"
|
||||
script: scripts/deploy.sh "nitro-$TRAVIS_COMMIT.human-connection.org"
|
||||
on:
|
||||
tags: true
|
||||
all_branches: true
|
||||
|
||||
26
Dockerfile
26
Dockerfile
@ -1,19 +1,23 @@
|
||||
FROM node:10-alpine
|
||||
FROM node:10-alpine as base
|
||||
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 4000
|
||||
|
||||
ARG BUILD_COMMIT
|
||||
ENV BUILD_COMMIT=$BUILD_COMMIT
|
||||
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 package.json yarn.lock ./
|
||||
COPY .env.template .env
|
||||
|
||||
CMD ["yarn", "run", "start"]
|
||||
|
||||
FROM base as builder
|
||||
RUN yarn install --frozen-lockfile --non-interactive
|
||||
COPY . .
|
||||
RUN yarn run build
|
||||
|
||||
# reduce image size with a multistage build
|
||||
FROM base as production
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=builder /nitro-backend/dist ./dist
|
||||
RUN yarn install --frozen-lockfile --non-interactive
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# Human-Connection - NITRO Backend
|
||||
[](https://travis-ci.com/Human-Connection/Nitro-Backend)
|
||||
|
||||
> This Prototype tries to resolve the biggest hurdle of connecting
|
||||
> our services together. This is not possible in a sane way using
|
||||
@ -62,6 +63,14 @@ Configure the file `.env` according to your needs and your local setup.
|
||||
|
||||
Start the GraphQL service:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
# -or-
|
||||
npm dev
|
||||
```
|
||||
|
||||
And on the production machine run following:
|
||||
|
||||
```bash
|
||||
yarn start
|
||||
# -or-
|
||||
|
||||
0
dist/.gitkeep
vendored
Normal file
0
dist/.gitkeep
vendored
Normal file
@ -2,9 +2,14 @@ version: "3.7"
|
||||
|
||||
services:
|
||||
backend:
|
||||
image: humanconnection/nitro-backend:builder
|
||||
build:
|
||||
context: .
|
||||
target: builder
|
||||
volumes:
|
||||
- .:/nitro-backend
|
||||
- /nitro-backend/node_modules
|
||||
command: yarn run dev
|
||||
neo4j:
|
||||
ports:
|
||||
- 7687:7687
|
||||
|
||||
8
docker-compose.travis.yml
Normal file
8
docker-compose.travis.yml
Normal file
@ -0,0 +1,8 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
backend:
|
||||
image: humanconnection/nitro-backend:builder
|
||||
build:
|
||||
context: .
|
||||
target: builder
|
||||
@ -3,7 +3,9 @@ version: "3.7"
|
||||
services:
|
||||
backend:
|
||||
image: humanconnection/nitro-backend:latest
|
||||
build: .
|
||||
build:
|
||||
context: .
|
||||
target: production
|
||||
networks:
|
||||
- hc-network
|
||||
depends_on:
|
||||
|
||||
55
package.json
55
package.json
@ -7,37 +7,36 @@
|
||||
"no_auth": "cross-env GRAPHQL_URI=http://localhost:4001 GRAPHQL_PORT=4001 PERMISSIONS=disabled"
|
||||
},
|
||||
"scripts": {
|
||||
"mocha": "./node_modules/.bin/mocha --require @babel/register src/**/*.test.js",
|
||||
"eslint": "eslint src --config .eslintrc.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",
|
||||
"db:script:seed": "wait-on tcp:4001 && ./node_modules/.bin/babel-node src/seed/seed-db.js",
|
||||
"db:script:reset": "wait-on tcp:4001 && ./node_modules/.bin/babel-node src/seed/reset-db.js",
|
||||
"build": "babel src/ -d dist/ --copy-files",
|
||||
"start": "node dist/",
|
||||
"dev": "nodemon --exec babel-node src/index.js",
|
||||
"dev:debug": "nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js",
|
||||
"mocha": "mocha --require @babel/register src/**/*.test.js",
|
||||
"lint": "eslint src --config .eslintrc.js",
|
||||
"test": "nyc --reporter=text-lcov mocha --require @babel/register src/**/*.test.js",
|
||||
"test:coverage": "nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"db:script:seed": "wait-on tcp:4001 && babel-node src/seed/seed-db.js",
|
||||
"db:script:reset": "wait-on tcp:4001 && babel-node src/seed/reset-db.js",
|
||||
"db:seed": "$npm_package_config_no_auth run-p --race start db:script:seed",
|
||||
"db:reset": "$npm_package_config_no_auth run-p --race start db:script:reset"
|
||||
},
|
||||
"author": "Human Connection gGmbH",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/cli": "~7.2.0",
|
||||
"@babel/core": "~7.2.0",
|
||||
"@babel/node": "~7.2.0",
|
||||
"@babel/preset-env": "~7.2.0",
|
||||
"@babel/register": "~7.0.0",
|
||||
"apollo-cache-inmemory": "~1.3.11",
|
||||
"apollo-client": "~2.4.7",
|
||||
"apollo-link-http": "~1.5.7",
|
||||
"apollo-server": "~2.2.6",
|
||||
"apollo-link-http": "~1.5.8",
|
||||
"apollo-server": "~2.3.1",
|
||||
"bcryptjs": "~2.4.3",
|
||||
"cheerio": "~1.0.0-rc.2",
|
||||
"cross-env": "~5.2.0",
|
||||
"date-fns": "^2.0.0-alpha.25",
|
||||
"date-fns": "^2.0.0-alpha.26",
|
||||
"dotenv": "~6.2.0",
|
||||
"graphql": "~0.13.0",
|
||||
"graphql-custom-directives": "~0.2.14",
|
||||
"graphql-iso-date": "~3.6.1",
|
||||
"graphql-middleware": "2.0.2",
|
||||
"graphql-shield": "~4.1.0",
|
||||
"graphql-middleware": "~1.7.8",
|
||||
"graphql-shield": "~4.1.2",
|
||||
"graphql-tag": "~2.10.0",
|
||||
"graphql-yoga": "~1.16.7",
|
||||
"jsonwebtoken": "~8.4.0",
|
||||
@ -45,28 +44,34 @@
|
||||
"lodash": "~4.17.11",
|
||||
"ms": "~2.1.1",
|
||||
"neo4j-driver": "~1.7.2",
|
||||
"neo4j-graphql-js": "2.0.1",
|
||||
"neo4j-graphql-js": "~2.0.1",
|
||||
"node-fetch": "~2.3.0",
|
||||
"passport": "~0.4.0",
|
||||
"passport-jwt": "~4.0.0",
|
||||
"sanitize-html": "~1.19.3",
|
||||
"slug": "~0.9.2",
|
||||
"trunc-html": "~1.1.2"
|
||||
"faker": "~4.1.0",
|
||||
"slug": "~0.9.3",
|
||||
"trunc-html": "~1.1.2",
|
||||
"npm-run-all": "~4.1.5",
|
||||
"wait-on": "~3.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "~7.2.0",
|
||||
"@babel/core": "~7.2.0",
|
||||
"@babel/node": "~7.2.0",
|
||||
"@babel/preset-env": "~7.2.0",
|
||||
"@babel/register": "~7.0.0",
|
||||
"apollo-server-testing": "~2.2.6",
|
||||
"babel-eslint": "~10.0.1",
|
||||
"chai": "~4.2.0",
|
||||
"eslint": "~5.9.0",
|
||||
"eslint": "~5.10.0",
|
||||
"eslint-config-standard": "~12.0.0",
|
||||
"eslint-plugin-import": "~2.14.0",
|
||||
"eslint-plugin-node": "~8.0.0",
|
||||
"eslint-plugin-promise": "~4.0.1",
|
||||
"eslint-plugin-standard": "~4.0.0",
|
||||
"faker": "~4.1.0",
|
||||
"mocha": "^5.2.0",
|
||||
"nodemon": "~1.18.7",
|
||||
"npm-run-all": "~4.1.5",
|
||||
"wait-on": "~3.2.0"
|
||||
"mocha": "~5.2.0",
|
||||
"nodemon": "~1.18.8",
|
||||
"nyc": "^13.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "See me deployed at $1 :)"
|
||||
|
||||
|
||||
3
scripts/docker_push.sh
Executable file
3
scripts/docker_push.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
docker push humanconnection/nitro-backend:latest
|
||||
@ -9,5 +9,6 @@ const serverConfig = {
|
||||
}
|
||||
|
||||
server.start(serverConfig, options => {
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.log(`Server ready at ${process.env.GRAPHQL_URI} 🚀`)
|
||||
})
|
||||
|
||||
@ -31,8 +31,10 @@ export default async function (client) {
|
||||
})
|
||||
data[key] = Object.assign(data[key] || {}, res.data)
|
||||
} catch (err) {
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.error(err)
|
||||
}
|
||||
})
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.log('Seeded Data', data)
|
||||
}
|
||||
|
||||
@ -12,8 +12,10 @@ const driver = neo4j().getDriver()
|
||||
const session = driver.session()
|
||||
|
||||
query('MATCH (n) DETACH DELETE n', session).then(() => {
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.log('Successfully deleted all nodes and relations!')
|
||||
}).catch((err) => {
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.log(`Error occurred deleting the nodes and relations (reset the db)\n\n${err}`)
|
||||
}).finally(() => {
|
||||
if (session) {
|
||||
|
||||
@ -23,6 +23,7 @@ let schema = makeExecutableSchema({
|
||||
const driver = neo4j().getDriver()
|
||||
|
||||
const MOCK = (process.env.MOCK === 'true')
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.log('MOCK:', MOCK)
|
||||
|
||||
schema = augmentSchema(schema, {
|
||||
@ -45,7 +46,9 @@ const server = new GraphQLServer({
|
||||
try {
|
||||
const token = payload.req.headers.authorization.replace('Bearer ', '')
|
||||
payload.user = await jwt.verify(token, process.env.JWT_SECRET)
|
||||
} catch (err) {}
|
||||
} catch (err) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
return payload
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user