You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 27, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+70-45Lines changed: 70 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,13 @@ The API for a better world. More information under [human-connection.org](https:
17
17
18
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
19
20
-
## Development
20
+
## Local installation
21
21
22
22
> we recommand to install the project locally for the best development ease and performance
23
23
24
24
Getting up and running is as easy as 1, 2, 3, 4 ... 5.
25
25
26
-
1. Make sure you have [NodeJS](https://nodejs.org/), [yarn](https://yarnpkg.com),[mongoDB](https://www.mongodb.com/download-center#community) installed.
26
+
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.
27
27
28
28
2. Clone this repo
29
29
```bash
@@ -35,87 +35,112 @@ Getting up and running is as easy as 1, 2, 3, 4 ... 5.
35
35
$ cd ./API
36
36
$ yarn
37
37
```
38
+
4. Setup database seeder for local development (recommended)
38
39
39
-
4. Setup local mailserver (optional)
40
-
41
-
> **Note:**
40
+
Run
41
+
```sh
42
+
$ cp config/local.example.json config/local.json
43
+
```
44
+
45
+
5. Setup local mailserver (optional)
46
+
47
+
> **Note:**
42
48
> *You only have to start that mailserver when you want to register, reset your password or test emails in any form, it
43
49
> 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)
50
+
51
+
Install the [MailDev](https://github.com/djfarrelly/MailDev)
46
52
server to catch all sent emails in a nice web interface.
47
-
53
+
48
54
```bash
49
55
# 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
56
+
$ yarn global add maildev
57
+
58
+
# start the server, it will output the web url
53
59
# which normally is http://localhost:1080
54
60
$ maildev
55
61
```
56
-
62
+
57
63
You could also insert your smtp credentials into the local.json but that is not recommended as all emails would be sent
58
64
to the given addresses which should not happen in development.
59
-
60
-
5. Start server
61
65
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:
66
+
6. Start server
67
+
68
+
You don't have a background process running for mongodb?
69
+
Just open another terminal and run:
70
+
71
+
```bash
72
+
# open up another terminal and run:
73
+
$ yarn run mongo
74
+
# or if you are on windows, run:
75
+
$ yarn run mongo:win
76
+
```
77
+
> ##### IMPORTANT for Windows users:
78
+
> - make sure you have mongo bin directory added to your PATH
79
+
80
+
Start the API server with the following commands:
63
81
```bash
64
-
# start mongodb, feathers and seed database
65
82
$ yarn dev
66
-
$ yarn dev:win if you're on windows
67
83
68
-
# start mongodb, feathers without seeding the database
69
-
$ yarn dev:noseed
70
-
71
-
# start mongodb, feathers for production
84
+
# without hot reload
72
85
$ yarn start
86
+
# you can customize the environment like this:
87
+
$ NODE_ENV=production yarn start
73
88
```
74
89
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
90
84
-
6. Setup and Start Thumbnail Service (optional)
91
+
Now, your API should be running at [http://localhost:3030](http://localhost:3030).
92
+
If you seeded your database, you will see some contributions at [http://localhost:3030/contributions](http://localhost:3030/contributions).
93
+
94
+
7. Setup and Start Thumbnail Service (optional)
85
95
86
96
We are using [Thumbor](https://github.com/thumbor/thumbor) as a Thumbnail Microservice.
87
97
You can install it locally if you like but this is totally optional.
88
-
98
+
89
99
**Install OR use docker**
90
-
100
+
91
101
- 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
102
- 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
103
96
-
## Local configuration
104
+
> Do not forget to always start it if you choose that setup or otherwise you will not see any pictures at all.
97
105
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.
106
+
### Local configuration
99
107
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`.
108
+
You can override any default configuration in `config/local.json`. You can find
109
+
a list of availabe defaults in `config/default.json`.
110
+
See [node-config documentation](https://github.com/lorenwest/node-config/wiki/Configuration-Files)
111
+
for details.
101
112
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).
113
+
E.g. if you want to access the server from your mobile over WiFi, you should
114
+
replace `localhost` in your settings with your IP address in the local network:
115
+
```json
116
+
{
117
+
"host": "192.168.188.22",
118
+
"baseURL": "http://192.168.188.22:3030",
119
+
"frontURL": "http://192.168.188.22:3000"
120
+
}
106
121
107
-
> **Note** *You can switch the `dropDatabase` entry after seeding and it will persist the seeded data.*
122
+
```
108
123
109
124
## Testing
110
125
111
-
Simply run `yarn test` and all your tests in the `test/` directory will be run.
126
+
Run the entire test suite with:
127
+
```bash
128
+
$ yarn run test
129
+
```
130
+
131
+
If you want you can run specific tests:
132
+
```bash
133
+
$ yarn run mocha
134
+
$ yarn run cucumber
135
+
```
136
+
112
137
113
138
## Scaffolding
114
139
115
140
Feathers has a powerful command line interface. Here are a few things it can do:
0 commit comments