-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
79 lines (62 loc) · 2.93 KB
/
index.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'use strict';
const path = require('path');
const pwd = path.join(__dirname, '..', '/.env');
require('dotenv').config({path: pwd});
//const util = require('ms-utilities');
const seneca = require('seneca')({
actcache: {
active: true,
size: 257
}
});
const database = require('./lib/database');
const nearby = require('./lib/nearby');
const schoenhier = require('./lib/schoenhier');
const location = require('./lib/location');
const newLoc = require('./lib/newLoc');
// select desired transport method
//const transportMethod = process.env['SENECA_TRANSPORT_METHOD'] || 'rabbitmq';
const patternPin = 'role:location';
// init database
database.connect().then(() => {
// init seneca and expose functions
seneca
//.use(transportMethod + '-transport')
//.client({type: 'tcp', port: 7010, host: 'localhost', pin: 'role:reporter'})
.add(patternPin + ',cmd:nearby', nearby.getLocationsNearby)
.add(patternPin + ',cmd:addschoenhier', schoenhier.addSchoenhier)
.add(patternPin + ',cmd:nearbyschoenhier', schoenhier.getSchoenhiersNearby)
.add(patternPin + ',cmd:locationById', location.getLocationById)
.add(patternPin + ',cmd:addnewlocation', newLoc.addNewLocation)
.add(patternPin + ',cmd:deletelocation', location.deleteLocation)
.add(patternPin + ',cmd:locationbyname', location.getLocationByName)
.add(patternPin + ',cmd:getlocbyuserid', location.getLocationsOfUser)
.add(patternPin + ',cmd:toggleFavor', location.toggleFavorLocation)
.add(patternPin + ',cmd:favor', location.favorLocation)
.add(patternPin + ',cmd:unfavor', location.unfavorLocation)
// add impressions
.add(patternPin + ',cmd:addimpression,type:text', location.addTextImpression)
.add(patternPin + ',cmd:addimpression,type:image', location.addImageImpression)
.add(patternPin + ',cmd:addimpression,type:video', location.addVideoImpression)
.add(patternPin + ',cmd:addimpression,type:audio', location.addAudioImpression)
.add(patternPin + ',cmd:getlocationstream', location.getLocationStreamById)
.add(patternPin + ',cmd:getfavoritelocationbyuserid', location.getFavoriteLocationbyUserId)
.add(patternPin + ',cmd:count,entity:location,by:userId', location.getCountForLocationsByUserId)
//.act({
// role: 'location',
// cmd: 'addimpression',
// type: 'text',
// data: {
// location_id: '567800aafb3dcfc1d9f85436',
// user_id: '56786fe35227864133663976',
// message: 'Hallo, tolle location das da'
//
// }
//}, (err, data) => {
// console.log(err || data);
//})
//.listen({type: transportMethod, pin: patternPin});
//.listen({type: 'tcp', port: 7001, pin: patternPin})
.use('mesh',{auto:true, pin:patternPin});
// .wrap(patternPin, util.reporter.report);
});