total5 0.0.1-3 → 0.0.1-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api.js CHANGED
@@ -132,7 +132,7 @@ APICallProto.error = APICallProto.err = function(err, reverse) {
132
132
 
133
133
  APICallProto.callback = function($) {
134
134
  var t = this;
135
- t.$callback = typeof($) === 'function' ? $ : $.callback;
135
+ t.$callback = typeof($) === 'function' ? $ : $.callback();
136
136
  return t;
137
137
  };
138
138
 
package/builders.js CHANGED
@@ -262,6 +262,11 @@ ErrorBuilder.prototype = {
262
262
  }
263
263
  };
264
264
 
265
+ ErrorBuilder.prototype.reject = function(language) {
266
+ var self = this;
267
+ return new Error(self.toString(language, ''));
268
+ };
269
+
265
270
  ErrorBuilder.prototype.push = function(err, path, index) {
266
271
  var self = this;
267
272
 
@@ -333,12 +338,12 @@ ErrorBuilder.prototype.output = function(language = 'default') {
333
338
  return output;
334
339
  };
335
340
 
336
- ErrorBuilder.prototype.toString = function(language = 'default') {
341
+ ErrorBuilder.prototype.toString = function(language = 'default', divider = '\n') {
337
342
  var self = this;
338
343
  var output = self.output(language);
339
344
  var str = '';
340
345
  for (let err of output)
341
- str += (str ? '\n' : '') + err.error;
346
+ str += (str ? divider : '') + err.error;
342
347
  return str;
343
348
  };
344
349
 
@@ -463,7 +468,7 @@ RESTP.promise = function($) {
463
468
  if ($ && $.invalid)
464
469
  $.invalid(err);
465
470
  else
466
- reject(err);
471
+ reject(err.reject());
467
472
  } else
468
473
  resolve(response);
469
474
  });
@@ -1219,7 +1224,7 @@ ActionCaller.prototype.exec = function() {
1219
1224
  var type = meta.payload || (action.input ? '+' : '-');
1220
1225
  var $ = self.$;
1221
1226
 
1222
- $.id = id;
1227
+ $.id = action.id;
1223
1228
  $.error = self.error;
1224
1229
  $.controller = self.controller;
1225
1230
  $.fields = action.fields;
@@ -1363,7 +1368,7 @@ ActionCaller.prototype.promise = function($) {
1363
1368
  if ($ && $.invalid)
1364
1369
  $.invalid(err);
1365
1370
  else
1366
- reject(err);
1371
+ reject(err.reject());
1367
1372
  } else
1368
1373
  resolve(response);
1369
1374
  };
package/bundles.js CHANGED
@@ -400,7 +400,7 @@ exports.extract = function(callback, skip) {
400
400
  try {
401
401
 
402
402
  if (F.Fs.readFileSync('bundles.debug')) {
403
- F.isbundle = true;
403
+ F.isBundle = true;
404
404
  F.dir(F.path.root('/.src/'));
405
405
  callback();
406
406
  return;
@@ -428,7 +428,7 @@ exports.extract = function(callback, skip) {
428
428
  });
429
429
  }, function() {
430
430
  extract(function() {
431
- F.isbundle = true;
431
+ F.isBundle = true;
432
432
  F.dir(F.path.root('/.src/'));
433
433
  callback();
434
434
  });
@@ -436,21 +436,11 @@ exports.extract = function(callback, skip) {
436
436
  };
437
437
 
438
438
  try {
439
-
440
439
  var files = F.Fs.readdirSync(bundles);
441
440
  if (files.length)
442
441
  extractbundles();
443
442
  else
444
443
  callback();
445
-
446
- /*
447
- if (F.$bundling) {
448
- makebundle();
449
- return;
450
- } else {
451
- F.isbundle = true;
452
- F.dir(F.path.root('/.src/'));
453
- }*/
454
444
  } catch(e) {
455
445
  callback();
456
446
  }
package/controller.js CHANGED
@@ -153,8 +153,32 @@ Controller.prototype = {
153
153
 
154
154
  };
155
155
 
156
+ Controller.prototype.callback = function(err, value) {
157
+
158
+ var ctrl = this;
159
+
160
+ if (arguments.length == 0) {
161
+ return function(err, response) {
162
+ if (err)
163
+ ctrl.invalid(err);
164
+ else
165
+ ctrl.json(response);
166
+ };
167
+ }
168
+
169
+ if (err)
170
+ ctrl.invalid(err);
171
+ else {
172
+ if (value === undefined)
173
+ ctrl.success();
174
+ else
175
+ ctrl.json(value);
176
+ }
177
+
178
+ };
179
+
156
180
  Controller.prototype.csrf = function() {
157
- return DEF.onCSRFcreate(this);
181
+ return F.def.onCSRFcreate(this);
158
182
  };
159
183
 
160
184
  Controller.prototype.redirect = function(value, permanent) {
@@ -777,6 +801,7 @@ Controller.prototype.$route = function() {
777
801
  }
778
802
 
779
803
  let route = F.TRouting.lookup(ctrl);
804
+
780
805
  if (route) {
781
806
 
782
807
  ctrl.route = route;
@@ -795,7 +820,7 @@ Controller.prototype.$route = function() {
795
820
 
796
821
  ctrl.req.on('data', function(chunk) {
797
822
  ctrl.payloadsize += chunk.length;
798
- if (ctrl.payloadsize > ctrl.route.size) {
823
+ if ((ctrl.payloadsize / 1024) > ctrl.route.size) {
799
824
  if (!ctrl.toolarge) {
800
825
  ctrl.toolarge = true;
801
826
  delete ctrl.payload;
@@ -936,7 +961,7 @@ function multipart(ctrl) {
936
961
  }
937
962
 
938
963
  function authorize(ctrl) {
939
- if (DEF.onAuthorize) {
964
+ if (F.def.onAuthorize) {
940
965
  var opt = new F.TBuilders.Options(ctrl);
941
966
  opt.TYPE = 'auth'; // important
942
967
  opt.next = opt.callback;
@@ -953,7 +978,7 @@ function authorize(ctrl) {
953
978
  ctrl.fallback(401);
954
979
  }
955
980
  };
956
- DEF.onAuthorize(opt);
981
+ F.def.onAuthorize(opt);
957
982
  } else
958
983
  execute(ctrl);
959
984
  }
@@ -984,7 +1009,7 @@ function execute(ctrl) {
984
1009
  body = body.data;
985
1010
  if (!body || typeof(body) === 'object') {
986
1011
  ctrl.params = params;
987
- F.action(endpoint.actions, body || EMPTYOBJECT, ctrl).autorespond();
1012
+ F.action(endpoint.actions, body || {}, ctrl).autorespond();
988
1013
  return;
989
1014
  }
990
1015
  }