Skip to content

Commit f7148bf

Browse files
committed
Initial commit
1 parent 1d7390f commit f7148bf

19 files changed

Lines changed: 1459 additions & 0 deletions

File tree

‎LICENSE.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# LICENSE
2+
3+
Copyright © 2017 Bill & Melinda Gates Foundation
4+
5+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0
6+
(the "License") and you may not use these files except in compliance with the [License](http://www.apache.org/licenses/LICENSE-2.0). You may obtain a copy of the License at
7+
8+
[http://www.apache.org/licenses/LICENSE-2.0]()
9+
10+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the [License](http://www.apache.org/licenses/LICENSE-2.0).

‎app.js‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*****
2+
License
3+
--------------
4+
Copyright © 2017 Bill & Melinda Gates Foundation
5+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8+
Contributors
9+
--------------
10+
This is the official list of the Mojaloop project contributors for this file.
11+
Names of the original copyright holders (individuals or organizations)
12+
should be listed with a '*' in the first column. People who have
13+
contributed from an organization can be listed under the organization
14+
that actually holds the copyright for their contributions (see the
15+
Gates Foundation organization for an example). Those individuals should have
16+
their names indented and be marked with a '-'. Email address can be added
17+
optionally within square brackets <email>.
18+
* Gates Foundation
19+
- Name Surname <name.surname@gatesfoundation.com>
20+
* Valentin Genev <valentin.genev@modusbox.com>
21+
* Deon Botha <deon.botha@modusbox.com>
22+
--------------
23+
******/
24+
25+
'use strict'
26+
27+
const setup = require('./src/setup').setup
28+
29+
setup()

‎config/config.json‎

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"clearRepetitionTimerMs": 60000,
3+
"swaggerOptions": {
4+
"info": {
5+
"title": "Central notification system API Documentation",
6+
"description": "Api Documentation for central-notification"
7+
},
8+
"expanded": "full"
9+
},
10+
"mongo": {
11+
"url": "localhost:27017",
12+
"database": "mojaloop",
13+
"ruleCollection": "Rule",
14+
"netDebitCapPositionCollection": "NDCPosition",
15+
"actionCollection": "Actions",
16+
"eventCollection": "Events",
17+
"limitCollection": "Limits",
18+
"notificationEndpointCollection": "NotificationEndpoints"
19+
},
20+
"KAFKA": {
21+
"TOPIC_TEMPLATES": {
22+
"NOTIFICATION_TOPIC_TEMPLATE": {
23+
"TEMPLATE": "topic-notification-event",
24+
"REGEX": "topic-notification-event"
25+
},
26+
"GENERAL_TOPIC_TEMPLATE": {
27+
"TEMPLATE": "topic-{{functionality}}-{{action}}",
28+
"REGEX": "topic-(.*)-(.*)"
29+
}
30+
},
31+
"CONSUMER": {
32+
"NOTIFICATION": {
33+
"EVENT": {
34+
"config": {
35+
"options": {
36+
"mode": 2,
37+
"batchSize": 1,
38+
"recursiveTimeout": 100,
39+
"messageCharset": "utf8",
40+
"messageAsJSON": true,
41+
"sync": true,
42+
"consumeTimeout": 1000
43+
},
44+
"rdkafkaConf": {
45+
"client.id": "cep-con-notification-event",
46+
"group.id": "notifier",
47+
"metadata.broker.list": "localhost:9092",
48+
"socket.blocking.max.ms": 1,
49+
"fetch.wait.max.ms": 1,
50+
"fetch.error.backoff.ms": 1,
51+
"queue.buffering.max.ms": 1,
52+
"broker.version.fallback": "0.10.1.0",
53+
"api.version.request": true,
54+
"enable.auto.commit": false,
55+
"auto.commit.interval.ms": 200,
56+
"socket.keepalive.enable": true,
57+
"socket.max.fails": 1
58+
},
59+
"topicConf": {
60+
"auto.offset.reset": "earliest"
61+
}
62+
}
63+
}
64+
}
65+
},
66+
"PRODUCER": {
67+
"NOTIFICATION": {
68+
"EVENT": {
69+
"config": {
70+
"options": {
71+
"messageCharset": "utf8"
72+
},
73+
"rdkafkaConf": {
74+
"debug": "all",
75+
"metadata.broker.list": "localhost:9092",
76+
"client.id": "cep-prod-notification-event",
77+
"event_cb": true,
78+
"compression.codec": "none",
79+
"retry.backoff.ms": 100,
80+
"message.send.max.retries": 2,
81+
"socket.keepalive.enable": true,
82+
"queue.buffering.max.messages": 10000000,
83+
"batch.num.messages": 100,
84+
"dr_cb": true,
85+
"socket.blocking.max.ms": 1,
86+
"queue.buffering.max.ms": 1,
87+
"broker.version.fallback": "0.10.1.0",
88+
"api.version.request": true
89+
}
90+
}
91+
}
92+
}
93+
}
94+
},
95+
"emailSetting": {
96+
"mailOptions": {
97+
"service": "gmail",
98+
"auth": {
99+
"user": "",
100+
"pass": ""
101+
}
102+
},
103+
"smtpConfig": {
104+
"host": "smtp.gmail.com",
105+
"port": 587,
106+
"secureConnection": false,
107+
"tls": {
108+
"ciphers":"SSLv3"
109+
},
110+
111+
"auth": {
112+
"user": "modusboxnotifier@gmail.com",
113+
"pass": "m0dusb0xn0t1f13r"
114+
}
115+
},
116+
"smtpPoolConfig": {
117+
"pool": true,
118+
"host": "smtp.example.com",
119+
"port": 465,
120+
"secure": false,
121+
"auth": {
122+
"user": "userName",
123+
"pass": "passWord"
124+
}
125+
}
126+
}
127+
}

‎package.json‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "central-notification",
3+
"version": "0.0.1",
4+
"description": "email notifier to monitor the notificaion kafka topic and send emails.",
5+
"main": "index.js",
6+
"dependencies": {
7+
"@mojaloop/central-services-error-handling": "0.5.1",
8+
"@mojaloop/central-services-shared": "^3.7.1-snapshot",
9+
"json-rules-engine": "^2.3.0",
10+
"mustache": "^3.0.0",
11+
"nodemailer": "^4.6.8",
12+
"rxjs": "^6.3.3",
13+
"rxjs-compat": "^6.3.3",
14+
"uuid4": "^1.1.4"
15+
},
16+
"scripts": {
17+
"test": "echo \"Error: no test specified\" && exit 1"
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "git+https://github.com/vgenev/central-notification.git"
22+
},
23+
"author": "Valentin Genev",
24+
"license": "MIT",
25+
"bugs": {
26+
"url": "https://github.com/vgenev/central-notification/issues"
27+
},
28+
"homepage": "https://github.com/vgenev/central-notification#readme"
29+
}

‎src/lib/enum.js‎

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/*****
2+
* @file This registers all handlers for the central-ledger API
3+
License
4+
--------------
5+
Copyright © 2017 Bill & Melinda Gates Foundation
6+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
11+
12+
Contributors
13+
--------------
14+
This is the official list of the Mojaloop project contributors for this file.
15+
Names of the original copyright holders (individuals or organizations)
16+
should be listed with a '*' in the first column. People who have
17+
contributed from an organization can be listed under the organization
18+
that actually holds the copyright for their contributions (see the
19+
Gates Foundation organization for an example). Those individuals should have
20+
their names indented and be marked with a '-'. Email address can be added
21+
optionally within square brackets <email>.
22+
23+
* Gates Foundation
24+
- Name Surname <name.surname@gatesfoundation.com>
25+
26+
* Georgi Georgiev <lazola.lucas@modusbox.com>
27+
28+
--------------
29+
******/
30+
31+
'use strict'
32+
33+
/**
34+
* @module src/lib/enum.js
35+
*/
36+
37+
// Code specific (non-DB) enumerations sorted alphabetically
38+
const transferEventType = {
39+
PREPARE: 'prepare',
40+
POSITION: 'position',
41+
TRANSFER: 'transfer',
42+
FULFIL: 'fulfil',
43+
NOTIFICATION: 'notification',
44+
ADMIN: 'admin',
45+
GET: 'get'
46+
}
47+
48+
const notificationActionMap = {
49+
NET_DEBIT_CAP_BREACH_MAIL: 'sendEmail'
50+
}
51+
52+
const limitNotificationMap = {
53+
NET_DEBIT_CAP: 'NET_DEBIT_CAP_BREACH_MAIL'
54+
}
55+
56+
const transferEventAction = {
57+
PREPARE: 'prepare',
58+
PREPARE_DUPLICATE: 'prepare-duplicate',
59+
TRANSFER: 'transfer',
60+
COMMIT: 'commit',
61+
ABORT: 'abort',
62+
TIMEOUT_RECEIVED: 'timeout-received',
63+
TIMEOUT_RESERVED: 'timeout-reserved',
64+
REJECT: 'reject',
65+
FAIL: 'fail',
66+
EVENT: 'event',
67+
FULFIL: 'fulfil'
68+
}
69+
const adminTransferAction = {
70+
RECORD_FUNDS_IN: 'recordFundsIn',
71+
RECORD_FUNDS_OUT_PREPARE: 'recordFundsOutPrepare',
72+
RECORD_FUNDS_OUT_COMMIT: 'recordFundsOutCommit',
73+
RECORD_FUNDS_OUT_ABORT: 'recordFundsOutAbort'
74+
}
75+
const rejectionType = {
76+
EXPIRED: 'expired',
77+
CANCELLED: 'cancelled'
78+
}
79+
const transferEventStatus = {
80+
SUCCESS: 'success',
81+
FAILED: 'failed'
82+
}
83+
const headers = {
84+
FSPIOP: {
85+
SWITCH: 'central-switch'
86+
}
87+
}
88+
const topicMap = {
89+
position: {
90+
'commit': {
91+
functionality: transferEventType.POSITION,
92+
action: transferEventAction.FULFIL
93+
},
94+
'timeout-reserved': {
95+
functionality: transferEventType.POSITION,
96+
action: transferEventAction.ABORT
97+
},
98+
'reject': {
99+
functionality: transferEventType.POSITION,
100+
action: transferEventAction.ABORT
101+
}
102+
},
103+
notification: {
104+
'prepare': {
105+
functionality: transferEventType.NOTIFICATION,
106+
action: transferEventAction.EVENT
107+
},
108+
'prepare-duplicate': {
109+
functionality: transferEventType.NOTIFICATION,
110+
action: transferEventAction.EVENT
111+
},
112+
'commit': {
113+
functionality: transferEventType.NOTIFICATION,
114+
action: transferEventAction.EVENT
115+
},
116+
'abort': {
117+
functionality: transferEventType.NOTIFICATION,
118+
action: transferEventAction.EVENT
119+
},
120+
'timeout-received': {
121+
functionality: transferEventType.NOTIFICATION,
122+
action: transferEventAction.EVENT
123+
},
124+
'reject': {
125+
functionality: transferEventType.NOTIFICATION,
126+
action: transferEventAction.EVENT
127+
},
128+
'get': {
129+
functionality: transferEventType.NOTIFICATION,
130+
action: transferEventAction.EVENT
131+
}
132+
}
133+
}
134+
135+
module.exports = {
136+
transferEventType,
137+
transferEventAction,
138+
adminTransferAction,
139+
rejectionType,
140+
transferEventStatus,
141+
headers,
142+
topicMap,
143+
notificationActionMap,
144+
limitNotificationMap
145+
}

0 commit comments

Comments
 (0)