Skip to content

Commit

Permalink
Merge pull request #59 from BoolJS/develop
Browse files Browse the repository at this point in the history
Several fixes on bootstrapping process
  • Loading branch information
pandres95 authored Mar 23, 2020
2 parents f49cbee + 0c96f33 commit 8e29e67
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
12 changes: 10 additions & 2 deletions lib/api/folder/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ module.exports = class FolderList {

/** @ignore */
get paths () {
return this.subfolders;
return this[Subfolders];
}

/** @ignore */
get base () {
return this.base;
return this[BasePath];
}

/** @ignore */
Expand All @@ -49,6 +49,14 @@ module.exports = class FolderList {
}
}

has (key) {
return this[Subfolders][key] !== undefined;
}

set (key, location) {
this.loadSubfolderProperties(key, location);
}

loadSubfolderProperties (key, location) {
Object.defineProperty(this, key, {
/** @ignore */
Expand Down
2 changes: 1 addition & 1 deletion lib/api/folder/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exports.readFiles = async function (instance, component, route, files) {
throw new Error(0, 'E_INVALIDFILENAME', 'The file name format is invalid');
} else {
instance.insertComponent(filenameInfo.name,
await new Reader().readCode(filenameInfo.ext, filename), component);
await Reader.readCode(filenameInfo.ext, filename), component);
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions lib/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ module.exports = class BoolJSBootstrapper {
* @return {BoolJSBootstrapper} The loaded application instance
*/
setFolder (key, folder) {
if (!this.folders.has(key)) {
this.folders.set(key, folder);
return this;
}

this.folders[key] = folder;
return this;
}
Expand Down Expand Up @@ -150,7 +155,7 @@ module.exports = class BoolJSBootstrapper {
for (var route in _.omit(this.folders.paths, 'configuration')) {
this.instance.insertComponent(route, {});

await this.Folder.read(
await Folder.read(
this.instance,
this.instance.getComponents()[route],
this.folders[route]
Expand Down Expand Up @@ -245,6 +250,6 @@ module.exports = class BoolJSBootstrapper {
return this.run();
}

this.bootstrap();
return this.bootstrap();
}
};
4 changes: 3 additions & 1 deletion lib/api/loaders/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ exports.fetchModel = async function (instance, loaders, { models, key }) {
}
};
}

return Model;
};

/**
Expand All @@ -79,7 +81,7 @@ module.exports = async function DatabaseLoader (instance, drivers) {
const loaders = await exports.openDatabases(instance, drivers);

for (const { models, key } of modelsList) {
const Model = exports
const Model = await exports
.fetchModel(instance, loaders, { models, key });
instance.insertComponent(key, Model, models);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/api/loaders/server/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { Plugins, RouteMiddleware } = require('@booljs/api');

function matchPolicies (middlewareList, condition) {
return middlewareList.filter(middleware => {
for (const policy of middleware.policies) {
for (const policy of Object.values(middleware.policies)) {
if (condition(middleware, policy)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "booljs",
"version": "0.9.1",
"version": "0.9.2",
"description": "Bool MVC Framework - Bootstraping Unit",
"main": "lib/index.js",
"license": "GPL-3.0",
Expand Down

0 comments on commit 8e29e67

Please sign in to comment.