What is Thorin?

Thorin is a Node.js framework created by the team at Unloq, a passwordless security startup. The whole idea behind Thorin was to be able to have options, to be able to choose what modules you need and what modules you don’t. The thing is, you don’t always need all the features so why should you have to keep them all in one single package? Thorin was born from a modular idea, from the concept of creating modules for each task/function. This way you only need to install the modules you need, not everything all together in one single pack.

Thorin is the core module, the chassis of the framework, the one that binds all the other modules together.

thorin logo

Technical information: The core module abstracts away HTTP/TCP/WS requests, treating them as a set of input/output data. The transport provides the input data, (called an Intent, encapsulating the incoming request information, client IP, headers, etc) and passes it to the centralized dispatcher. The dispatcher will then route the intent through a set of authorization and middleware functions. The intent can be terminated (with success or error) in any of these functions (almost like express middlewares, but more complex). Once the intent is terminated, the transport will then know to return the result to the client (browser, device, etc).

Flux architecture (especially redux) was a great inspiration for the team behind Thorin. There are 4 main categories of modules in Thorin.js:

Transports (currently http and websockets) — abstract away the transport layer, providing the dispatcher with an intent.

(currently http and websockets) — abstract away the transport layer, providing the dispatcher with an intent. Stores (similar to MySQL, Redis, ElasticSearch) — wrappers over different store modules (Sequelize, Redis, elasticsearch) that provide better error handling, structure, auto-loading, connection handling, etc. (stores can be requested by calling thorin.store(“{storeName}”)

(similar to MySQL, Redis, ElasticSearch) — wrappers over different store modules (Sequelize, Redis, elasticsearch) that provide better error handling, structure, auto-loading, connection handling, etc. (stores can be requested by calling thorin.store(“{storeName}”) Plugins — these are modules that extend functionality of either the core module or other transports or stores. For example, thorin-plugin-render adds render capability to the HTTP transport, extending the intent/action class and using different render engines (currently nunjucks). The thorin-plugin-auth-password plugin adds authorization handlers that correctly handles user login (using scrypt, hashing passwords correctly, protecting against timing attacks, etc). Transports can be requested by calling thorin.transport(“{transportName}”). Plugins can be requested from anywhere by calling thorin.plugin(“{pluginName}”).

— these are modules that extend functionality of either the core module or other transports or stores. For example, thorin-plugin-render adds render capability to the HTTP transport, extending the intent/action class and using different render engines (currently nunjucks). The thorin-plugin-auth-password plugin adds authorization handlers that correctly handles user login (using scrypt, hashing passwords correctly, protecting against timing attacks, etc). Transports can be requested by calling thorin.transport(“{transportName}”). Plugins can be requested from anywhere by calling thorin.plugin(“{pluginName}”). Libraries — a basic set of additional code that can be used throughout the application. You can look at these libraries as singleton services, that do one thing and do it good. Libraries can be requested from anywhere by calling thorin.lib(“{libraryName}”)

Thorin.js is very adaptable and flexible as you will see during the training, basically anybody (yes, you too) can write their own module and integrate it with Thorin. No matter what you need — you can write a plugin for it!

You can check out all the Thorin modules on github here: https://github.com/Thorinjs

Thorin will be the topic of the first edition of helloJS Academy. Check out the event here!