A RAIN application has two major configuration points: the server configuration and the component level configuration.
Warning
The RAIN server has a set of configuration files that are located in a configuration folder. These files have to be in JSON format. When the RAIN server starts it reads all the files with the .conf extension from the configuration folder which is determined in the following order:
- if the RAIN_CONF environment variable is set, this value is used
- if the dir parameter of the raind process is set, the location is <dir>/conf
- the default configuration that is <project-root>/conf
If no configuration files are found or the format is invalid then the server won’t start.
The server configuration file has required and optional parameters described below. The required fields are formatted with bold.
Warning
The “cookieSecure” option should be used only when the requests are encrypted / using https protocol, otherwise the session cookie won’t be created. If you are using HAProxy in front of the NodeJS servers, adding this line for the secured connections avoids the problem: reqadd x-forwarded-proto:\ https.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | {
"server": {
"port": 1337,
"timeoutForRequests" : 3,
"components": ["./components"]
},
"websocket": {
"idleTime": 5,
"disconnectIdle": true,
"disconnectIdleOnMaxConn": 2,
"idleCheckInterval": 5
},
"staticFiles": {
"maxAge": 3600,
"folders": {
"/": "./public",
"/doc": "doc/build/html"
}
},
"defaultLanguage": "en_US",
"language": "en_US",
"enableClientLogging": false,
"enableMinification": false,
"logger": {
"level": "debug",
"appenders": [{
"type": "console",
"layout": {
"type": "pattern",
"params": {
"pattern": "%logger - %source - [%level] %date: %message %stacktrace"
}
},
"params": {
"debug": {
"foreground": "green"
},
"info": {
"foreground": "cyan"
},
"warn": {
"foreground": "yellow"
},
"error": {
"foreground": "red"
},
"fatal": {
"foreground": "black",
"background": "red"
}
}
}]
},
"languages": [
{"key": "en_US", "text": "English"},
{"key": "de_DE", "text": "Deutsch"},
{"key": "ro_RO", "text": "Română"},
{"key": "ar_SA", "text": "عربي"}
],
"errorComponent": {
"id": "error",
"version": "1.0"
},
"loadingComponent": {
"id": "placeholder",
"version": "1.0",
"viewId": "index",
"timeout": 500
},
"loginComponent": {
"id": "user",
"version": "1.0",
"viewId": "login"
},
"mainComponent": {
"id": "sprint_example_list",
"version": "1.0",
"viewId": "index"
},
"session": {
"store": "./configuration/custom_session_store"
},
"identity": {
"provider": "./configuration/custom_identity_provider"
},
"pageTitle": "RAIN component",
"bootstrap": {
"customHead": false,
"headFile": "./resources/custom_bootstrap.html",
"metas": [
"<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>"
],
"links": [
"<link rel='stylesheet' type='text/css' href='/globalComponent/resources/global.css'>"
],
"scripts": [
"<script type=\"text/javascript\" src=\"/globalComponent/js/util.js\"></script>"
],
"footerScripts": {
"external": [
"<script type=\"text/javascript\" src=\"/globalComponent/js/analytics.js\"></script>"
],
"inline": [
"./resources/user_analytics.html"
]
}
}
}
|
The inline scripts can look like this:
<script type="text/javascript" src="/globalComponent/js/another_script.js"></script>
<script type="text/javascript">//<![CDATA[
var page = '{{component.id}}/{{path}}';
{{#if isAuthenticated}}
var username = '{{user.username}}';
{{/if}}
//]]></script>
Please read Component configuration for more information.
The sensitive information configuration file must be placed in the conf folder.
1 2 3 4 5 6 | {
"cookieSecret": "custom secret",
"custom_sensitivekey": "custom sensitive value"
}
|
The only required parameter is the “cookieSecret”
The rain server can support configuration for individual domains. It is advisable that you set this configuration in another <filename>.conf in your conf folder. For example “language.conf”.
A valid example of this configuration must look like this:
1 2 3 4 5 6 7 8 9 10 11 12 | {
"tlds": {
"net": {
"defaultLanguage": "en_US",
"supportedLanguages": ["en_US", "ro_RO", "en_UK"]
},
"com": {
"defaultLanguage": "en_US",
"supportedLanguages": ["en_US", "ro_RO", "en_UK"]
}
}
}
|
As you can see in this example the first key is the domain than you have a defaultLanguage and an array of supportedLanguages. Both of this parameters defaultLanguage and supportedLanguages are mandatory.
The userLanguage is set from the start depending on the browser accepted-language if it’s accepted or the defaultLanguage.
All the text for the selectLanguage menu must be set in the server.conf at the languages key.