Skip to content

Commit 9a6fbf1

Browse files
committed
Complete information about database & tables and mailer, mention MailHog and provide information about setting credentials with environment variables
1 parent cc8fd5d commit 9a6fbf1

1 file changed

Lines changed: 40 additions & 6 deletions

File tree

README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ To find out more about the Clock of Change and Human Connection - the network be
1111
* Express.js: We use the [Express.js](https://expressjs.com/en/) framework - a Node.js framework to help build web applications
1212
* Nodemon: We use [Nodemon](https://nodemon.io/) for development - a handy replacement wrapper for Node.js that automatically restarts the application on file changes
1313
* MySQL: We use [MySQL](https://www.mysql.com) as our relational database of choice to store our data
14-
14+
* MailHog: We use [MailHog](https://github.com/mailhog/MailHog) to debug and preview the email communication
1515

1616
## Project Structure & Components
1717

@@ -21,7 +21,9 @@ To find out more about the Clock of Change and Human Connection - the network be
2121
* core/: The core directory contains the most important files of the project like database, mailer, router and main controller
2222
* core/entryController.js: Is the main controller for all the requests
2323
* core/restapi.js: All routes can be found here, they will also be listed further down
24+
* documentation/: Documentation for the Clock of Change API
2425
* mails/: The mails directory holds the mail templates
26+
* migrations/: Migrations for the database
2527
* public/: The public directory is not used for now
2628

2729

@@ -31,23 +33,55 @@ We use MySQL for the COC API as our relational database.
3133
Currently all of the database related code can be found in the `core/db.js` file.
3234
This includes the credentials for the database (host, user, password and db name) and can be changed in this file.
3335

34-
TODO: Add description of tables
36+
More conveniently the MySQL credentials can be provided via environment variables. Use the following environment variables:
37+
* MYSQL_HOST: Host address for the database
38+
* MYSQL_DB: Database Name
39+
* MYSQL_USER: MySQL User
40+
* MYSQL_PASS: MySQL Password
41+
42+
Currently we have two tables:
43+
* apikeys: Contains the apikeys required to perform authorized API request
44+
* entries: Stores the user entries for the Clock of Change
45+
46+
For more information about the tables, see the SQL dump of the tables at `documentation/tables.sql` .
3547

3648
**MAILER**
3749

3850
The code related to the mail system can be found in the file `core/mailer.js`.
3951
For the mailer to work the smtp credentials need to be changed in this file as well.
4052
Then the mailer will work and use the mail templates from `mails/entry/`
4153

54+
More conveniently the Mailer credentials can be provided via environment variables. Use the following environment variables:
55+
* MAIL_HOST: Host address for the mailer
56+
* MAIL_PORT: Port number for the mailer
57+
* MAIL_USER: Mailer User
58+
* MAIL_PASS: Mailer Password
59+
60+
61+
To debug and preview the emails, we use [MailHog](https://github.com/mailhog/MailHog).
62+
When installing the Clock of Change without Docker, you have to install MailHog manually (see link for details).
63+
Then set the host address of MailHog in the Clock of Change API and use `1025` as the port number.
64+
Assuming MailHog is running on localhost, you can then debug the mails under [http://localhost:8025/](http://localhost:8025/).
4265

4366
## Installation
4467

4568
**PREREQUESITES**
4669

47-
Before starting the installation you need to make sure you have the following tools installed:
48-
* Git: You need to have Git installed. You can check this in the console with `git --help`. For installation instructions visit https://git-scm.com/
49-
* Node.js: You need to have Node.js installed. You can check this in the console with `node -v`. For installation instructions visit https://nodejs.org/en/
50-
* Npm: You need to have npm installed. You can check this in the console with `npm -v`. For installation instructions head to https://www.npmjs.com/get-npm
70+
Before starting the installation you need to make sure you have a recent version of [Git](https://git-scm.com/), [Nodejs](https://nodejs.org/en/) and [Npm](https://www.npmjs.com/get-npm) installed.
71+
E.g. we have the following versions:
72+
```
73+
$ git --version
74+
git version 2.14.2.windows.1
75+
$ node --version
76+
v10.15.0
77+
$ npm --version
78+
4.6.0
79+
80+
Git: 2.14.2
81+
Node: 10.15.0
82+
Npm: 4.6.0
83+
OS: Windows 10
84+
```
5185

5286
**INSTALLATION**
5387

0 commit comments

Comments
 (0)