Total.js v2.7.0

Tue Jul 04 2017 08:27:56 GMT+0200 (Central European Summer Time), Peter Širka

New Total.js framework version 2.7.0

This version brings a few fixes and improvements.

News

Static files of Components

I have improved rendering of group of components @{components('group'}. Now the framework links static files from rendered groups only. In other words: each group of components has its own scripts and styles. This change is a good news for applications using a lot of components.

Prototypes

With this version you can extend some Total.js prototypes easily. Just extend prototype:

F.prototypes(function(proto) {
    // proto.Chunker
    // proto.Controller
    // proto.Database
    // proto.DatabaseBinary
    // proto.DatabaseBuilder
    // proto.DatabaseBuilder2
    // proto.DatabaseCounter
    // proto.ErrorBuilder
    // proto.HttpFile
    // proto.HttpRequest
    // proto.HttpResponse
    // proto.Image
    // proto.Message
    // proto.Page
    // proto.Pagination
    // proto.RESTBuilder
    // proto.RESTBuilderResponse
    // proto.SchemaBuilder
    // proto.SchemaOptions
    // proto.TransformBuilder
    // proto.UrlBuilder
    // proto.WebSocket
    // proto.WebSocketClient
});

Changed default IP

I have changed default IP from 127.0.0.1 to 0.0.0.0. This change has multiple benefits:

  • app can run on localhost or 127.0.0.1
  • app can run on your machine IP e.g. 192.168.200.1
  • Amazon EC2 and another similar services use 0.0.0.0 IP for Node.js apps

Controller can be changed in the schema directly

In some cases it's very important to change a controller dynamically and directly in the schema. I have extend SchemaBuilderEntity by adding a new method .$controller(new_controller).

For example:

model.$controller(NEW_INSTANCE_OF_CONTROLLER);
model.$save();

NoSQL meta-data

Only a few developers know that NoSQL supports meta-data - key-value storage. I have extended database object by adding new methods:

var db = NOSQL('orders');
db.set('numbering', (db.get('numbering') || 0) + 1);

Meta-data are stored in plain-text JSON file: orders.nosql-meta and all meta-data are read into the memory automatically when the DB is loaded.

Improved Unit-Testing

I have improved unit-testing in Total.js framework. Read more information about new unit-testing system in Total.js documentation or follow this example.

Example of some test:

TEST('controller.increment()', function() {
    FAIL(F.controller('default').functions.increment(1) !== 2);
});

TEST('Test URL 1', '/1/', function(builder) {
    // builder === RESTBuilder
    builder.get();
    builder.exec(function(err, response, output) {
        FAIL(output.response !== '1');
    });
});

TEST('Test URL 2', '/2/', function(builder) {
    // builder === RESTBuilder
    builder.get();
    builder.exec(function(err, response, output) {
        FAIL(output.response !== '2', 'additional description');
        OK(output.status === 200, 'HTTP status');
    });
});

TEST('Test URL 3', '/3/', function(builder) {
    // builder === RESTBuilder
    builder.json({ data: 4 });
    builder.exec(function(err, response) {
        FAIL(response.data !== 3);
    });
});

RESULT:

====================================================
PID         : 51109
Node.js     : v8.1.3
Total.js    : v2.7.0
OS          : darwin 16.6.0
====================================================
Name        : Total.js
Version     : 1.0.0
Author      : Peter Širka
Date        : 2017-07-03 11:06:28
Mode        : debug
====================================================

http://0.0.0.0:8000/

===================== TESTING ======================

[ TEST: default.js ]

Passed ............. controller.increment() [1 ms]
Passed ............. Test URL 1 [22 ms]
Passed ............. Test URL 2 <additional description> [6 ms]
Passed ............. Test URL 2 <HTTP status> [6 ms]
Failed [x] ......... Test URL 3 [6 ms]

===================== RESULTS ======================

> Passed ......... 4/4
> Failed [x] ..... 1/4

Improved RESTBuilder

I have added a new features into the RESTBuilder:

  • instance.robot() extends user-agent by adding bot keyword
  • instance.mobile() extends user-agent by adding iPhone keyword
  • instance.file(name, filename, [buffer]) can upload file as multipart/form-data

Follow Total.js Framework on Twitter and give a star on Github.


Tags

Follow us

Latest blogs
Flow v6 is here!
Thu Mar 07 2019 11:53:54 GMT+0100 (Central European Standard Time)
A critical security fix
Wed Feb 13 2019 22:15:39 GMT+0100 (Central European Standard Time)
New release: Total.js v3.2
Wed Feb 13 2019 22:14:39 GMT+0100 (Central European Standard Time)
Total.js Wiki v2
Fri Jan 04 2019 22:15:01 GMT+0100 (Central European Standard Time)
Total Year 2018
Thu Jan 03 2019 21:14:00 GMT+0100 (Central European Standard Time)

Latest comments
Nice tip
Mauro Junior
Thu Sep 20 2018 21:41:02 GMT+0200 (Central European Summer Time)
Not only for Total.js. You can communicate with different websocket servers.
Peter Širka
Mon Apr 23 2018 20:08:20 GMT+0200 (Central European Summer Time)
Marko: you need to create a buffer with this codepage and write byte-to-byte string. I recommend ...
Peter Širka
Mon Apr 23 2018 20:06:21 GMT+0200 (Central European Summer Time)
Is WEBSOCKETCLIENT only for internal ws connections between totaljs apps?
Stelios Stephanua
Fri Mar 16 2018 06:04:22 GMT+0100 (Central European Standard Time)
Total.js is amazing! ;)
Leonardo Hessel
Tue Dec 19 2017 19:51:15 GMT+0100 (Central European Standard Time)

Pixabay


Read more

Flow v6 is here!

News: We have released a new version of Flow. This version brings great new features and UI improvements.

Thu Mar 07 2019 11:53:54 GMT+0100 (Central European Standard Time)
A critical security fix

News: We were notified about the critical security bug in Total.js framework. Read a prevention.

Wed Feb 13 2019 22:15:39 GMT+0100 (Central European Standard Time)
New release: Total.js v3.2

News: This new release brings a critical security fix and small new improvements. Update Total.js now.

Wed Feb 13 2019 22:14:39 GMT+0100 (Central European Standard Time)
Total.js Wiki v2

Products: I have released a new version of Total.js Wiki. New version brings new improvements.

Fri Jan 04 2019 22:15:01 GMT+0100 (Central European Standard Time)
Total Year 2018

Business: Last year was perfect for Total.js platform. Total.js platform grows up and it has great results.

Thu Jan 03 2019 21:14:00 GMT+0100 (Central European Standard Time)
Total.js Code Editor v1

Products: Try our real-time collaboration tool for Total Developers. Code Editor offers great features for development.

Fri Dec 07 2018 22:55:13 GMT+0100 (Central European Standard Time)