forked from igorfritzsch/pubsub-rest-websocket-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (25 loc) · 974 Bytes
/
app.js
File metadata and controls
35 lines (25 loc) · 974 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
32
33
34
35
/**
* Module dependencies.
*/
var express = require('express')
, pubsub = require('./lib/pubsub.js')
, rest = require('./lib/rest.js')
, ws = require('./lib/ws.js');
var app = express();
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.favicon());
app.use('/style', express.static(__dirname + '/public/style'));
app.get('/', rest.index);
app.get('/topics', rest.topic); //List all topics ONLY RabbitMQ
app.post(/^\/topics\/([A-Za-z0-9\-\_\%\/]*[A-Za-z0-9\-\_])$/, rest.topic_subscribe);
app.put(/^\/topics\/([A-Za-z0-9\-\_\%\/]*[A-Za-z0-9\-\_])\/data$/, rest.topic_publish);
app.get(/^\/topics\/([A-Za-z0-9\-\_\%\/]*[A-Za-z0-9\-\_])\/data$/, rest.topic_message_get);
app.get(/^\/topics\/([A-Za-z0-9\-\_\%\/]*[A-Za-z0-9\-\_])$/, rest.topic_get);
//Connect to Broker
pubsub.connect('localhost', 61613);
//Start REST interface
app.listen(3000);
//Start WebSocket interface
ws.listen(8181);