diff --git a/bot.js b/bot.js index 52abbed..12e5d2f 100644 --- a/bot.js +++ b/bot.js @@ -83,17 +83,22 @@ String.prototype.format = function() { }); }; +var api_base_url = "/api/v1"; + var notificationController = Broadcast.notifications({ storage: controller.storage, - token_secret: process.env.SECRET + token_secret: process.env.SECRET, + api_base_url: api_base_url }); var topicController = Broadcast.topics({ storage: controller.storage, - token_secret: process.env.SECRET + token_secret: process.env.SECRET, + api_base_url: api_base_url }); var messageController = Broadcast.messages({ storage: controller.storage, - token_secret: process.env.SECRET + token_secret: process.env.SECRET, + api_base_url: api_base_url }); var authController = Broadcast.auth({ storage: controller.storage, @@ -101,7 +106,8 @@ var authController = Broadcast.auth({ client_secret: process.env.CLIENT_SECRET, redirect_uri: process.env.REDIRECT_URI, allowed_admin: process.env.ALLOWED_ADMIN, - token_secret: process.env.SECRET + token_secret: process.env.SECRET, + api_base_url: api_base_url }); diff --git a/dist/index.html b/dist/index.html deleted file mode 100644 index 6769dd6..0000000 --- a/dist/index.html +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/lib/.DS_Store b/lib/.DS_Store deleted file mode 100644 index 732dc70..0000000 Binary files a/lib/.DS_Store and /dev/null differ diff --git a/lib/auth.js b/lib/auth.js index d656b57..a940c61 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -5,9 +5,10 @@ function Auth(configuration) { var request = require('request'); var jwt = require('jsonwebtoken'); + var base_url = controller.config.api_base_url; controller.createAuthEndpoints = function(webserver, bot, cb) { - webserver.get('/auth/token', function(req, res) { + webserver.get(base_url + '/auth/token', function(req, res) { var body = { grant_type: "authorization_code", diff --git a/lib/messages.js b/lib/messages.js index dd88245..583b300 100644 --- a/lib/messages.js +++ b/lib/messages.js @@ -4,9 +4,10 @@ function Messages(configuration) { }; var jwt = require('jsonwebtoken'); + var base_url = controller.config.api_base_url; controller.createMessageEndpoints = function(webserver, bot, cb) { - webserver.get('/messages', function(req, res) { + webserver.get(base_url + '/messages', function(req, res) { var token = req.headers['x-access-token']; jwt.verify(token, controller.config.token_secret, function(err, decoded) { @@ -31,7 +32,7 @@ function Messages(configuration) { }); - webserver.get('/messages/:message/status', function(req, res) { + webserver.get(base_url + '/messages/:message/status', function(req, res) { var token = req.headers['x-access-token']; jwt.verify(token, controller.config.token_secret, function(err, decoded) { diff --git a/lib/notifications.js b/lib/notifications.js index aa492a9..84f251a 100644 --- a/lib/notifications.js +++ b/lib/notifications.js @@ -4,11 +4,12 @@ function Notifications(configuration) { }; var jwt = require('jsonwebtoken'); + var base_url = controller.config.api_base_url; controller.createNotificationEndpoints = function(webserver, bot, cb) { const uuidv4 = require('uuid/v4'); - webserver.post('/notifications', function(req, res) { + webserver.post(base_url + '/notifications', function(req, res) { var token = req.headers['x-access-token']; jwt.verify(token, controller.config.token_secret, function(err, decoded) { diff --git a/lib/topics.js b/lib/topics.js index 26ca57b..76f01de 100644 --- a/lib/topics.js +++ b/lib/topics.js @@ -4,9 +4,10 @@ function Topics(configuration) { }; var jwt = require('jsonwebtoken'); + var base_url = controller.config.api_base_url; controller.createTopicEndpoints = function(webserver, bot, cb) { - webserver.get('/topics', function(req, res) { + webserver.get(base_url + '/topics', function(req, res) { var token = req.headers['x-access-token']; jwt.verify(token, controller.config.token_secret, function(err, decoded) { @@ -28,7 +29,7 @@ function Topics(configuration) { }); - webserver.post('/topics', function(req, res) { + webserver.post(base_url + '/topics', function(req, res) { var token = req.headers['x-access-token']; jwt.verify(token, controller.config.token_secret, function(err, decoded) { @@ -42,7 +43,7 @@ function Topics(configuration) { }); }); - webserver.delete('/topics/:topic', function(req, res) { + webserver.delete(base_url + '/topics/:topic', function(req, res) { var token = req.headers['x-access-token']; jwt.verify(token, controller.config.token_secret, function(err, decoded) { @@ -57,7 +58,7 @@ function Topics(configuration) { }); - webserver.get('/topics/:topic', function(req, res) { + webserver.get(base_url + '/topics/:topic', function(req, res) { var token = req.headers['x-access-token']; jwt.verify(token, controller.config.token_secret, function(err, decoded) {