Skip to content

Commit 8e29e67

Browse files
authored
Merge pull request #59 from BoolJS/develop
Several fixes on bootstrapping process
2 parents f49cbee + 0c96f33 commit 8e29e67

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

lib/api/folder/list.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ module.exports = class FolderList {
3232

3333
/** @ignore */
3434
get paths () {
35-
return this.subfolders;
35+
return this[Subfolders];
3636
}
3737

3838
/** @ignore */
3939
get base () {
40-
return this.base;
40+
return this[BasePath];
4141
}
4242

4343
/** @ignore */
@@ -49,6 +49,14 @@ module.exports = class FolderList {
4949
}
5050
}
5151

52+
has (key) {
53+
return this[Subfolders][key] !== undefined;
54+
}
55+
56+
set (key, location) {
57+
this.loadSubfolderProperties(key, location);
58+
}
59+
5260
loadSubfolderProperties (key, location) {
5361
Object.defineProperty(this, key, {
5462
/** @ignore */

lib/api/folder/read.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ exports.readFiles = async function (instance, component, route, files) {
4343
throw new Error(0, 'E_INVALIDFILENAME', 'The file name format is invalid');
4444
} else {
4545
instance.insertComponent(filenameInfo.name,
46-
await new Reader().readCode(filenameInfo.ext, filename), component);
46+
await Reader.readCode(filenameInfo.ext, filename), component);
4747
}
4848
}
4949
}

lib/api/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ module.exports = class BoolJSBootstrapper {
5959
* @return {BoolJSBootstrapper} The loaded application instance
6060
*/
6161
setFolder (key, folder) {
62+
if (!this.folders.has(key)) {
63+
this.folders.set(key, folder);
64+
return this;
65+
}
66+
6267
this.folders[key] = folder;
6368
return this;
6469
}
@@ -150,7 +155,7 @@ module.exports = class BoolJSBootstrapper {
150155
for (var route in _.omit(this.folders.paths, 'configuration')) {
151156
this.instance.insertComponent(route, {});
152157

153-
await this.Folder.read(
158+
await Folder.read(
154159
this.instance,
155160
this.instance.getComponents()[route],
156161
this.folders[route]
@@ -245,6 +250,6 @@ module.exports = class BoolJSBootstrapper {
245250
return this.run();
246251
}
247252

248-
this.bootstrap();
253+
return this.bootstrap();
249254
}
250255
};

lib/api/loaders/database.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ exports.fetchModel = async function (instance, loaders, { models, key }) {
6363
}
6464
};
6565
}
66+
67+
return Model;
6668
};
6769

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

8183
for (const { models, key } of modelsList) {
82-
const Model = exports
84+
const Model = await exports
8385
.fetchModel(instance, loaders, { models, key });
8486
instance.insertComponent(key, Model, models);
8587
}

lib/api/loaders/server/router.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { Plugins, RouteMiddleware } = require('@booljs/api');
55

66
function matchPolicies (middlewareList, condition) {
77
return middlewareList.filter(middleware => {
8-
for (const policy of middleware.policies) {
8+
for (const policy of Object.values(middleware.policies)) {
99
if (condition(middleware, policy)) {
1010
return true;
1111
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "booljs",
3-
"version": "0.9.1",
3+
"version": "0.9.2",
44
"description": "Bool MVC Framework - Bootstraping Unit",
55
"main": "lib/index.js",
66
"license": "GPL-3.0",

0 commit comments

Comments
 (0)