Revert "ServerlessFunction: Fix endpoint and event loading"

This reverts commit dc6b480358a70b0c776c5b7fbb00e3b4abf01a33.
This commit is contained in:
Eslam A. Hefnawy 2016-01-28 17:59:00 +07:00
parent dc6b480358
commit bcf6cb3c2f
2 changed files with 54 additions and 40 deletions

View File

@ -150,36 +150,50 @@ class ServerlessFunction {
functionJson = SUtils.readAndParseJsonSync(path.join(_this._config.fullPath, 's-function.json'));
return functionJson.endpoints ? functionJson.endpoints : [];
// loop through endpoints
return functionJson.endpoints;
})
.each(function(e, i) {
.then(function(endpoints){
for (let i = 0; i < endpoints.length; i++) {
functionJson.endpoints[i] = new _this._S.classes.Endpoint(_this._S, {
component: _this._config.component,
module: _this._config.module,
function: functionJson.name,
endpointPath: endpoints[i].path,
endpointMethod: endpoints[i].method
});
functionJson.endpoints[i] = new _this._S.classes.Endpoint(_this._S, {
component: _this._config.component,
module: _this._config.module,
function: functionJson.name,
endpointPath: functionJson.endpoints[i].path,
endpointMethod: functionJson.endpoints[i].method
});
functionJson.endpoints[i].load()
.then(function(instance) {
functionJson.endpoints[i] = instance;
return functionJson.endpoints[i].load();
// loop through events
return functionJson.endpoints[i];
});
}
return functionJson.events;
})
.then(function() {
return functionJson.events ? functionJson.events : [];
})
.each(function(e, i) {
.then(function(events) {
functionJson.events[i] = new _this._S.classes.Event(_this._S, {
component: _this._config.component,
module: _this._config.module,
function: functionJson.name,
name: functionJson.events[i].name,
type: functionJson.events[i].type,
config: functionJson.events[i].config
});
return functionJson.events[i].load();
// Add Event Class Instances
for (let i = 0; i < events.length; i++) {
functionJson.events[i] = new _this._S.classes.Event(_this._S, {
component: _this._config.component,
module: _this._config.module,
function: functionJson.name,
name: events[i].name,
type: events[i].type,
config: events[i].config
});
functionJson.events[i].load()
.then(function (instance) {
functionJson.events[i] = instance;
return functionJson.events[i];
});
}
return functionJson;
})
.then(function() {

View File

@ -16,20 +16,20 @@ describe('All Tests', function() {
require('./tests/classes/ServerlessComponentTest');
require('./tests/classes/ServerlessProjectTest');
require('./tests/classes/ServerlessStateTest');
//require('./tests/actions/TestPluginCustom');
//require('./tests/actions/TestDefaultActionHook');
//require('./tests/actions/StageCreate');
//require('./tests/actions/RegionCreate');
//require('./tests/actions/ComponentCreate');
//require('./tests/actions/ModuleCreate');
//require('./tests/actions/FunctionCreate');
//require('./tests/actions/EnvList');
//require('./tests/actions/EnvGet');
//require('./tests/actions/EnvSetUnset');
//require('./tests/actions/ResourcesDeploy');
//require('./tests/actions/FunctionRun');
//require('./tests/actions/FunctionDeploy');
//require('./tests/actions/EndpointDeploy');
//require('./tests/actions/ProjectCreate');
//require('./tests/actions/ProjectInstall');
require('./tests/actions/TestPluginCustom');
require('./tests/actions/TestDefaultActionHook');
require('./tests/actions/StageCreate');
require('./tests/actions/RegionCreate');
require('./tests/actions/ComponentCreate');
require('./tests/actions/ModuleCreate');
require('./tests/actions/FunctionCreate');
require('./tests/actions/EnvList');
require('./tests/actions/EnvGet');
require('./tests/actions/EnvSetUnset');
require('./tests/actions/ResourcesDeploy');
require('./tests/actions/FunctionRun');
require('./tests/actions/FunctionDeploy');
require('./tests/actions/EndpointDeploy');
require('./tests/actions/ProjectCreate');
require('./tests/actions/ProjectInstall');
});