Controller is like a section or area where different resource & services are available.

e.g - A Fort may have sections - WeaponSection, LibrarySection, MeetingSection etc.

Now consider a real world application created for university may have sections - StudentSection, TeacherSection, LibrarySection etc.

A controller has following members -

Creating controller

Controller is a class which extends the class "Controller" from fortjs.


import { Controller } from "fortjs";

export class UserController extends Controller {


In order to make this controller active, you need to assign it to routes where you have bootstrapped your app.

import { Fort } from "fortjs";
import { UserController } from "./controllers";

class App extends Fort {
    constructor() {
        this.routes = [{
            controller: UserController,
            path: "/user"

In the code we are adding our controller into routes array along with a path. The path is used to associate the controller with a top level route.

e.g - Consider your website is , so when user hits the url - "" then the controller - 'UserController' will be called.

Note :- You must have worker inside the controller otherwise it wont work.