1 of 26

Thorin.js

A real-world framework for Node.js

2 of 26

Adrian Bunta

github.com/snupa

github.com/thorinjs

  • CTO, UNLOQ
  • Node.js enthusiast
  • Started in 2010
  • Projects
    • Online Multiplayer RTS in the browser
    • Ad bidding platform
    • Social platform
    • Mobile-app backend
    • UNLOQ
    • SConfig
    • Loglet

3 of 26

Who are we?

  • UNLOQ.io
    • Passwordless authentication
    • Personal encryption keys
  • Sconfig.io
    • Encrypted application configuration storage
    • Built-in thorin-friendly discovery system
    • Firewall & access management
  • Loglet.io
    • Encrypted centralized log management
    • Livestream application logs

4 of 26

Kickoff

github.com/thorinjs

hellojs.org

UNLOQ.io

sconfig.io

loglet.io

  1. Who we are & what we do
  2. Current stack
  3. Thorin technical overview
  4. Component presentation
  5. Real-world use cases
  6. Traditional TODO app
  7. Overclock the TODO app
  8. QA & Conclusions

5 of 26

Lessons learned

  • One module to rule them all
  • Monolithic architecture
  • Code duplication
  • Limited DI
  • Tie resources to views

6 of 26

Current stack & views

  • React + tredux + less + webpack
  • Node.js + Thorin.js + pm2 + nginx
  • MySQL / MariaDB + ElasticSearch + Redis
  • Microservice oriented
  • Stateless applications
  • K.I.S.S.

7 of 26

What’s Thorin.js?

  • Node.js framework
  • Build rapid scalable real-world apps
  • Power stands in its components
  • Designed with usability & microservices in mind
  • Focus on the product

8 of 26

Why Thorin.js?

  • Powerful and extendable core
  • Simple integration with other services
  • Production-ready setup with our tools
  • Components that integrate with your use case
  • Built on top of other tested frameworks
  • Focus on functionality, not on integrating with services

9 of 26

Out-of-the-box

  • Config loading
  • Global logger & namespaced logging
  • Input sanitization / convertor
  • Environment-aware
  • Centralized dispatcher for request handling
  • Action encapsulation, definition and specification
  • Intent abstractization
  • Authorisation & middleware support

10 of 26

Building blocks

Transports

Stores

Sanitizers

Libraries

Plugins

Actions

Intents

Authorization & middleware func

Error handlers & transforms

Utilities

11 of 26

Booting & component lifecycle

Booting up

  • Sanitizers
  • Stores
  • Libraries
  • Transports
  • Plugins

Lifecycle

  • Prepare env & config
  • Register our components
  • Components get constructed
  • Call init() forEach component
  • If in setup, call setup(fn)
  • Call run(fn) forEach component

12 of 26

Information flow

13 of 26

Current Thorin.js components 1/3

Thorin-transport-http

Thorin-transport-ws

Thorin-store-sql

Thorin-store-redis

Thorin-store-elastic

14 of 26

Current Thorin.js components 2/3

Plugin-auth-unloq

Plugin-auth-password

Plugin-auth-history

Plugin-discovery

Plugin-docs

Plugin-geo

Plugin-less

Plugin-sass

Plugin-loglet

Plugin-mail

Plugin-queue

Plugin-render

15 of 26

Current Thorin.js components 3/3

Plugin-session

Plugin-stripe

Plugin-static-html

Plugin-tasks

Plugin-upload

Plugin-utils

Client-side helper components

  • Thorin-fetch
  • Thorin-fetch-ws
  • Tredux
  • tri18n

16 of 26

Use case

  1. TODO App

Dependencies:

  • Thorin-transport-http
  • Thorin-store-sql
  • Thorin-plugin-auth-password
  • Thorin-plugin-render

17 of 26

Use case

  1. Mailing app

Dependencies:

  • Thorin-transport-http
  • Thorin-plugin-discovery
  • Thorin-plugin-mail
  • Thorin-plugin-render
  • Thorin-plugin-less ?

18 of 26

Use case

  1. CRUD App with file upload

Dependencies:

  • Thorin-transport-http
  • Thorin-store-sql
  • Thorin-plugin-upload
  • Thorin-plugin-upload-aws
  • Thorin-plugin-docs ?

19 of 26

Use case

  • Chat application

Dependencies:

  • Thorin-transport-ws
  • Thorin-store-redis
  • Thorin-plugin-session
  • Thorin-plugin-tasks

20 of 26

Use case

  • Static HTML site

Dependencies:

  • Thorin-transport-http
  • Thorin-plugin-render
  • Thorin-plugin-(less|sass)
  • Thorin-plugin-static-html

21 of 26

Case study

Loglet.io infrastructure design

22 of 26

Q&A

1/4

23 of 26

Q&A

2/4

24 of 26

Q&A

3/4

25 of 26

Q&A

4/4

26 of 26