-
Notifications
You must be signed in to change notification settings - Fork 1
/
notification.js
executable file
·44 lines (36 loc) · 1 KB
/
notification.js
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
var handler = require('./handlers')
var notificationHandler = new handler()
var authentication = require('./authentication')
var notification = {}
notification.sendNotification = (request, response) => {
authentication.authenticate(request.body, authCb)
function authCb(err, res) {
if (err) {
response.send({
status: err.status,
message: 'authentication failure'
})
return
}
notificationHandler.send({
body: request.body,
key: res.key
}, function(_err, _res) {
if (_err) {
response.send(_err)
} else {
response.send(_res)
}
})
}
}
notification.register = (request, response) => {
notificationHandler.registerClient(request.body, function(_err, _res) {
if (_err) {
response.send(_err)
} else {
response.send(_res)
}
})
}
module.exports = notification