From b42ce9c6b8719c9526dd123717fe247e77f35695 Mon Sep 17 00:00:00 2001 From: Rafael Campos Date: Sat, 4 Nov 2017 19:14:55 -0600 Subject: [PATCH] Added /api/v1 to all API endpoints --- bot.js | 14 ++++++++++---- dist/index.html | 1 - lib/.DS_Store | Bin 6148 -> 0 bytes lib/auth.js | 3 ++- lib/messages.js | 5 +++-- lib/notifications.js | 3 ++- lib/topics.js | 9 +++++---- 7 files changed, 22 insertions(+), 13 deletions(-) delete mode 100644 dist/index.html delete mode 100644 lib/.DS_Store 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 732dc702da72e03d4b3182015a493451dcf56604..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyG{c!5S)bwMWRVb>0jUvtSEdzejrGo2oZurMCz;fE8yx|dB zjQKp1dk4I7f5+$N*}f-}0#ZN@fPW@ zo~Tg@NP)2e*STDH{ePhU(f^N0T1f#Za8U}_Y_(o3`ASt=Coku2WX*L=?XUN|HMo$;U(^)ukQ$fUr3D{umFARCDQ 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) {