Skip to content

Commit

Permalink
Added /api/v1 to all API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Campos committed Nov 5, 2017
1 parent 4ca214e commit b42ce9c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 13 deletions.
14 changes: 10 additions & 4 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,31 @@ 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,
client_id: process.env.CLIENT_ID,
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
});


Expand Down
1 change: 0 additions & 1 deletion dist/index.html

This file was deleted.

Binary file removed lib/.DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions lib/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion lib/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 5 additions & 4 deletions lib/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit b42ce9c

Please sign in to comment.