Re-organize
This commit is contained in:
parent
9d2deccdf9
commit
a9696aeaf8
|
@ -395,17 +395,6 @@ app.enableAuth = function(options) {
|
|||
this.isAuthEnabled = true;
|
||||
};
|
||||
|
||||
app.controller = function(controllerCtor, options) {
|
||||
var self = this;
|
||||
SharedClass = RemoteObjects.SharedClass;
|
||||
|
||||
controllerCtor._sharedClass = new SharedClass(controllerCtor.name);
|
||||
controllerCtor._sharedClass.resolve = function() {
|
||||
return new controllerCtor(app, remotingContext);
|
||||
};
|
||||
app.remotes().addClass(controllerCtor._sharedClass);
|
||||
};
|
||||
|
||||
app.boot = function(options) {
|
||||
throw new Error(
|
||||
'`app.boot` was removed, use the new module loopback-boot instead');
|
||||
|
@ -578,3 +567,49 @@ app.listen = function(cb) {
|
|||
|
||||
return server;
|
||||
};
|
||||
|
||||
/* START CONTROLLER CODE*/
|
||||
|
||||
// Implementation without wrapper
|
||||
|
||||
// app.controller = function(controllerCtor, options) {
|
||||
// var self = this;
|
||||
// SharedClass = RemoteObjects.SharedClass;
|
||||
|
||||
// controllerCtor._sharedClass = new SharedClass(controllerCtor.name, controllerCtor);
|
||||
// controllerCtor._sharedClass.resolve = function() {
|
||||
// return new controllerCtor(app, remotingContext);
|
||||
// };
|
||||
// app.remotes().addClass(controllerCtor._sharedClass);
|
||||
// };
|
||||
|
||||
// Implementation with wrapper
|
||||
|
||||
app.controller = function(ctor, options) {
|
||||
var controller = new SharedController(ctor);
|
||||
app.remotes().addClass(wrapper.sharedClass);
|
||||
app.controllers[ctor.name] = wrapper;
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
function SharedController(ctor, options) {
|
||||
options = options || {};
|
||||
this.name = ctor.name;
|
||||
this.ctor = ctor;
|
||||
this.sharedClass = new SharedClass(this.name, ctor, options);
|
||||
};
|
||||
|
||||
SharedController.remoteMethod = function(name, options) {
|
||||
if (options.isStatic === undefined) {
|
||||
var m = name.match(/^prototype\.(.*)$/);
|
||||
options.isStatic = !m;
|
||||
name = options.isStatic ? name : m[1];
|
||||
}
|
||||
this.sharedClass.defineMethod(name, options);
|
||||
};
|
||||
|
||||
SharedController.disableRemoteMethod = function() {
|
||||
|
||||
};
|
||||
|
||||
/* END CONTROLLER CODE */
|
||||
|
|
Loading…
Reference in New Issue