Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into blacklist_feature
Browse files Browse the repository at this point in the history
  • Loading branch information
roschaefer committed Oct 5, 2018
2 parents d305d1c + bf3f51b commit 385380d
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 245 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ node_modules
.classpath
.c9/
.vscode
/.vs
*.launch
.settings/
*.sublime-workspace
Expand Down Expand Up @@ -123,3 +124,4 @@ rethinkdb_data
.env
/config/local.json
package-lock.json
/.github
194 changes: 7 additions & 187 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,193 +12,13 @@
</p>

# Human-Connection API

The API for a better world. More information under [human-connection.org](https://human-connection.org)

> **Note:** This is only the API part of Human-Connection, you have to also checkout the [WebApp](https://github.com/Human-Connection/WebApp) which uses this API.
## Installation via docker

Make sure you have a recent version of [docker](https://www.docker.com/) and [docker-compose](https://docs.docker.com/compose/).

Run:
```bash
$ docker-compose up --build
```
Now, your API should be running at [http://localhost:3030](http://localhost:3030)
and you can see some contributions at [http://localhost:3030/contributions](http://localhost:3030/contributions).

For debugging you can run:
```bash
$ docker-compose run --rm --service-ports api yarn run dev:debug
```
And debug your app with [Chrome Dev Tools](chrome://inspect).

### Configuration in Docker

Change configuration in `config/docker/local-development.json` or
`config/docker/local.json` and rerun `docker-compose up --build`.

#### Local Staging Environment

To get an environment which is close to production, run the following:
```sh
$ docker-compose -f docker-compose.yml -f docker-compose.staging.yml up --build
```

### Testing in Docker

Run the entire test suite with:
```bash
$ docker-compose run --rm api yarn run test
```

If you want you can run specific tests:
```bash
$ docker-compose run --rm api yarn run mocha
$ docker-compose run --rm api yarn run cucumber
```


## Local installation

> we recommand to install the project locally for the best development ease and performance
Getting up and running is as easy as 1, 2, 3, 4 ... 5.

1. Make sure you have a recent version of [NodeJS](https://nodejs.org/), [yarn](https://yarnpkg.com) and [mongoDB](https://www.mongodb.com/download-center#community) installed.

2. Clone this repo
``` bash
$ git clone https://github.com/Human-Connection/API.git
```

3. Install your dependencies
``` bash
$ cd ./API
$ yarn
```
4. Setup database seeder for local development (recommended)

Run
```sh
$ cp config/local.example.json config/local.json
```

5. Setup local mailserver (optional)

> **Note:**
> *You only have to start that mailserver when you want to register, reset your password or test emails in any form, it
> does not affect the rest of the application.*
Install the [MailDev](https://github.com/djfarrelly/MailDev)
server to catch all sent emails in a nice web interface.

``` bash
# install mail dev (only has to be done once)
$ yarn global add maildev

# start the server, it will output the web url
# which normally is http://localhost:1080
$ maildev
```

You could also insert your smtp credentials into the local.json but that is not recommended as all emails would be sent
to the given addresses which should not happen in development.

6. Start server

You don't have a background process running for mongodb?
Just open another terminal and run:

```bash
# open up another terminal and run:
$ yarn run mongo
# or if you are on windows, run:
$ yarn run mongo:win
```
> ##### IMPORTANT for Windows users:
> - make sure you have mongo bin directory added to your PATH
Start the API server with the following commands:
``` bash
$ yarn dev

# without hot reload
$ yarn start
# you can customize the environment like this:
$ NODE_ENV=production yarn start
```


Now, your API should be running at [http://localhost:3030](http://localhost:3030).
If you seeded your database, you will see some contributions at [http://localhost:3030/contributions](http://localhost:3030/contributions).


### Local Configuration

You can override any default configuration in `config/local.json`. You can find
a list of availabe defaults in `config/default.json`.
See [node-config documentation](https://github.com/lorenwest/node-config/wiki/Configuration-Files)
for details.

E.g. if you want to access the server from your mobile over WiFi, you should
replace `localhost` in your settings with your IP address in the local network:
```json
{
"host": "192.168.188.22",
"baseURL": "http://192.168.188.22:3030",
"frontURL": "http://192.168.188.22:3000"
}

```

### Local Testing

Test Logins

| Role | E-Mail | Password |
| --------- | -------------- | -------- |
| Admin | test@test.de | 1234 |
| Moderator | test2@test2.de | 1234 |
| User | test3@test3.de | 1234 |


Run the entire test suite with:
```bash
$ yarn run test
```

If you want you can run specific tests:
```bash
$ yarn run mocha
$ yarn run cucumber
```


## Scaffolding

Feathers has a powerful command line interface. Here are a few things it can do:

``` bash
$ yarn global add feathers-cli # Install Feathers CLI

$ feathers generate service # Generate a new Service
$ feathers generate hook # Generate a new Hook
$ feathers generate model # Generate a new Model
$ feathers help # Show all commands
```
This is the backend of HC.<br />
It uses the FeathersJS, NodeJS, yarn and mongoDB.<br />

## Help
The HC platform and its setup is documented in our [docs](https://docs.human-connection.org/) (work in progress).<br />
Connect with other developers over [Discord](https://discord.gg/6ub73U3)<br />

For more information on all the framework related things visit [docs.feathersjs.com](http://docs.feathersjs.com).

The HC platform is documented in our [gitbook](https://www.gitbook.com/book/human-connection/documentation/) (work in progress).

Connect with other developers over [Discord](https://discord.gg/mVmjvNF).

## License

Copyright (c) 2018 [Human-Connection.org](https://human-connection.org)

Licensed under the [MIT](https://github.com/Human-Connection/WebApp/blob/develop/LICENSE.md) license.
## License
Copyright (c) 2018 [Human-Connection.org](https://human-connection.org)<br />
Licensed under the [MIT](https://github.com/Human-Connection/WebApp/blob/develop/LICENSE.md) license.<br />
1 change: 1 addition & 0 deletions config/default-docker.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"baseURL": "http://api.127.0.0.1.xip.io:3030",
"mongodb": "mongodb://mongo:27017/hc_api",
"host": "0.0.0.0"
}
5 changes: 2 additions & 3 deletions config/local-staging-docker.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"baseURL": "http://172.25.0.11:3030",
"seeder": {
"runOnInit": true,
"dropDatabase": true
"dropDatabase": false
},
"smtpConfig": {
"host": "maildev",
"port": 25,
"ignoreTLS": true
},
"thumbor": {
"url": "http://localhost:8000",
"url": "http://thumbor.127.0.0.1.xip.io:8000",
"key": ""
}
}
2 changes: 1 addition & 1 deletion docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3'
version: '3.5'

services:
api:
Expand Down
24 changes: 2 additions & 22 deletions docker-compose.staging.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
version: '3'
version: '3.5'

services:
api:
container_name: api_api
hostname: api_api
image: humanconnection/api-feathers:edge
build:
context: .
Expand All @@ -18,8 +16,6 @@ services:
- hc-network

maildev:
container_name: api_maildev
hostname: api_maildev
image: djfarrelly/maildev
networks:
- hc-network
Expand All @@ -28,25 +24,9 @@ services:
- "1025:25"

thumbor:
container_name: api_thumbor
hostname: api_thumbor
container_name: thumbor.127.0.0.1.xip.io
image: apsl/thumbor
networks:
- hc-network
ports:
- "8000:8000"

dns-proxy-server:
image: defreitas/dns-proxy-server
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/etc/resolv.conf:/etc/resolv.conf"
ports:
- 5380:5380
hostname: dns.mageddo

networks:
hc-network:
driver: bridge
ipam:
driver: default
17 changes: 16 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
version: '3'
version: '3.5'

services:
api:
container_name: api.127.0.0.1.xip.io
build: .
depends_on:
- mongo
networks:
- hc-network

mongo:
image: mongo
networks:
- hc-network
command: "--smallfiles --logpath=/dev/null"

# dns-proxy-server:
# image: defreitas/dns-proxy-server
# volumes:
# - "/var/run/docker.sock:/var/run/docker.sock"
# - "/etc/resolv.conf:/etc/resolv.conf"
# - "./dns-proxy-server.config.json:/app/conf/config.json"
# ports:
# - 5380:5380
# hostname: dns.mageddo
# networks:
# - hc-network

networks:
hc-network:
name: hc-network
37 changes: 37 additions & 0 deletions features/api/usersettings.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Feature: Save current newsfeed filters to usersettings
As a user of human connection
You would like to have my latest newsfeed filter settings saved
In order to see the same selection of content next time I log in

Background:
Given this is your user account:
| email | password | isVerified |
| user@example.com | 1234 | true |

Scenario: Save your language
Given you are authenticated
When you create your user settings via POST request to "/usersettings" with:
"""
{
"uiLanguage": "de"
}
"""
Then your language "de" is stored in your user settings

Scenario: Save your filter settings
Given you are authenticated
When you create your user settings via POST request to "/usersettings" with:
"""
{
"contentLanguages" : [ "en" ],
"uiLanguage" : "en",
"filter": {
"categoryIds": [
"5b310ab8b801653c1eb6c426",
"5b310ab8b801653c1eb6c427",
"5b310ab8b801653c1eb6c428"
]
}
}
"""
Then these category ids are stored in your user settings
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
"crypto-js": "^3.1.9-1",
"dauria": "~2.0.0",
"email-templates": "2.6.0",
"feathers-authentication-hooks": "~0.3.0",
"feathers-authentication-hooks": "~0.3.1",
"feathers-authentication-management": "~2.0.1",
"feathers-blob": "~2.0.1",
"feathers-hooks-common": "~4.14.3",
"feathers-logger": "0.3.2",
"feathers-mailer": "~2.0.0",
"feathers-memory": "~2.1.3",
"feathers-mongodb": "~3.2.0",
"feathers-mongodb": "~3.3.0",
"feathers-mongodb-fuzzy-search": "~1.1.1",
"feathers-mongoose": "~6.1.2",
"feathers-profiler": "^0.1.5",
Expand Down Expand Up @@ -103,7 +103,7 @@
"babel-eslint": "~8.2.6",
"chai": "^4.1.2",
"cucumber": "^4.2.1",
"concurrently": "~3.6.1",
"concurrently": "~4.0.1",
"cross-env": "^5.2.0",
"eslint": "~4.19.1",
"istanbul": "1.1.0-alpha.1",
Expand Down
Loading

0 comments on commit 385380d

Please # to comment.