Tidy up API passed to node modules

This commit is contained in:
Nick O'Leary
2015-11-24 22:38:42 +00:00
parent 043b8a3105
commit f03aff7006
18 changed files with 195 additions and 99 deletions

View File

@@ -42,7 +42,6 @@ function init(_server,runtime) {
runtime.events.on("node-status",handleStatus);
}
function start() {
var Tokens = require("./auth/tokens");
var Users = require("./auth/users");

View File

@@ -20,7 +20,7 @@ var api;
module.exports = {
init: function(runtime) {
log = runtime.log;
api = runtime.api;
api = runtime.nodes;
},
get: function (req, res) {
// TODO: It should verify the given node id is of the type specified -

View File

@@ -21,7 +21,7 @@ var settings;
module.exports = {
init: function(runtime) {
settings = runtime.settings;
redNodes = runtime.api;
redNodes = runtime.nodes;
log = runtime.log;
},
get: function(req,res) {

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2014 IBM Corp.
* Copyright 2014, 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ var i18n;
var log;
var adminApp;
var nodeApp;
var server;
var errorHandler = function(err,req,res,next) {
if (err.message === "request entity too large") {
@@ -49,7 +50,8 @@ var errorHandler = function(err,req,res,next) {
res.status(400).json({error:"unexpected_error", message:err.toString()});
};
function init(server,runtime) {
function init(_server,runtime) {
server = _server;
var settings = runtime.settings;
i18n = runtime.i18n;
log = runtime.log;
@@ -150,6 +152,7 @@ module.exports = {
comms: {
publish: comms.publish
},
adminApp: function() { return adminApp; },
nodeApp: function() { return nodeApp; }
get adminApp() { return adminApp; },
get nodeApp() { return nodeApp; },
get server() { return server; }
};

View File

@@ -24,7 +24,7 @@ var settings;
module.exports = {
init: function(runtime) {
redNodes = runtime.api;
redNodes = runtime.nodes;
log = runtime.log;
i18n = runtime.i18n;
settings = runtime.settings;