Incident

kryo is another library for Node and browsers. It provides general-purpose schema definitions for data models. Its main use cases are data validation and serialization.

This is a library that went through a large amount of refactoring as my understanding of the issue evolved. It all started when I wanted to get an abstract data-storage service that would let me query data from the browser or server with the same syntax (shared service layer) while ensuring authorizations enforcement and data integrity. It turns out its not so easy. This library now only focuses on describing and enforcing a data model.

Serialization was previously tightly integrated with the data types previously. For example, the module defining the Date type also had the code to handle JSON, BSON and qs (GET parameters) serialization. This was easy but did not scale well due to the MxN problem (M types, N formats) and caused bloat when bundling methods serializing to formats that were not used. Since version 0.7.0, this is solved by abstracting de/serialization and moving JSON, BSON and qs support to other modules. This was inspired by Rust's serde library and should enable the addition of additional formats such as CBOR or focusing on interoperability with other libraries such as sequelize, ts-schema or protobuf.

This library is used in my other projects: it checks the values received by skype-http, describes the AST in swf-tree or handles data validation and serialization of eternalfest.