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

Commit 2079253

Browse files
authored
Merge pull request #170 from Human-Connection/develop
Update master
2 parents 37fea2d + e95b29c commit 2079253

36 files changed

+2385
-443
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ node_modules
3434
.classpath
3535
.c9/
3636
.vscode
37+
/.vs
3738
*.launch
3839
.settings/
3940
*.sublime-workspace
@@ -123,3 +124,4 @@ rethinkdb_data
123124
.env
124125
/config/local.json
125126
package-lock.json
127+
/.github

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ jobs:
2121
- docker build -t humanconnection/api-feathers .
2222
- script:
2323
- yarn install --frozen-lockfile --non-interactive
24-
- yarn add codacy-coverage
25-
- yarn run eslint
26-
- cp config/cucumber.json config/local.json
27-
- yarn run test:coverage
24+
- yarn global add codacy-coverage
25+
- yarn run ci
2826
- cat ./coverage/lcov.info | codacy-coverage
2927

3028
after_success:

Dockerfile

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
FROM node:8.9-alpine
1+
FROM node:alpine
22
LABEL Description="This image is used to start the hc-api-feathers" Vendor="Human-Connection gGmbH" Version="1.0" Maintainer="Human-Connection gGmbH ([email protected])"
33

4-
# update unix packages
5-
RUN apk update && apk upgrade
6-
RUN rm -rf /var/cache/apk/*
7-
RUN yarn global add pm2
8-
94
# expose the app port
105
EXPOSE 3030
116

12-
# set environment variables
13-
# ENV NPM_CONFIG_PRODUCTION=false
14-
# ENV HOST=0.0.0.0
7+
# override configuration by instance name in docker container
8+
ENV NODE_APP_INSTANCE=docker
159
ENV NODE_ENV=production
16-
ENV API_PORT=3030
17-
18-
# start the application in a autohealing cluster
19-
# NOTE: quick fix for server issues, restart api when reaching max of 300 MB Memory Usage (happens in conjunction with 100% CPU Usage)
20-
# TODO: find better way of dealing with that issue
21-
CMD NODE_ENV=production pm2 start server/index.js -n api --attach --max-memory-restart 1024M
22-
# CMD NODE_ENV=production pm2 start server/index.js -n api -i 2 --attach
23-
# as we have issues with pm2 currently in conjunction with nuxt, we use the standard approach here
24-
# CMD NODE_ENV=production node server/index.js
2510

2611
# create working directory
27-
RUN mkdir -p /var/www/
28-
WORKDIR /var/www/
12+
RUN mkdir -p /API
13+
WORKDIR /API
14+
15+
# --no-cache: download package index on-the-fly, no need to cleanup afterwards
16+
# --virtual: bundle packages, remove whole bundle at once, when done
17+
RUN apk --no-cache --virtual build-dependencies add python make g++
18+
19+
RUN yarn global add pm2
2920

3021
# install app dependencies
31-
COPY package.json /var/www/
32-
COPY yarn.lock /var/www/
33-
RUN yarn install --frozen-lockfile --non-interactive
22+
COPY package.json /API
23+
COPY yarn.lock /API
24+
RUN yarn install --production=false --frozen-lockfile --non-interactive
25+
26+
RUN apk del build-dependencies
27+
3428

3529
# copy the code to the docker image
36-
COPY . /var/www/
30+
COPY . /API
31+
32+
# start the application in a autohealing cluster
33+
# NOTE: quick fix for server issues, restart api when reaching max of 300 MB Memory Usage (happens in conjunction with 100% CPU Usage)
34+
# TODO: find better way of dealing with that issue
35+
CMD ["pm2", "start", "server/index.js", "-n", "api", "--attach", "--max-memory-restart", "1024M"]

README.md

Lines changed: 6 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -12,125 +12,13 @@
1212
</p>
1313

1414
# Human-Connection API
15-
16-
The API for a better world. More information under [human-connection.org](https://human-connection.org)
17-
18-
> **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.
19-
20-
## Development
21-
22-
> we recommand to install the project locally for the best development ease and performance
23-
24-
Getting up and running is as easy as 1, 2, 3, 4 ... 5.
25-
26-
1. Make sure you have [NodeJS](https://nodejs.org/), [yarn](https://yarnpkg.com), [mongoDB](https://www.mongodb.com/download-center#community) installed.
27-
28-
2. Clone this repo
29-
``` bash
30-
$ git clone https://github.com/Human-Connection/API.git
31-
```
32-
33-
3. Install your dependencies
34-
``` bash
35-
$ cd ./API
36-
$ yarn
37-
```
38-
39-
4. Setup local mailserver (optional)
40-
41-
> **Note:**
42-
> *You only have to start that mailserver when you want to register, reset your password or test emails in any form, it
43-
> does not affect the rest of the application.*
44-
45-
Copy `config/local.example.json` to `config/local.json` and install the [MailDev](https://github.com/djfarrelly/MailDev)
46-
server to catch all sent emails in a nice web interface.
47-
48-
``` bash
49-
# install mail dev (only has to be done once)
50-
$ npm install -g maildev
51-
52-
# start the server, it will output the web url
53-
# which normally is http://localhost:1080
54-
$ maildev
55-
```
56-
57-
You could also insert your smtp credentials into the local.json but that is not recommended as all emails would be sent
58-
to the given addresses which should not happen in development.
59-
60-
5. Start server
61-
62-
Make sure that the `data` folder exists according to the `mongod --dbpath` in `package.json` to write the data into, then start the server:
63-
``` bash
64-
# start mongodb, feathers and seed database
65-
$ yarn dev
66-
$ yarn dev:win if you're on windows
67-
68-
# start mongodb, feathers without seeding the database
69-
$ yarn dev:noseed
70-
71-
# start mongodb, feathers for production
72-
$ yarn start
73-
```
74-
75-
> ##### IMPORTANT for WIN users:
76-
> - make sure you have mongo bin directory added to your PATH
77-
> - if you picked another data directory during mongodb setup make sure
78-
> to change package.json scripts section for key "dev:win" so it points to
79-
> the proper path. Otherwise you will get missing data path errors from mongodb.
80-
81-
If you did it right it will seed some fake data for you and downloads some images and avatar for faster development.
82-
Now you should be able to list some post at [http://localhost:3030/contributions](http://localhost:3030/contributions)
83-
84-
6. Setup and Start Thumbnail Service (optional)
85-
86-
We are using [Thumbor](https://github.com/thumbor/thumbor) as a Thumbnail Microservice.
87-
You can install it locally if you like but this is totally optional.
88-
89-
**Install OR use docker**
90-
91-
- At first you have to [install](http://thumbor.readthedocs.io/en/latest/installing.html) it locally and start it in the console with `thumbor` **OR** run it with docker `docker run -p 8000:8000 apsl/thumbor`
92-
- Set the `thumbor.url` in `config/local.json` to `http://localhost:8888` (with docker `http://localhost:8000`) if not defined differently. The `thumbor.key` does not necessarily have to be defined, it just makes the URL more secure.
93-
94-
> Do not forget to always start it if you choose that setup or otherwise you will not see any pictures at all.
95-
96-
## Local configuration
97-
98-
If you need to configure anything you can do so inside the `config/local.json` file. For that the `config/local.example.json` will contain always a minimal setup to get it working.
99-
100-
If, f.ex., you want to change listen address, port or URL, you can do so. Entries in the `config/local.json` will override entries in the `config/default.json`.
101-
102-
**Note on the seeder configuration**
103-
The seeder configuration has two properties:
104-
- **dropDatabase:** drop the whole database on (re)start.
105-
- **runOnInit:** run the seeder always on server (re)start (when database is empty).
106-
107-
> **Note** *You can switch the `dropDatabase` entry after seeding and it will persist the seeded data.*
108-
109-
## Testing
110-
111-
Simply run `yarn test` and all your tests in the `test/` directory will be run.
112-
113-
## Scaffolding
114-
115-
Feathers has a powerful command line interface. Here are a few things it can do:
116-
117-
``` bash
118-
$ npm install -g feathers-cli # Install Feathers CLI
119-
120-
$ feathers generate service # Generate a new Service
121-
$ feathers generate hook # Generate a new Hook
122-
$ feathers generate model # Generate a new Model
123-
$ feathers help # Show all commands
124-
```
15+
This is the backend of HC.<br />
16+
It uses the FeathersJS, NodeJS, yarn and mongoDB.<br />
12517

12618
## Help
127-
128-
For more information on all the framework related things visit [docs.feathersjs.com](http://docs.feathersjs.com).
129-
130-
The HC platform is documented in our [gitbook](https://www.gitbook.com/book/human-connection/documentation/) (work in progress).
19+
The HC platform and its setup is documented in our [docs](https://docs.human-connection.org/) (work in progress).<br />
20+
Connect with other developers over [Discord](https://discord.gg/6ub73U3)<br />
13121

13222
## License
133-
134-
Copyright (c) 2018 [Human-Connection.org](https://human-connection.org)
135-
136-
Licensed under the [MIT](https://github.com/Human-Connection/WebApp/blob/develop/LICENSE.md) license.
23+
Copyright (c) 2018 [Human-Connection.org](https://human-connection.org)<br />
24+
Licensed under the [MIT](https://github.com/Human-Connection/WebApp/blob/develop/LICENSE.md) license.<br />

config/cucumber.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

config/default-docker.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"baseURL": "http://api.127.0.0.1.xip.io:3030",
3+
"mongodb": "mongodb://mongo:27017/hc_api",
4+
"host": "0.0.0.0"
5+
}

config/default.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@
1111
"max": 100
1212
},
1313
"thumbor": {
14-
"url": "",
15-
"key": ""
14+
"url": false,
15+
"key": false
1616
},
1717
"apiSecret": "TE9TqAk2xK[9EFJL",
1818
"sentry": {},
1919
"seeder": {
20-
"runOnInit": true,
21-
"dropDatabase": true
20+
"runOnInit": false,
21+
"dropDatabase": false
22+
},
23+
"defaultEmail": "[email protected]",
24+
"smtpConfig": {
25+
"host": "0.0.0.0",
26+
"port": 1025,
27+
"ignoreTLS": true
2228
},
2329
"mongodb": "mongodb://localhost:27017/hc_api",
2430
"authentication": {

config/local-staging-docker.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"seeder": {
3+
"runOnInit": true,
4+
"dropDatabase": false
5+
},
6+
"smtpConfig": {
7+
"host": "maildev",
8+
"port": 25,
9+
"ignoreTLS": true
10+
},
11+
"thumbor": {
12+
"url": "http://thumbor.127.0.0.1.xip.io:8000",
13+
"key": ""
14+
}
15+
}

config/local.example.json

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
{
2-
"host": "localhost",
3-
"port": 3030,
4-
"baseURL": "http://localhost:3030",
5-
"frontURL": "http://localhost:3000",
6-
"smtpConfig": {
7-
"host": "0.0.0.0",
8-
"port": 1025,
9-
"ignoreTLS": true
10-
},
11-
"thumbor": {
12-
"url": "",
13-
"key": ""
14-
},
152
"seeder": {
163
"runOnInit": true,
174
"dropDatabase": false
18-
},
19-
"defaultEmail": "[email protected]"
5+
}
206
}

config/test-docker.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mongodb": "mongodb://mongo:27017/hc_api_test"
3+
}

0 commit comments

Comments
 (0)