chevron_right
chevron_right
chevron_right
chevron_right
chevron_right
chevron_right
chevron_right
chevron_right
chevron_right
chevron_right

Components are most important part of fort application. They are independent & every component has its own lifecycle and scope. It helps you to modularize your app & reutilize codes.

There are three types of components -

  1. Wall

  2. Shield

  3. Guard

Concept

FortJs Architecture

The above picture shows the architecture of fortjs app and flow of http request inside app -

  • When a http request comes to your app - it has to go through sequence of components i.e Wall, Shield & Guard and if everyone allows then request is transferred to Worker inside Controller where the actual resource is present.
  • The Http Request has to first go through component Wall. The incoming event of wall is called and if wall
    • Allows - It is sent to next lower level component which is Shield
    • Rejects - The result is considered as final result and result is sent as http response & its lifecycle is ended there.
  • After Wall allows the request, it is sent to Shield and if shield
    • Allows - It is sent to next component which is Guard
    • Rejects - The result is considered as final result. The result has to go through wall outgoing event and finally http response is sent.
  • After Shield allows - the request is allowed to go inside Controller & control is transferred to Guard & if guard
    • Allows - It is sent to Worker where the actual resource is present.
    • Rejects - The result is considered as final result. The result has to go through wall outgoing event and finally http response is sent.


Important points


  • It is not necessary to create any components, you can have just Controller and Worker. But it is highly recommended to use components since components helps to modularize your app into small dedicated features making your code cleaner, reutilizable & testable.

  • Here we saw Components are being used to block the request, but it can be also used to do some work and pass the result from one component to another. Check out particular component to know more.

e.g - The validation of data, extracting some information like ip address & passing from one component to another etc.