Skip to content

Commit 49b51e4

Browse files
committed
Refactor server with Sequelize ORM, refactor server configs, now will show note status (created or updated) and support docs (note alias)
1 parent e613aeb commit 49b51e4

35 files changed

Lines changed: 1879 additions & 2122 deletions

README.md

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ Still in early stage, feel free to fork or contribute to this.
99

1010
Thanks for your using! :smile:
1111

12+
[docker-hackmd](https://github.com/hackmdio/docker-hackmd)
13+
---
14+
Before you going too far, here is the great docker repo for HackMD.
15+
With docker, you can deploy a server in minutes without any hardtime.
16+
17+
[migration-to-0.4.0](https://github.com/hackmdio/migration-to-0.4.0)
18+
---
19+
We've dropped MongoDB after version 0.4.0.
20+
So here is the migration tool for you to transfer old DB data to new DB.
21+
This tool is also used for official service.
22+
1223
Browsers Requirement
1324
---
1425
- Chrome >= 45, Chrome for Android >= 47
@@ -20,33 +31,24 @@ Browsers Requirement
2031

2132
Prerequisite
2233
---
23-
- Node.js 4.x or up (test up to 5.8.0)
24-
- PostgreSQL 9.3.x or 9.4.x
25-
- MongoDB 3.0.x
34+
- Node.js 4.x or up (test up to 5.10.1)
35+
- Database (PostgreSQL, MySQL, MariaDB, SQLite, MSSQL)
2636
- npm and bower
2737

2838
Get started
2939
---
3040
1. Download a release and unzip or clone into a directory
3141
2. Enter the directory and type `npm install && bower install`, will install all the dependencies
32-
3. Install PostgreSQL and MongoDB (yes, currently we need both)
33-
4. Import database schema, see more on below
34-
5. Setup the configs, see more on below
35-
6. Setup environment variables, which will overwrite the configs
36-
7. Run the server as you like (node, forever, pm2)
37-
38-
Import database schema
39-
---
40-
The notes are store in PostgreSQL, the schema is in the `hackmd_schema.sql`
41-
To import the sql file in PostgreSQL, see http://www.postgresql.org/docs/9.4/static/backup-dump.html
42-
43-
The users, temps and sessions are store in MongoDB, which don't need schema, so just make sure you have the correct connection string.
42+
3. Setup the configs, see more on below
43+
4. Setup environment variables, which will overwrite the configs
44+
5. Run the server as you like (node, forever, pm2)
4445

4546
Structure
4647
---
4748
```
4849
hackmd/
4950
├── tmp/ --- temporary files
51+
├── docs/ --- document files
5052
├── lib/ --- server libraries
5153
└── public/ --- client files
5254
├── css/ --- css styles
@@ -57,63 +59,58 @@ hackmd/
5759

5860
Configuration files
5961
---
60-
There are some config you need to change in below files
62+
There are some configs you need to change in below files
6163
```
62-
./config.js --- for server settings
63-
./public/js/index.js --- for client settings
64+
./config.json --- for server settings
6465
./public/js/common.js --- for client settings
6566
```
6667

67-
Client-side index.js settings
68+
Client settings `common.js`
6869
---
6970
| variables | example values | description |
7071
| --------- | ------ | ----------- |
7172
| debug | `true` or `false` | set debug mode, show more logs |
72-
| version | `0.3.2` | current version, must match same var in server side `config.js` |
73-
74-
Client-side common.js settings
75-
---
76-
| variables | example values | description |
77-
| --------- | ------ | ----------- |
7873
| domain | `localhost` | domain name |
7974
| urlpath | `hackmd` | sub url path, like: `www.example.com/<urlpath>` |
8075

81-
Environment variables
76+
Environment variables (will overwrite other server configs)
8277
---
8378
| variables | example values | description |
8479
| --------- | ------ | ----------- |
85-
| NODE_ENV | `production` or `development` | show current environment status |
86-
| DATABASE_URL | `postgresql://user:pass@host:port/hackmd` | PostgreSQL connection string |
87-
| MONGOLAB_URI | `mongodb://user:pass@host:port/hackmd` | MongoDB connection string |
88-
| PORT | `80` | web port |
89-
| SSLPORT | `443` | ssl web port |
90-
| DOMAIN | `localhost` | domain name |
91-
| URL_PATH | `hackmd` | sub url path, like `www.example.com/<URL_PATH>` |
92-
93-
Server-side config.js settings
80+
| NODE_ENV | `production` or `development` | set current environment (will apply correspond settings in the `config.json`) |
81+
| PORT | `80` | web app port |
82+
| DEBUG | `true` or `false` | set debug mode, show more logs |
83+
84+
Server settings `config.json`
9485
---
9586
| variables | example values | description |
9687
| --------- | ------ | ----------- |
97-
| testport | `3000` | debug web port, fallback to this when not set in environment |
98-
| testsslport | `3001` | debug web ssl port, fallback to this when not set in environment |
99-
| usessl | `true` or `false` | set to use ssl |
100-
| protocolusessl | `true` or `false` | set to use ssl protocol |
101-
| urladdport | `true` or `false` | set to add port on oauth callback url |
10288
| debug | `true` or `false` | set debug mode, show more logs |
103-
| usecdn | `true` or `false` | set to use CDN resources or not |
104-
| version | `0.3.2` | currnet version, must match same var in client side `index.js` |
89+
| domain | `localhost` | domain name |
90+
| urlpath | `hackmd` | sub url path, like `www.example.com/<urlpath>` |
91+
| port | `80` | web app port |
10592
| alloworigin | `['localhost']` | domain name whitelist |
106-
| sslkeypath | `./cert/client.key` | ssl key path |
107-
| sslcertpath | `./cert/hackmd_io.crt` | ssl cert path |
108-
| sslcapath | `['./cert/COMODORSAAddTrustCA.crt']` | ssl ca chain |
109-
| dhparampath | `./cert/dhparam.pem` | ssl dhparam path |
110-
| tmppath | `./tmp/` | temp file path |
111-
| postgresqlstring | `postgresql://user:pass@host:port/hackmd` | PostgreSQL connection string, fallback to this when not set in environment |
112-
| mongodbstring | `mongodb://user:pass@host:port/hackmd` | MongoDB connection string, fallback to this when not set in environment |
93+
| usessl | `true` or `false` | set to use ssl server (if true will auto turn on `protocolusessl`) |
94+
| protocolusessl | `true` or `false` | set to use ssl protocol for resources path |
95+
| urladdport | `true` or `false` | set to add port on callback url (port 80 or 443 won't applied) |
96+
| usecdn | `true` or `false` | set to use CDN resources or not |
97+
| db | `{ "dialect": "sqlite", "storage": "./db.hackmd.sqlite" }` | set the db configs, [see more here](http://sequelize.readthedocs.org/en/latest/api/sequelize/) |
98+
| sslkeypath | `./cert/client.key` | ssl key path (only need when you set usessl) |
99+
| sslcertpath | `./cert/hackmd_io.crt` | ssl cert path (only need when you set usessl) |
100+
| sslcapath | `['./cert/COMODORSAAddTrustCA.crt']` | ssl ca chain (only need when you set usessl) |
101+
| dhparampath | `./cert/dhparam.pem` | ssl dhparam path (only need when you set usessl) |
102+
| tmppath | `./tmp/` | temp directory path |
103+
| defaultnotepath | `./public/default.md` | default note file path |
104+
| docspath | `./public/docs` | docs directory path |
105+
| indexpath | `./public/views/index.ejs` | index template file path |
106+
| hackmdpath | `./public/views/hackmd.ejs` | hackmd template file path |
107+
| errorpath | `./public/views/error.ejs` | error template file path |
108+
| prettypath | `./public/views/pretty.ejs` | pretty template file path |
109+
| slidepath | `./public/views/slide.hbs` | slide template file path |
113110
| sessionname | `connect.sid` | cookie session name |
114111
| sessionsecret | `secret` | cookie session secret |
115112
| sessionlife | `14 * 24 * 60 * 60 * 1000` | cookie session life |
116-
| sessiontouch | `1 * 3600` | cookie session touch |
113+
| staticcachetime | `1 * 24 * 60 * 60 * 1000` | static file cache time |
117114
| heartbeatinterval | `5000` | socket.io heartbeat interval |
118115
| heartbeattimeout | `10000` | socket.io heartbeat timeout |
119116
| documentmaxlength | `100000` | note max length |
@@ -122,8 +119,8 @@ Third-party integration api key settings
122119
---
123120
| service | file path | description |
124121
| ------- | --------- | ----------- |
125-
| facebook, twitter, github, dropbox | `config.js` | for signin |
126-
| imgur | `config.js` | for image upload |
122+
| facebook, twitter, github, dropbox | `config.json` | for signin |
123+
| imgur | `config.json` | for image upload |
127124
| dropbox | `public/views/foot.ejs` | for chooser and saver |
128125
| google drive | `public/js/common.js` | for export and import |
129126

0 commit comments

Comments
 (0)