Component loading and registration

You can load up any kind of Thorin component, by calling the appropriate registration function.

thorin.addTransport(transport, name)
Registers the given transport component inside your Thorin app
  • transportstring* | transportObj*either the class that extends thorin.Interface.Transport, or the full name of the transport and Thorin will try to perform require(transport).
  • namestringoverride the default transport name and use this one in stead.
thorin.addStore(store, name)
Registers the given store component inside your Thorin app
  • storestring* | storeObj*either the class that extends thorin.Interface.Store or the full name of the store module, as Thorin will try to perform require(store).
  • namestringoverride the default store name and use this one in stead or create multiple instances from the given store component (see example below)
thorin.addPlugin(plugin, name, opt)
Registers the given plugin in your Thorin application. You can override its default name and pass any kind of contextual options. The opt object will override any application-level configuration for the plugin.
  • pluginstring* | function*either the plugin function or the full name name of the plugin, as Thorin will try to perform require(name). If a function, it will be called with fn(thorin, opt, name)
  • namestringoverride the default plugin name and use this one in stead
  • optobjectprovide inline options for the plugin.
Registers a custom error parser inside your thorin app. Error parsers are used when an error is encountered inside the application to alter the information that it will expose to the end user.
  • fnfunction*the error parser function that will be called with an error as the first argument
Registers the given custom sanitizers inside your thorin app
  • itemsclass* | array<class>*the custom sanitizer class or an array of classes that extends thorin.Interface.Sanitizer
thorin.addLibrary(module, name)
Registers your libraries inside your thorin app.
  • modulestring* | function*either the name of the library, the library object or the library constructor function.
  • namestringwhen provided, the name of the library.
If you call addLibrary(module) with no name and module as an object or constructor function, the name of the library will be taken from
Ways of calling:
thorin.addLibrary(module=string) // it will perform require(module);
thorin.addLibrary(module=function, name=string) // use the constructor function with a specific name
thorin.addLibrary(module=string, name=string) // it will perform require(module) and register the library with the given name
thorin.addLibrary(module=function) // it will register the the library using the module's or
'use strict';
const thorin = require('thorin');
   .addStore(require('thorin-store-redis'), 'sessionDb', 'cacheDb')
   .addPlugin(require('thorin-plugin-less'), {
      watch: true
   .addLibrary('app/lib/myLib.js', 'myLib');;
Do you have a question or is something missing?

You can always create a new issue on GitHub or contact one of the core founders by chat.