Compare View
Commits (2)
Changes
Showing 2 changed files Inline Diff
package.json
1 | { | 1 | { |
2 | "name": "komodo-sdk", | 2 | "name": "komodo-sdk", |
3 | "version": "1.26.2", | 3 | "version": "1.26.3", |
4 | "description": "SDK for Komodo", | 4 | "description": "SDK for Komodo", |
5 | "main": "index.js", | 5 | "main": "index.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "test": "mocha", | 7 | "test": "mocha", |
8 | "postversion": "git push && git push --tags" | 8 | "postversion": "git push && git push --tags" |
9 | }, | 9 | }, |
10 | "repository": { | 10 | "repository": { |
11 | "type": "git", | 11 | "type": "git", |
12 | "url": "git@gitlab.kodesumber.com:komodo/komodo-sdk.git" | 12 | "url": "git@gitlab.kodesumber.com:komodo/komodo-sdk.git" |
13 | }, | 13 | }, |
14 | "keywords": [ | 14 | "keywords": [ |
15 | "ppob", | 15 | "ppob", |
16 | "payment", | 16 | "payment", |
17 | "komodo" | 17 | "komodo" |
18 | ], | 18 | ], |
19 | "author": "Adhidarma Hadiwinoto <gua@adhisimon.org>", | 19 | "author": "Adhidarma Hadiwinoto <gua@adhisimon.org>", |
20 | "license": "ISC", | 20 | "license": "ISC", |
21 | "dependencies": { | 21 | "dependencies": { |
22 | "basic-auth": "^2.0.0", | 22 | "basic-auth": "^2.0.0", |
23 | "body-parser": "^1.18.2", | 23 | "body-parser": "^1.18.2", |
24 | "dot-object": "^1.7.0", | 24 | "dot-object": "^1.7.0", |
25 | "express": "^4.16.3", | 25 | "express": "^4.16.3", |
26 | "express-session": "^1.15.6", | 26 | "express-session": "^1.15.6", |
27 | "json-query": "^2.2.2", | 27 | "json-query": "^2.2.2", |
28 | "lru-cache": "^4.1.1", | 28 | "lru-cache": "^4.1.1", |
29 | "macaddress": "^0.2.8", | 29 | "macaddress": "^0.2.8", |
30 | "moment": "^2.19.1", | 30 | "moment": "^2.19.1", |
31 | "node-machine-id": "^1.1.10", | 31 | "node-machine-id": "^1.1.10", |
32 | "node-natural-sort": "^0.8.6", | 32 | "node-natural-sort": "^0.8.6", |
33 | "numeral": "^2.0.6", | 33 | "numeral": "^2.0.6", |
34 | "nunjucks": "^3.0.1", | 34 | "nunjucks": "^3.0.1", |
35 | "redis": "^2.8.0", | 35 | "redis": "^2.8.0", |
36 | "request": "^2.81.0", | 36 | "request": "^2.81.0", |
37 | "sha1": "^1.1.1", | 37 | "sha1": "^1.1.1", |
38 | "simple-git": "^1.80.1", | 38 | "simple-git": "^1.80.1", |
39 | "strftime": "^0.10.0", | 39 | "strftime": "^0.10.0", |
40 | "uniqid": "^4.1.1", | 40 | "uniqid": "^4.1.1", |
41 | "uuid": "^3.1.0", | 41 | "uuid": "^3.1.0", |
42 | "winston": "^2.3.1", | 42 | "winston": "^2.3.1", |
43 | "winston-circular-buffer": "^1.0.0", | 43 | "winston-circular-buffer": "^1.0.0", |
44 | "winston-daily-rotate-file": "^1.4.6" | 44 | "winston-daily-rotate-file": "^1.4.6" |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 |
rc-from-msg.js
1 | "use strict"; | 1 | "use strict"; |
2 | 2 | ||
3 | function logOnDebug(msg) { | 3 | function logOnDebug(msg) { |
4 | if (process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG) { | 4 | if (process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG) { |
5 | console.log(msg); | 5 | console.log(msg); |
6 | } | 6 | } |
7 | } | 7 | } |
8 | 8 | ||
9 | function run(msg, rules) { | 9 | function run(msg, rules) { |
10 | if (typeof msg !== 'string') { | 10 | if (typeof msg !== 'string') { |
11 | logOnDebug('RC-FROM-MSG: invalid msg type === ' + typeof msg); | 11 | logOnDebug('RC-FROM-MSG: invalid msg type === ' + typeof msg); |
12 | return; | 12 | return; |
13 | } | 13 | } |
14 | if (!rules) { | 14 | if (!rules) { |
15 | logOnDebug('RC-FROM-MSG: invalid rules'); | 15 | logOnDebug('RC-FROM-MSG: invalid rules'); |
16 | return; | 16 | return; |
17 | } | 17 | } |
18 | if (!rules.length) { | 18 | if (!rules.length) { |
19 | logOnDebug('RC-FROM-MSG: rules is empty'); | 19 | logOnDebug('RC-FROM-MSG: rules is empty'); |
20 | return; | 20 | return; |
21 | } | 21 | } |
22 | 22 | ||
23 | const rules_count = rules.length; | 23 | const rules_count = rules.length; |
24 | for(let i = 0; i < rules_count; i++) { | 24 | for(let i = 0; i < rules_count; i++) { |
25 | const rule = rules[i]; | 25 | const rule = rules[i]; |
26 | 26 | ||
27 | logOnDebug('RC-FROM-MSG: checking with rule: ' + JSON.stringify(rule)); | 27 | logOnDebug('RC-FROM-MSG: checking with rule: ' + JSON.stringify(rule)); |
28 | const re = (typeof rule.flags === 'string') ? new RegExp(rule.pattern, rule.flags) : new RegExp(rule.pattern); | 28 | const re = (typeof rule.flags === 'string') ? new RegExp(rule.pattern, rule.flags) : new RegExp(rule.pattern); |
29 | if (msg.search(re) > 0) { | 29 | if (msg.search(re) > 0) { |
30 | logOnDebug('RC-FROM-MSG: match with rule: ' + JSON.stringify(rule)); | 30 | logOnDebug('RC-FROM-MSG: match with rule: ' + JSON.stringify(rule)); |
31 | return rule.rc || rule.result; | 31 | return rule.rc || rule.result; |
32 | } | 32 | } |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | module.exports = run; | 36 | module.exports = run; |
37 | 37 |