Skip to content
This repository was archived by the owner on Apr 6, 2022. It is now read-only.
Merged

Docs #32

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#############

# postgres url (shared between republik and publikator)
DATABASE_URL=postgres://patte@localhost:5432/republik
DATABASE_URL=postgres://localhost:5432/republik

# redis url, leave blank for default: 127.0.0.1:6379
#REDIS_URL=
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"start": "if [ -z \"$SERVER\" ]; then >&2 echo \"Missing ENV var: SERVER. Possible values are: republik, publikator, assets.\" && exit 1; else cd servers/$SERVER && yarn run start; fi",
"dev": "nf --procfile Procfile-dev start",
"precommit": "lint-staged",
"cloc": "find . -name '*.js' -not -path \"*/node_modules*\" -not -path \"./node_modules*\" | xargs wc -l",
"commit": "git-cz",
"commitmsg": "validate-commit-msg",
"roleUser": "node packages/auth/script/roleUser",
Expand Down
5 changes: 4 additions & 1 deletion packages/documents/lib/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { parse } = require('url')
const visit = require('unist-util-visit')

checkEnv([
'GITHUB_LOGIN',
'FRONTEND_BASE_URL'
])

Expand All @@ -15,6 +14,10 @@ const {
const PUBLIC_HOSTNAME = parse(FRONTEND_BASE_URL).hostname

const getRepoId = (url, requireQuery) => {
checkEnv([
'GITHUB_LOGIN'
])

if (!url) {
return
}
Expand Down
12 changes: 6 additions & 6 deletions packages/github/lib/appAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ const jwt = require('jsonwebtoken')
const fetch = require('isomorphic-unfetch')
const checkEnv = require('check-env')

checkEnv([
'GITHUB_APP_ID',
'GITHUB_APP_KEY',
'GITHUB_INSTALLATION_ID'
])

const {
GITHUB_APP_ID,
GITHUB_APP_KEY,
Expand Down Expand Up @@ -43,6 +37,12 @@ const getAppJWT = () => {
}

const getInstallationToken = async () => {
checkEnv([
'GITHUB_APP_ID',
'GITHUB_APP_KEY',
'GITHUB_INSTALLATION_ID'
])

const response = await fetch(
`https://api.github.com/installations/${GITHUB_INSTALLATION_ID}/access_tokens`,
{
Expand Down
6 changes: 3 additions & 3 deletions servers/republik/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Commented envs are optional

# the url of republik-frontend
CORS_WHITELIST_URL=http://localhost:3010
CORS_WHITELIST_URL=http://localhost:3010,http://localhost:3003

# analytics with apollo's engine
#ENGINE_API_KEY=
Expand Down Expand Up @@ -63,8 +63,8 @@ MAILCHIMP_INTEREST_MEMBER_BENEFACTOR=
#PF_PSPID=

# stripe
STRIPE_PLATFORM=PROJECT_R
STRIPE_CONNECTED_ACCOUNTS=REPUBLIK
STRIPE_PLATFORM=
STRIPE_CONNECTED_ACCOUNTS=

STRIPE_PLATFORM_CLIENT_ID=

Expand Down
12 changes: 6 additions & 6 deletions servers/republik/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ Run it.
yarn run dev
```

Checkout the API: `http://localhost:3020/graphiql`
- [signin](http://localhost:3020/graphiql?query=mutation%20%7BsignIn(email%3A%20%22patrick.recher%40project-r.construction%22)%20%7B%0A%20%20phrase%0A%7D%7D)
- [me](http://localhost:3020/graphiql?query=query%20%7Bme%20%7B%0A%20%20id%0A%20%20email%0A%7D%7D)
Checkout the API: `http://localhost:5000/graphiql`
- [signin](http://localhost:5000/graphiql?query=mutation%20%7BsignIn(email%3A%20%22patrick.recher%40project-r.construction%22)%20%7B%0A%20%20phrase%0A%7D%7D)
- [me](http://localhost:5000/graphiql?query=query%20%7Bme%20%7B%0A%20%20id%0A%20%20email%0A%7D%7D)

### Usage with Docker
### Usage with Docker

You can start the whole stack with docker-compose in production mode:
```
Expand Down Expand Up @@ -110,8 +110,8 @@ The mocked API is not ideal to test the pagination of the `comments` root query.
- move `comments.json` to `./seeds/`
- run `node seeds/seedComments.js`
- Test with the following queries:
- [comments](http://localhost:3020/graphiql?query=query%20getDiscussion(%24parentId%3A%20ID%2C%20%24after%3A%20String)%20%7B%0A%20%20discussions%20%7B%0A%20%20%20%20id%0A%20%20%20%20comments(first%3A%203%2C%20parentId%3A%20%24parentId%2C%20after%3A%20%24after%2C%20orderBy%3A%20HOT%2C%20orderDirection%3A%20DESC)%20%7B%0A%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%0Afragment%20ConnectionInfo%20on%20CommentConnection%20%7B%0A%20%20totalCount%0A%20%20pageInfo%20%7B%0A%20%20%20%20hasNextPage%0A%20%20%20%20endCursor%0A%20%20%7D%0A%7D%0A%0Afragment%20Comment%20on%20Comment%20%7B%0A%20%20id%0A%20%20content%0A%20%20depth%0A%20%20_depth%0A%20%20createdAt%0A%20%20hotness%0A%7D%0A&operationName=getDiscussion&variables=)
- [more comments](http://localhost:3020/graphiql?query=query%20getDiscussion(%24parentId%3A%20ID%2C%20%24after%3A%20String)%20%7B%0A%20%20discussions%20%7B%0A%20%20%20%20id%0A%20%20%20%20comments(first%3A%203%2C%20parentId%3A%20%24parentId%2C%20after%3A%20%24after%2C%20orderBy%3A%20HOT%2C%20orderDirection%3A%20ASC)%20%7B%0A%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20totalCount%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%0Afragment%20ConnectionInfo%20on%20CommentConnection%20%7B%0A%20%20totalCount%0A%20%20pageInfo%20%7B%0A%20%20%20%20hasNextPage%0A%20%20%20%20endCursor%0A%20%20%7D%0A%7D%0A%0Afragment%20Comment%20on%20Comment%20%7B%0A%20%20id%0A%20%20content%0A%20%20depth%0A%20%20_depth%0A%20%20createdAt%0A%20%20hotness%0A%7D%0A&operationName=getDiscussion&variables=%7B%0A%20%20%22after%22%3A%20%22eyJvcmRlckJ5IjoiSE9UIiwib3JkZXJEaXJlY3Rpb24iOiJERVNDIiwicGFyZW50SWQiOiJhZGQzMmUxMy1hYzIyLWU1ZGItZTMyOC01NjU5NTJkNjAwM2MiLCJhZnRlcklkIjoiMWVhNzhkZjgtNDE1Ny1mYTcwLWM5ZDYtMDU3Y2NkNDk5ZTlhIn0%3D%22%0A%7D)
- [comments](http://localhost:5000/graphiql?query=query%20getDiscussion(%24parentId%3A%20ID%2C%20%24after%3A%20String)%20%7B%0A%20%20discussions%20%7B%0A%20%20%20%20id%0A%20%20%20%20comments(first%3A%203%2C%20parentId%3A%20%24parentId%2C%20after%3A%20%24after%2C%20orderBy%3A%20HOT%2C%20orderDirection%3A%20DESC)%20%7B%0A%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%0Afragment%20ConnectionInfo%20on%20CommentConnection%20%7B%0A%20%20totalCount%0A%20%20pageInfo%20%7B%0A%20%20%20%20hasNextPage%0A%20%20%20%20endCursor%0A%20%20%7D%0A%7D%0A%0Afragment%20Comment%20on%20Comment%20%7B%0A%20%20id%0A%20%20content%0A%20%20depth%0A%20%20_depth%0A%20%20createdAt%0A%20%20hotness%0A%7D%0A&operationName=getDiscussion&variables=)
- [more comments](http://localhost:5000/graphiql?query=query%20getDiscussion(%24parentId%3A%20ID%2C%20%24after%3A%20String)%20%7B%0A%20%20discussions%20%7B%0A%20%20%20%20id%0A%20%20%20%20comments(first%3A%203%2C%20parentId%3A%20%24parentId%2C%20after%3A%20%24after%2C%20orderBy%3A%20HOT%2C%20orderDirection%3A%20ASC)%20%7B%0A%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...ConnectionInfo%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20...Comment%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20comments%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20totalCount%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%0Afragment%20ConnectionInfo%20on%20CommentConnection%20%7B%0A%20%20totalCount%0A%20%20pageInfo%20%7B%0A%20%20%20%20hasNextPage%0A%20%20%20%20endCursor%0A%20%20%7D%0A%7D%0A%0Afragment%20Comment%20on%20Comment%20%7B%0A%20%20id%0A%20%20content%0A%20%20depth%0A%20%20_depth%0A%20%20createdAt%0A%20%20hotness%0A%7D%0A&operationName=getDiscussion&variables=%7B%0A%20%20%22after%22%3A%20%22eyJvcmRlckJ5IjoiSE9UIiwib3JkZXJEaXJlY3Rpb24iOiJERVNDIiwicGFyZW50SWQiOiJhZGQzMmUxMy1hYzIyLWU1ZGItZTMyOC01NjU5NTJkNjAwM2MiLCJhZnRlcklkIjoiMWVhNzhkZjgtNDE1Ny1mYTcwLWM5ZDYtMDU3Y2NkNDk5ZTlhIn0%3D%22%0A%7D)

## Testing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ const {
module.exports = async (pgdb) => {
const accountNames = [
STRIPE_PLATFORM,
...STRIPE_CONNECTED_ACCOUNTS
? STRIPE_CONNECTED_ACCOUNTS.split(',')
: { }
]
...(STRIPE_CONNECTED_ACCOUNTS || '').split(',')
].filter(Boolean)

if (!accountNames.length) {
console.warn('missing env STRIPE_PLATFORM and/or STRIPE_CONNECTED_ACCOUNTS, stripe integration will not work')
return {}
}

const companies = await pgdb.public.companies.find({
name: accountNames
Expand Down