Skip to content

Commit

Permalink
Moved API calls to /api context path
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 29, 2015
1 parent e02968d commit af0a6c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/js/services/backendAPIService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ angular.module('jboss-forge').service('backendAPI', function($http, config){
}

this.fetchAddons = function(_success) {
return this.fetch('/addons', _success);
return this.fetch('/api/addons', _success);
}

this.fetchDocs = function(_success) {
return this.fetch('/docs', _success);
return this.fetch('/api/docs', _success);
}

this.fetchNews = function(_success) {
return this.fetch('/news', _success);
return this.fetch('/api/news', _success);
}
});

11 changes: 6 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ var mkdirSync = function (path) {
}

// Routes
app.get(/(\/|\/(1\.x|css|fonts|images|js|views)\/?.*)/, restify.serveStatic({default: 'index.html', directory: './app/'}));

app.get('/addons', function(req, res) {
app.get('/api/addons', function(req, res) {
var addons =
{
'community':
Expand Down Expand Up @@ -58,7 +56,7 @@ app.get('/addons', function(req, res) {
res.json(addons);
});

app.get('/docs', function(req, res) {
app.get('/api/docs', function(req, res) {
var docs = [
{
level: 'beginner',
Expand All @@ -85,12 +83,15 @@ app.get('/docs', function(req, res) {
res.json(docs);
});

app.get('/news', function(req, res) {
app.get('/api/news', function(req, res) {
var body = fs.readFileSync(config.get('FORGE_WEBSITE_DATA_DIR') + "/docs-news.yaml");
var allEntries = yamlLoad(body);
res.json(allEntries);
});

// Everything except the already defined routes. IMPORTANT: this should be the last route
app.get(/\/?.*/, restify.serveStatic({default: 'index.html', directory: './app/'}));

app.listen(config.get('PORT'), config.get('IP'), function () {
console.log( "Listening on " + config.get('IP') + ", port " + config.get('PORT') );
});
Expand Down

0 comments on commit af0a6c9

Please sign in to comment.