Total.js Platform
Total.js Platform

Total.js Platform news and tutorials

Total.js v3.0.0

Total.js v3.0.0

Impossible is possible, this is Total.js v3. This new version brings great new features which will make you love Total.js framework even more. Version 3 is not just an another number, it brings breakthrough features and simplicity.

Good backwards compatibility

I guarantee a good backward compatibility with Total.js >= 2.5, but downgrade won't be possible for NoSQL embedded databases since this version doesn't contain NoSQL Views. Some methods have been removed and the framework contains alternatives in most cases.

Bundles

Bundles are one of the best features in this new version of Total.js. Bundles are something like packages, but they are a part of application's core. Imagine that you have a CMS with many files and you don't want to see these files in your e.g. new project because they are useless for you but they are important for the project. And then you use a bundle of CMS which you copy into your app, then you can extend a built-in funcionallity or a theme. Also you can create the bundle from everything e.g. API, eshop, etc. and use it in your projects. Bundles bring clean projects and easy maintenance. You will love bundles.

Async rendering of Total.js Components

This is a very big feature. So a component can contain e.g. loading products from DB or communicate via RESTBuilder with another 3rd party service.

Component:

Rendering in a view:

Total.js Components support inline files

Next big feature. Total.js parses all inline files and stores them in temporary directory. All files are available on http://blabla.com/~componentname/filename.

  • files must be encoded in base64 format
  • data are stored in <file name="FILENAME">base64</file> tag
  • Documentation

Example:

NoSQL database

Total.js v3 brings improved, highly optimized database engine with features not seen in any other flat file database. The database is much faster during reading/updating/removing/inserting operations and saves memory as well as CPU. This DB works well on ARM and data is streamed when reading/updating/removing/inserting.

I re-wrote the engine completely and now the engine doens't use Node.js streams but it uses my own implementation which is optimized for better reading and writing.

New database filters and features

NoSQL worker

This is another great feature in Total.js framework. NoSQL worker creates another thread for NoSQL embedded database, so your application will not share the thread with db engine.

Enabling NoSQL worker in /config:

You can have a problem with some filters like builder.filter() and builder.prepare(). You can't use NoSQL worker in some cases if you use above filters. To get more info about workers feel free to contact me.

NoSQL storage

This is a new file system storage for small big data with MapReduce funcionality. This storage saves documents by days. In other words: the framework creates a new storage file every day. Data are saved in plain text files like NoSQL embedded database file (same structure). Storage is targeted for storing data from IoT sensors.

Storage doesn't have any method for removing/modifing documents, but you can perform:

Scanning:

Map Reduce:

This feature performs map/reduce on each document in the storage (only the first time) and then storage performs map/reduce for new documents only. It's very effective. A result called repository is stored on the file system.

NoSQL binary & FileStorage

NoSQL binary has also been updated and files are stored under sorted directories. Each directory holds up to 1000 files. Directories are indexed and they are named as 000-000-001 up to 999-999-999. So you can store max. 999 999 999 * 1000 files per DB.

Binary storage has the same methods as before and supports one new method binary.browse([directory], callback(err, files)) for browsing uploaded files.

New File Storage engine supports 100% backward compatibility, but downgrade won't be possible because of a new directory structure for the newest files. NoSQL File Storage can be used without reference to NoSQL database and for file operations only you can use FILESTORAGE(name_of_storage).method_name.

New helpful helpers:

Improved NoSQL performance

I have improved reading/updating performance of NoSQL database by about 20%.

Reading:

For example 100 000 simple documents like example below can be processed within 1 seconds. Reading introduces short CPU pausing, so it doesn't overload CPU.

Updating:

This version of NoSQL performs updates as the data are read. Older version always created a copy of modified NoSQL database, but new version performs all modifications as the file is read (just-in-time), so it's much more effective. Writing also introduces short CPU pausing, so it doesn't overload CPU. IMPORTANT: database can't corrupt DB files when the app is killed since it is designed for unexpected situations.

TABLE - an another NoSQL database

TABLE is a new plain text database like NoSQL embedded but the big difference is preddefined schema. In other words this TABLE DB can store data according to the schema and NOSQL can store schema-less data. It uses same methods/engine like NoSQL embedded but the performance is much more better around (20-30%) and this DB can save CPU, memory and HDD consuption. Table supports following data-types: number, string, boolean, date and object serialized to JSON format. TABLE DB also supports joins like NoSQL embedded database and worker.

Schema must be defined in the config:

NoSQL embedded can be used in cluster

I have added a simple support for using NoSQL embedded database in the cluster. Database performs locking when updating DB.

Improved middleware

Middleware supports new implementation like Total.js Schema operations. New implementation can simplify the code, for example:

Live reload

Live reload automatically reloads website without the need to manually refresh a web browser. It's very easy to enable, just edit debug.js in your app and add options.livereload = true + you need to update view layout.html like the example below.

debug.js

Layout:

Improved schemas

Schemas supports two new improvements: schema.setInsert() and schema.setUpdate().

Execution in controller's action:

Inline execution is very easy:

Schema field default value

This version of Total.js simplifies declaring default values for the specific field. It's very easy, just follow the code below:

Async schema operations can be async

This version supports async execution of operations in async execution. The example bellow will show you how:

OUTPUT:

A simple support for a promises because of async/await

But I don't recommend to use it for web applications because it's slower than the classic way:

NoSQL embedded database:

RESTBuilder:

Improved routing

I have improved routing a bit by adding two great improvements:

  • a HTTP method can be a part of route URL, for some developers this can be better solution than defining method in the flags
  • schema flags support @crud_workflow_operation_name, the framework will try to find an operation according to the name in the specified schema, it's not related to workflows file

Write less, do more:

With new dynamic operations you can easily check required fields in the schema directly, for example:

Routing groups:

Can be used in some special cases. I use groups in Total.js CMS for some plugins which are added dynamically as a part of CMS admin and CMS evaluates these routes only for logged-in admin users.

Improved CORS

I have updated CORS() method by adding a new feature which can help you with allowing CORS for all requests. Just execute the method without arguments:

And the framework tries to merge different CORS conditions to one because of performance. The code below generates usually ROUTE() method with cors flag:

Improved domain root changing

This improved feature will help you if you want to provide multiple Total.js apps on the same domain divided by path e.g. /eshop/, /cms/, /helpdesk/.

  • all attributes href and src will be modified by adding a new root path
  • View Engine supports @{#} command for adding of new root path (it will work in JS and CSS files)

Example:

Output:

Disabling the auto-remaping in a view:

Output:

Auto-generating names in "/versions" file

This feature downloads the file in the background and generates MD5 checksum + CRC32. Then it adds the hash to the URL. So from now you don't need to change filename in the /versions file.

Output will be as shown bellow:

JS and CSS supports a simple markup of view engine

This feature can be helpful in some special cases. It can replace a mark in the script or style directly.

Supports only:

  • config values @{config.key}
  • resource values @{resource('key')}
  • framework globals @{G.key} or F.global.key

yourscript.js:

yourstyle.css:

IMPORTANT: it also works with .html templates processed via LOCALIZE() method.

Improved JavaScript compressor

I have tuned JS compressor and now it optimizes multiple var declarations to one var declaration divided by , comma, so your resulting script will be smaller. Example:

Output:

Improved CSS compressor

Improved CSS compressor can optimize margin and padding values. Improvements can decrease your size of CSS. For understanding:

Output:

Improved UID

I have improved UID([group]) method by adding a new argument group which means a specific counter for defined group.

Convertors

Convertors are a new part of Total.js framework. A convertor is a simple method which can convert some data according to defined schema. Schema supports almost all types from Total.js Schemas. I have tuned convertors for the best performance.

What for?

Usage is very simple and really helpful for preparing some filters, etc..

RESTBuilder supports proxy

I have extend RESTBuilder by adding proxy option. Now you can use proxy directly in the RESTBuilder. Proxy supports http protocol only which can communicate with http and https endpoints.

Or you can set the proxy globally in the config:

Auto-generating security.txt

This version of Total.js can generate security.txt file automatically, contact information depends on your app configuration.

Nicer error response messages

I have improved UI of error response messages after 3 years and it complies 21 century. I keep simple and universal design combined in white and black color.

error-messages.gif

Improved unit-testing

I have added a new global method TESTUSER() for testing purposes. Declared user in this method will be used as an authorized user for all requests. Internally the method replaces F.onAuthorize delegate.

Conclusion

That's not all. I have performed hundreds of small improvements and fixes which make Total.js one of the best Node.js frameworks.

Total.js framework benefits:

  • you don't need to use a complicated stack like WebPack, Gulp, Grunt, etc.
  • you don't need any dependency, framework is smaller
  • you can write apps everywhere and you can only use a Notepad with Node.js platform
  • for small projects you can use powerful NoSQL embedded database
  • Total.js doesn't use any dependency and contains everything for creating much powerful applications (real-time, web, IoT, REST services, etc.)
  • Give a star on GitHub
  • Download complete apps

Sponsorship / Partnership

We're looking for stable sponsors and partners. Contact us if you or your company is interested in sponsorship / partnership with Total.js platform. Be a part of us!

Are you interested? Contact us: info@totaljs.com