mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Transfer relevant changes from branch neode
This commit is contained in:
parent
b515da66f9
commit
f17242b824
@ -16,10 +16,12 @@ before_install:
|
||||
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
|
||||
- chmod +x docker-compose
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
- yarn global add wait-on
|
||||
|
||||
install:
|
||||
- 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
|
||||
- wait-on http://localhost:7474 && docker-compose exec neo4j migrate
|
||||
|
||||
script:
|
||||
- docker-compose exec backend yarn run lint
|
||||
|
||||
22
README.md
22
README.md
@ -3,15 +3,15 @@
|
||||
|
||||
> This Prototype tries to resolve the biggest hurdle of connecting
|
||||
> our services together. This is not possible in a sane way using
|
||||
> our current approach.
|
||||
>
|
||||
> With this Prototype we can explore using the combination of
|
||||
> our current approach.
|
||||
>
|
||||
> With this Prototype we can explore using the combination of
|
||||
> GraphQL and the Neo4j Graph Database for achieving the connected
|
||||
> nature of a social graph with better development experience as we
|
||||
> do not need to connect data by our own any more through weird table
|
||||
> structures etc.
|
||||
|
||||
>
|
||||
>
|
||||
> #### Advantages:
|
||||
> - easer data structure
|
||||
> - better connected data
|
||||
@ -19,10 +19,10 @@
|
||||
> - more performant and better to understand API
|
||||
> - better API client that uses caching
|
||||
>
|
||||
> We still need to evaluate the drawbacks and estimate the development
|
||||
> We still need to evaluate the drawbacks and estimate the development
|
||||
> cost of such an approach
|
||||
|
||||
## How to get in touch
|
||||
## How to get in touch
|
||||
Connect with other developers over [Discord](https://discord.gg/6ub73U3)
|
||||
|
||||
## Quick Start
|
||||
@ -35,6 +35,10 @@ Before you start, fork the repository using the fork button above, then clone it
|
||||
Run:
|
||||
```sh
|
||||
docker-compose up
|
||||
|
||||
# create indices etc.
|
||||
docker-compose exec neo4j migrate
|
||||
|
||||
# if you want seed data
|
||||
# open another terminal and run
|
||||
docker-compose exec backend yarn run db:seed
|
||||
@ -94,7 +98,7 @@ _.env_
|
||||
|
||||
```yaml
|
||||
NEO4J_URI=bolt://localhost:7687
|
||||
NEO4J_USER=neo4j
|
||||
NEO4J_USERNAME=neo4j
|
||||
NEO4J_PASSWORD=letmein
|
||||
```
|
||||
|
||||
@ -116,7 +120,7 @@ Just set `MOCK=true` inside `.env` or pass it on application start.
|
||||
|
||||
## Seed and Reset the Database
|
||||
|
||||
Optionally you can seed the GraphQL service by executing mutations that
|
||||
Optionally you can seed the GraphQL service by executing mutations that
|
||||
will write sample data to the database:
|
||||
|
||||
```bash
|
||||
@ -152,5 +156,5 @@ npm run test
|
||||
- [x] check if sorting is working
|
||||
- [x] check if pagination is working
|
||||
- [ ] check if upload is working (using graphql-yoga?)
|
||||
- [x] evaluate middleware
|
||||
- [x] evaluate middleware
|
||||
- [ ] ignore Posts and Comments by blacklisted Users
|
||||
|
||||
@ -11,6 +11,13 @@ services:
|
||||
- /nitro-backend/node_modules
|
||||
command: yarn run dev
|
||||
neo4j:
|
||||
environment:
|
||||
- NEO4J_AUTH=none
|
||||
ports:
|
||||
- 7687:7687
|
||||
- 7474:7474
|
||||
volumes:
|
||||
- neo4j-data:/data
|
||||
|
||||
volumes:
|
||||
neo4j-data:
|
||||
|
||||
9
docker-compose.prod.yml
Normal file
9
docker-compose.prod.yml
Normal file
@ -0,0 +1,9 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
neo4j:
|
||||
environment:
|
||||
- NEO4J_PASSWORD=letmein
|
||||
backend:
|
||||
environment:
|
||||
- NEO4J_PASSWORD=letmein
|
||||
@ -1,6 +1,12 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
neo4j:
|
||||
environment:
|
||||
- NEO4J_AUTH=none
|
||||
ports:
|
||||
- 7687:7687
|
||||
- 7474:7474
|
||||
backend:
|
||||
image: humanconnection/nitro-backend:builder
|
||||
build:
|
||||
|
||||
@ -27,14 +27,7 @@ services:
|
||||
context: neo4j
|
||||
networks:
|
||||
- hc-network
|
||||
volumes:
|
||||
- neo4j-data:/data
|
||||
environment:
|
||||
- NEO4J_AUTH=none
|
||||
|
||||
networks:
|
||||
hc-network:
|
||||
name: hc-network
|
||||
|
||||
volumes:
|
||||
neo4j-data:
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
FROM neo4j:3.5.0
|
||||
RUN wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.1/apoc-3.5.0.1-all.jar -P plugins/
|
||||
COPY migrate.sh /usr/local/bin/migrate
|
||||
|
||||
11
neo4j/migrate.sh
Executable file
11
neo4j/migrate.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [[ -z "${NEO4J_PASSWORD}" ]]; then
|
||||
echo 'CALL db.index.fulltext.createNodeIndex("full_text_search",["Post"],["title", "content"]);' | cypher-shell
|
||||
else
|
||||
echo "CALL dbms.security.changePassword('${NEO4J_PASSWORD}');" | cypher-shell --username neo4j --password neo4j
|
||||
echo "CREATE CONSTRAINT ON (p:Post) ASSERT p.slug IS UNIQUE;" | cypher-shell
|
||||
echo "CREATE CONSTRAINT ON (c:Category) ASSERT c.slug IS UNIQUE;" | cypher-shell
|
||||
echo "CREATE CONSTRAINT ON (u:User) ASSERT u.slug IS UNIQUE;" | cypher-shell
|
||||
echo "CREATE CONSTRAINT ON (o:Organization) ASSERT o.slug IS UNIQUE;" | cypher-shell
|
||||
fi
|
||||
@ -9,7 +9,7 @@ export default function () {
|
||||
driver = neo4j.driver(
|
||||
process.env.NEO4J_URI || 'bolt://localhost:7687',
|
||||
neo4j.auth.basic(
|
||||
process.env.NEO4J_USER || 'neo4j',
|
||||
process.env.NEO4J_USERNAME || 'neo4j',
|
||||
process.env.NEO4J_PASSWORD || 'neo4j'
|
||||
)
|
||||
)
|
||||
|
||||
15
src/middleware/slugify/uniqueSlug.js
Normal file
15
src/middleware/slugify/uniqueSlug.js
Normal file
@ -0,0 +1,15 @@
|
||||
import slugify from 'slug'
|
||||
export default function uniqueSlug(string, isUnique) {
|
||||
let slug = slugify(string, {
|
||||
lower: true
|
||||
})
|
||||
if (isUnique(slug)) return slug;
|
||||
|
||||
let count = 0
|
||||
let uniqueSlug
|
||||
do {
|
||||
count += 1
|
||||
uniqueSlug = `${slug}-${count}`
|
||||
} while(!isUnique(uniqueSlug));
|
||||
return uniqueSlug;
|
||||
}
|
||||
18
src/middleware/slugify/uniqueSlug.spec.js
Normal file
18
src/middleware/slugify/uniqueSlug.spec.js
Normal file
@ -0,0 +1,18 @@
|
||||
import uniqueSlug from './uniqueSlug'
|
||||
|
||||
describe('uniqueSlug', () => {
|
||||
it('slugifies given string', () => {
|
||||
const string = 'Hello World'
|
||||
const isUnique = () => true
|
||||
expect(uniqueSlug(string, isUnique)).toEqual('hello-world')
|
||||
})
|
||||
|
||||
it('increments slugified string until unique', () => {
|
||||
const string = 'Hello World'
|
||||
const isUnique = jest.fn()
|
||||
isUnique
|
||||
.mockReturnValueOnce(false)
|
||||
.mockReturnValueOnce(true)
|
||||
expect(uniqueSlug(string, isUnique)).toEqual('hello-world-1')
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user