Commit 36ac6b46 by Chavee Issariyapat

rename file, change debug config, remove setting env to development in code

parent 1c99fce2
.DS_Store
node_modules/
config/*.json
......@@ -6,11 +6,6 @@ var LRU = require("lru-cache"),
maxAge: 1000 * 60 * 5
});
// for testing
// function authCheck(client_id, username, topic, callback) {
// callback(true);
// }
module.exports = function (options = {}) {
return function (req, res, next) {
......@@ -43,8 +38,7 @@ module.exports = function (options = {}) {
var output = {};
GGID.getGroupID(req.body.username, req.body.client_id, function(group) {
var _ftopic = require('./utils/getTopic').rewriteTopic(topic, 'pub', group, req.body.client_id, output); // get topic where concat with groupID
var _ftopic = require('./utils/router').rewriteTopic(topic, 'pub', group, req.body.client_id, output); // get topic where concat with groupID
response = {
'result': 'ok',
'modifiers': {
......@@ -72,4 +66,4 @@ module.exports = function (options = {}) {
next();
}
}
}
\ No newline at end of file
}
......@@ -38,7 +38,7 @@ module.exports = function (options = {}) {
GGID.getGroupID(req.body.username, req.body.client_id, function(group) {
console.log(group);
var _ftopic = require('./utils/getTopic').rewriteTopic(topic, 'sub', group, req.body.client_id) // get topic where concat with groupID
var _ftopic = require('./utils/router').rewriteTopic(topic, 'sub', group, req.body.client_id) // get topic where concat with groupID
var _topic = [{ // setTopic for response
'topic': _ftopic,
'qos': 0
......
{
"authserv_host" : "AUTH_SERVICE_HOST",
"authserv_port" : "AUTH_SERVICE_PORT",
"authserv_host" : "AUTH_SERVICE_HOST",
"authserv_port" : "AUTH_SERVICE_PORT",
"device_registry_host" : "DEVICE_REGISTRY_HOST",
"device_registry_port" : "DEVICE_REGISTRY_PORT"
"device_registry_host" : "DEVICE_REGISTRY_HOST",
"device_registry_port" : "DEVICE_REGISTRY_PORT",
"auth_on_register_debug" : "AUTH_ON_REGISTER_DEBUG",
"auth_on_publish_debug" : "AUTH_ON_PUBLISH_DEBUG",
"auth_on_subscribe_debug" : "AUTH_ON_SUBSCRIBE_DEBUG",
"on_publish_debug" : "ON_PUBLISH_DEBUG",
"on_deliver_debug" : "ON_DELIVER_DEBUG",
"on_unsubscribe_debug" : "ON_UNSUBSCRIBE_DEBUG"
}
......@@ -3,7 +3,13 @@
"authserv_port" : 31081,
"pubca": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0oW2b1az7MLTRBQojy8e\nYTmVUcbrHBykyMZCkwt4OdL/4zD6jhOmE9JMr3NfRxEJ2BVj7gasEH2h/mpNRtSK\nHjKsgmFWt22QR/TNwNu7AHUiu+7pxyeOz6IDW9bzrptwwwvFz8wc0oKah6fs0cNY\n/Ln5QwY5CWpGJmHF5BOFE5R9PjC3bY2roKwDbKiw4Kx1rbRxwbSzvFGtBMVyK0Rv\nJpWEN6wTEesAI/bLkPth712zfY/PXFi9Vei/gcLxptceISj/o+PUZm4F6u+rHGGt\nOlcBI8lKiCBO8bggmGgpGCZ1fomj5pOPfInl/6Nn4X0gk/4s0MB7zuhBv45zxF8J\ntbzqQ9TVPdUewMtR5UWoPMGiGt6ZOYRAAmGYSWCsa7hD3plcg0NXYXVuLinyxmgd\nKUv0JmmDqWdkNme9W6m42Jb/zEACcneIIVgUeDkadYaJSjY05d2gn/Vn24f0hqp2\nSQ41fYBxw8eKUJLBNo2c9l+Vz7w/dln4cqI/hatXqOVvLml3CKBGwT9hFjufVTpr\nX5WgDzAxGAl0kO0IucInL/XROezsVcxhyJ2dp44KPOoSIUW8dFz7HNq4t9ENzcPV\nvYfvyS0l00p+ivaqT9iV53Ash6f+tHOR5arTNsuM3DHTi3Fi6qIhXSW5qGUl401c\nzSaVroFHIeQI0ZcTxzAOvS0CAwEAAQ==\n-----END PUBLIC KEY-----",
"device_registry_host" : "alpha.nexpie.io",
// "device_registry_host" : "127.0.0.1",
"device_registry_port" : 8080
"device_registry_host" : "127.0.0.1",
"device_registry_port" : 8990,
"auth_on_register_debug" : true,
"auth_on_publish_debug" : true,
"auth_on_subscribe_debug" : true,
"on_publish_debug" : true,
"on_deliver_debug" : true,
"on_unsubscribe_debug" : true
}
process.env["NODE_ENV"] = "development";
process.env["NODE_CONFIG_DIR"] = __dirname + "/config/";
var auth_on_register_debug = process.env["AUTH_ON_REGISTER_DEBUG"] || false;
var auth_on_publish_debug = process.env["AUTH_ON_PUBLISH_DEBUG"] || true;
var auth_on_subscribe_debug = process.env["AUTH_ON_SUBSCRIBE_DEBUG"] || true;
var on_publish_debug = process.env["ON_PUBLISH_DEBUG"] || true;
var on_deliver_debug = process.env["ON_DELIVER_DEBUG"] || true;
var on_unsubscribe_debug = process.env["ON_UNSUBSCRIBE_DEBUG"] || true;
var config = require('config');
var auth_on_register_debug = config.get('auth_on_register_debug');
var auth_on_publish_debug = config.get('auth_on_publish_debug');
var auth_on_subscribe_debug = config.get('auth_on_subscribe_debug');
var on_publish_debug = config.get('on_publish_debug');
var on_deliver_debug = config.get('on_deliver_debug');
var on_unsubscribe_debug = config.get('on_unsubscribe_debug');
var restify = require('restify');
var auth_on_register = require('./auth_on_register')({ debug: auth_on_register_debug });
......
......@@ -21,4 +21,4 @@ module.exports = function(options = {}) {
var topic = topics.split('/!')[1]
return topics.split('/!')[0] + topic.substring(topic.indexOf('/'), topic.length)
}
}
\ No newline at end of file
}
......@@ -18,10 +18,10 @@ module.exports = function(options = {}) {
}
else {
var GGID = require('./utils/getGroupID');
GGID.getGroupID(token, client_id, function(group) {
if (group) {
var _ftopic = require('./utils/getTopic').rewriteTopic(topic, 'unsub', group, client_id)
var _ftopic = require('./utils/router').rewriteTopic(topic, 'unsub', group, client_id)
response = {
"result": "ok",
"topics": [_ftopic]
......@@ -39,4 +39,4 @@ module.exports = function(options = {}) {
});
}
}
}
\ No newline at end of file
}
var assert = require('assert')
var getTopic = require('../utils/getTopic').getTopic
var getTopic = require('../utils/router').rewriteTopic
describe('GetTopic', () => {
describe('realtime msg', () => {
......@@ -49,4 +49,4 @@ describe('GetTopic', () => {
})
})
})
})
\ No newline at end of file
})
......@@ -2,9 +2,6 @@ var modify = require('./modify');
function rewriteTopic(topic, op, groupid, clientid, output) {
var chunk = topic.split('/');
console.log(groupid);
switch (chunk[0]) {
case '@msg' :
return modify.insertWordIntoTopic(topic, '!'+groupid, 1);
......@@ -44,4 +41,4 @@ console.log(groupid);
}
}
module.exports.rewriteTopic = rewriteTopic
\ No newline at end of file
module.exports.rewriteTopic = rewriteTopic
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment