Merge pull request #1895 from gpazo/24672
[xtuple] / node-datasource / readme.md
1 # Datasource
2
3 > A Node.js web service designed for deployment in a cloud environment and one piece
4 > of the Postbooks cloud technology stack. Exposes both a REST and WebSocket API for
5 > clients, serves the client and authentication source, manages user authentication,
6 > communication with the postgres databases, session control and more.
7
8 All of the configuration options for the datasource are in the `config.js` file (modified by you) 
9 or in any other configuration file and specified by the `-c` flag from the command-line at command 
10 invocation. You will typically want to copy the sample_config.js file to config.js and 
11 update any fields that are specific to your implementation.
12
13 ```javascript
14 // from config.js
15 datasource: {
16   sessionTimeout: 15,
17   securePort: 443,
18   secureKeyFile: "./lib/private/key.pem",
19   secureCertFile: "./lib/private/cert.crt",
20   secureSaltFile: "./lib/private/salt.txt"
21 }
22 ```
23
24 The datasource now needs a private key and signed certificate 
25 to be able to provide SSL (_https_) encryption. It is beyond the scope of these instructions to direct on how 
26 to generate a self-signed certificate for development. Note that once these have been generated they, by 
27 convention, should be placed in the `lib/private` directory but can be placed anywhere in the project directory 
28 with their paths specified in the `config.js` file. 
29
30 The files that _need_ to be generated/modified as necessary are:
31 * `config.js` for configuring the datasource
32 * `lib/private/key.pem` (or other path/name as specified by you)
33 * `lib/private/cert.crt` (or other path/name as specified by you)
34 * `lib/private/salt.txt` (or other path/name as specified by you)
35
36 ### Hints
37
38 1. The [node-datasource](http://github.com/xtuple/node-datasource) uses port 80 and 443; if there is another web server running (e.g. apache) then it needs to be stopped and if this machine is one you would like to frequently run the datasource from you might consider removing apache from an automatic startup routine if it has one. Consult your operating system documentation for details on how to do this. Also note that these ports require elevated credentials to bind thus the `sudo` in the command for non-root users starting the service.