-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (22 loc) · 870 Bytes
/
app.js
File metadata and controls
31 lines (22 loc) · 870 Bytes
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
var express = require('express');
var app = express();
var kafka = require('kafka-node');
let pushNotifications = require('./src/handlers/pushnotifications');
const Consumer = kafka.Consumer;
const client = new kafka.KafkaClient("localhost:2181");
//Handle push notifications
const consumer = new Consumer(client, [ { topic: 'test', partition: 0 } ], { autoCommit: true });
consumer.on('message', function (message) {
pushNotifications.handlePushTokens(message.value);
});
const indexRouter = require('./src/routes/index');
const tokenRouter = require('./src/routes/tokens');
const PORT_NUMBER = 3000; // port on which you want to run your server on
app.use(express.json());
// Routes
app.use('/', indexRouter);
app.use('/token', tokenRouter);
app.listen(PORT_NUMBER, () => {
console.log('Server Online on Port' + PORT_NUMBER);
});
module.exports = app;