Skip to content

Commit

Permalink
Merge pull request Azure#157 from andrerod/dev
Browse files Browse the repository at this point in the history
Adding service runtime sample app.
  • Loading branch information
André Rodrigues committed Apr 20, 2012
2 parents bee77cb + c46c4a5 commit 0971d59
Show file tree
Hide file tree
Showing 456 changed files with 7,938 additions and 8,169 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.txt
@@ -1,3 +1,8 @@
2012.04.19 Version 0.5.3
* Service Runtime Wrappers
* Multiple Bugfixes
* Unit tests converted to mocha and code coverage made easy through JSCoverage

2012.02.10 Version 0.5.2
* Service Bus Wrappers
* Storage Services UT run against a mock server.
Expand Down
8 changes: 7 additions & 1 deletion examples/geophoto/services/pushpinService.js
Expand Up @@ -13,7 +13,13 @@
* limitations under the License.
*/

var azure = require('azure');
var azure;
if (path.existsSync('./../../lib/azure.js')) {
azure = require('./../../lib/azure');
} else {
azure = require('azure');
}

var uuid = require('node-uuid');

var ServiceClient = azure.ServiceClient;
Expand Down
135 changes: 135 additions & 0 deletions examples/serviceexplorer/controllers/serviceController.js
@@ -0,0 +1,135 @@
/**
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var util = require('util');
var fs = require('fs');
var nconf = require('nconf');

nconf.file({ file: 'config.json' });

var roleEnvironmentService = require('../services/roleEnvironmentService');

exports.setup = function (request, response) {
response.render('setup');
};

exports.setupPOST = function (request, response) {
var showError = function (message) {
// TODO: actually show the error message
response.render('setup');
};

if (request.body.account &&
request.body.accessKey &&
request.body.WaRuntimeEndpoint) {

nconf.set('AZURE_STORAGE_ACCOUNT', request.body.account);
nconf.set('AZURE_STORAGE_ACCESS_KEY', request.body.accessKey);
nconf.set('WaRuntimeEndpoint', request.body.WaRuntimeEndpoint);

nconf.save(function (error) {
if (error) {
showError(error);
} else {
response.redirect('/');
}
});
} else {
showError();
}
};

exports.showRoles = function (request, response) {
var action = function () {
roleEnvironmentService.getRoles(function (error, roles) {
response.render('index', {
locals: {
error: error,
roles: roles
}
});
});
};

if (!exports.isConfigured()) {
response.redirect('/setup');
} else {
action();
}
};

exports.showRole = function (request, response) {
var action = function () {
roleEnvironmentService.getRole(request.params.id, function (error, role) {
response.render('role', {
locals: {
error: error,
role: role
}
});
});
};

if (!exports.isConfigured()) {
response.redirect('/setup');
} else {
action();
}
};

exports.editRole = function (request, response) {
var action = function () {
roleEnvironmentService.getRole(request.params.id, function (error, role) {
response.render('editRole', {
locals: {
error: error,
role: role
}
});
});
};

if (!exports.isConfigured()) {
response.redirect('/setup');
} else {
action();
}
};

exports.editRolePost = function (request, response) {
var roleData = request.body;
var roleImage = null;

if (request.files && request.files.image && request.files.image.size > 0) {
roleImage = request.files.image;
}

roleEnvironmentService.createOrEditRole(roleData, roleImage, function (createOrEditRoleError) {
if (createOrEditRoleError) {
response.writeHead(500, { 'Content-Type': 'text/plain' });
response.end(JSON.stringify(util.inspect(createOrEditRoleError)));
} else {
response.redirect('/');
}
});
};

exports.isConfigured = function () {
if (nconf.get('AZURE_STORAGE_ACCOUNT')) {
return true;
}

return false;
};
12 changes: 12 additions & 0 deletions examples/serviceexplorer/package.json
@@ -0,0 +1,12 @@
{
"name": "serviceexplorer"
, "version": "0.0.1"
, "dependencies": {
"azure": ">= 0.5.1"
, "express": "2.5.1"
, "ejs": ">= 0.0.1"
, "underscore": ">= 1.3.1"
, "node-uuid": ">= 1.3.3"
, "nconf": ">= 0.5.1"
}
}

0 comments on commit 0971d59

Please sign in to comment.