Repository navigation
Expand file tree
/
Copy pathconfig.js
More file actions
36 lines (27 loc) · 1.53 KB
/
Copy pathconfig.js
File metadata and controls
36 lines (27 loc) · 1.53 KB
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
module.exports = {
bus: process.env.BUS || "nats://localhost:4222",
/** Port to be running webserver on */
port: parseInt((process.env.PORT || 8080), 10),
/** The url to the api root, in order to display accurate urls */
apiRoot: process.env.API_ROOT || "{{host}}",
/** Project name in order to display the name in the header and title of the page */
projectName: process.env.PROJECT_NAME || "",
/**
* Words to be color coded in service endpoints. Uses the structure {cssClass}:{word},{word};{cssClass}:{word},{word};
* Note: It goes through this list in reverse order so any extension words should be latter; e.g. `create,created` = it will look for created first and then created.
*/
colorCodedWords: parseColorCodedWords(process.env.COLOR_CODED_WORDS ||
"GET:get,find;read;DELETE:delete,deleted,remove,removed,cancel,canceled,cancelled,decline,declined,unregister,unregistered;POST:create,created,post,posted,add,added,generate,generated,approve,approved,send,sent,resend,resent,set,validate,validated,verify,verified,authenticate,authenticated,decode,decode;PUT:put,update,updated,change,changed,reset;PUB:pub")
};
function parseColorCodedWords(string) {
const output = {};
const rules = string.split(";");
rules.forEach(rule => {
const indexOfColon = rule.indexOf(":");
const words = rule.substring(indexOfColon + 1).split(",");
words.forEach(word => {
output[word] = rule.substring(0, indexOfColon);
});
});
return output;
}