Skip to content

Commit 979a526

Browse files
committed
updated: exports.install (modules, models, controllers, etc.)
1 parent ed0accf commit 979a526

9 files changed

Lines changed: 44 additions & 23 deletions

File tree

changes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ BETA ======= 1.8.1
77
- added: F.path.private([filename])
88
- added: Controller.ping() for WebSocket
99
- added: global.DB() --> same as global.DATABASE()
10+
- added: `config['allow-compatibility'] = true` - a backward compatibility mode (in newest version 1.9 will be set to `false`)
1011

1112
- updated: F.route(url, ...), F.websocket(url, ...) --> URL can be function(url, req, [flags])
1213
- updated: `config['allow-performance']` is set to true
@@ -26,6 +27,9 @@ BETA ======= 1.8.1
2627

2728
- improved: code optimalization
2829

30+
__IMPORTANT:__
31+
`exports.install = function(framework) {}` framework variable is removed but with backward compatibility (`config['allow-compatibility']`).
32+
2933
======= 1.8.0
3034

3135
source-code: "tabs" instead of "spaces"

index.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ function Framework() {
269269
'allow-compile-html': true,
270270
'allow-performance': false,
271271
'allow-custom-titles': false,
272+
'allow-compatibility': true,
272273
'disable-strict-server-certificate-validation': true,
273274
'disable-clear-temporary-directory': false,
274275

@@ -1914,8 +1915,12 @@ Framework.prototype.install = function(type, name, declaration, options, callbac
19141915
else
19151916
self.sources[name] = obj;
19161917

1917-
if (typeof(obj.install) === TYPE_FUNCTION)
1918-
obj.install(self, options, name);
1918+
if (typeof(obj.install) === TYPE_FUNCTION) {
1919+
if (framework.config['allow-compatibility'])
1920+
obj.install(self, options, name);
1921+
else
1922+
obj.install(options, name);
1923+
}
19191924

19201925
if (!skipEmit) {
19211926
setTimeout(function() {
@@ -2094,8 +2099,12 @@ Framework.prototype.install_make = function(key, name, obj, options, callback, s
20942099

20952100
_controller = routeID;
20962101

2097-
if (typeof(obj.install) === TYPE_FUNCTION)
2098-
obj.install(self, options, name);
2102+
if (typeof(obj.install) === TYPE_FUNCTION) {
2103+
if (framework.config['allow-compatibility'])
2104+
obj.install(self, options, name);
2105+
else
2106+
obj.install(options, name);
2107+
}
20992108

21002109
me.processed = true;
21012110

@@ -2207,8 +2216,12 @@ Framework.prototype.uninstall = function(type, name, options, skipEmit) {
22072216
if (obj.id)
22082217
delete require.cache[require.resolve(obj.id)];
22092218

2210-
if (typeof(obj.uninstall) === TYPE_FUNCTION)
2211-
obj.uninstall(self, options, name);
2219+
if (typeof(obj.uninstall) === TYPE_FUNCTION) {
2220+
if (framework.config['allow-compatibility'])
2221+
obj.uninstall(self, options, name);
2222+
else
2223+
obj.uninstall(options, name);
2224+
}
22122225

22132226
if (type === 'model')
22142227
delete self.models[name];
@@ -2240,8 +2253,12 @@ Framework.prototype.uninstall = function(type, name, options, skipEmit) {
22402253
self.routes.websockets = self.routes.websockets.remove('controller', id);
22412254

22422255
if (obj) {
2243-
if (obj.uninstall)
2244-
obj.uninstall(self, options, name);
2256+
if (obj.uninstall) {
2257+
if (framework.config['allow-compatibility'])
2258+
obj.uninstall(self, options, name);
2259+
else
2260+
obj.uninstall(options, name);
2261+
}
22452262

22462263
if (isModule)
22472264
delete self.modules[name];

test/controllers/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var assert = require('assert');
22

3-
exports.install = function(framework) {
3+
exports.install = function() {
44

55
framework.route(function(url, req, flags) {
66
return url === '/custom/route/';

test/controllers/share.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
exports.dependencies = ['test'];
22

3-
exports.install = function(framework) {
3+
exports.install = function() {
44
framework.route('/share/', view_share);
55
framework.route('/router/', view_router);
66
framework.route('/share/a/', view_share_a);

test/controllers/subdirectory/share.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
exports.install = function(framework) {
1+
exports.install = function() {
22
framework.route('/sub/share/', view_share);
33
};
44

test/modules/inline-view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var assert = require('assert');
33
exports.dependencies = ['test'];
44
exports.installed = false;
55

6-
exports.install = function(framework) {
6+
exports.install = function() {
77
exports.installed = true;
88
framework.route('/inline-view-route/');
99
setTimeout(function() {

test/modules/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var assert = require('assert');
22
var app;
33

4-
exports.install = function(framework) {
4+
exports.install = function() {
55
app = framework;
66
assert.ok(typeof(framework.modules) === 'object', 'module install');
77

test/test-framework-release.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ function test_routing(next) {
8989

9090
var async = new utils.Async();
9191

92+
async.await('html compressor', function(complete) {
93+
utils.request(url + 'html-compressor/', ['get'], null, function(error, data, code, headers) {
94+
if (error)
95+
throw error;
96+
assert(data === '<div><p>a b c d</p><div>Price 30 &euro;</div></div><div>Name: Peter</div><div>Name: Peter</div><div>Price: 1000 1 000.00</div><div>13</div><div>Name: Peter</div>', 'HTML compressor');
97+
complete();
98+
});
99+
});
100+
92101
async.await('0', function(complete) {
93102
utils.request(url + 'share/', 'GET', null, function(error, data, code, headers) {
94103
if (error)
@@ -140,15 +149,6 @@ function test_routing(next) {
140149
});
141150
});
142151

143-
async.await('html compressor', function(complete) {
144-
utils.request(url + 'html-compressor/', ['get'], null, function(error, data, code, headers) {
145-
if (error)
146-
throw error;
147-
assert(data === '<div><p>a b c d</p><div>Price 30 &euro;</div></div><div>Name: Peter</div><div>Name: Peter</div>', 'HTML compressor');
148-
complete();
149-
});
150-
});
151-
152152
async.await('rest GET', function(complete) {
153153
utils.request(url + 'rest/', ['get'], null, function(error, data, code, headers) {
154154
if (error)

test/tests/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var assert = require('assert');
22

3-
exports.run = function(framework) {
3+
exports.run = function() {
44

55
framework.assert('validation assert', function(next, name) {
66
assert('1' !== '2', name);

0 commit comments

Comments
 (0)