Base server application.

Constructors

Properties

appDir: string

Relative path to the application directory.

appDirAbsolute: string

Absolute path to the application directory.

bundlePath: string

Bundle path in the website structure.

bundlePathAbsolute: string

Absolute path to the bundle file in the application structure.

bundling: boolean

Indicates if the webpack is bundling.

dev: boolean

Indicates if the app is in DEV mode.

Layout: Element

JSX class for the layout component.

nonce: string

CSP nonce.

path: string

Absolute path to the javascript directory for the webpack config.

port: number

Port number where the app listens.

Session: typeof Session

Session class.

staticDir: string

Relative path to the static dir.

staticDirAbsolute: string

Absolute path to the static dir.

Text: Text

Instance of the Text.

version: string

App version.

Methods

  • Authorizes the user.

    Parameters

    • session: Session<any>

      Current session.

    • next: ((err?: any) => void)

      Callback after the auth process.

        • (err?): void
        • Parameters

          • Optionalerr: any

          Returns void

    Returns void

  • Creates a file in RS directory.

    Parameters

    • filename: string

      Name of the file.

    • data: string | Buffer | (() => Promise<string | Buffer>)

      File content of async function to get the content.

    Returns this

  • Gets the filename of the dictionary file in the resources directory.

    Parameters

    • locale: string

      Locale to check.

    Returns string

  • Gets the text from the locale dictionary.

    Parameters

    • locale: string
    • key: string
    • Rest...args: any[]

    Returns string

  • Gets the installed plugin by its name.

    Type Parameters

    Parameters

    • name: string

      Name of the plugin.

    Returns T

  • Gets the list of registered components.

    Returns {
        auto: boolean;
        elementId: string;
        path: string;
    }[]

  • Gets the instance of the server.

    Returns Server<typeof IncomingMessage, typeof ServerResponse>

  • Injects the code to the generated entry file.

    Parameters

    • code: string

      Javascript code to inject.

    Returns this

  • Checks if the locale is default locale.

    Parameters

    • locale: string

      Locale to check.

    Returns boolean

  • Logs the error in the stderr.

    Parameters

    • tag: string

      Tag of the message.

    • message: string

      Message.

    • Rest...args: any[]

      Another arguments to log.

    Returns void

  • Logs the info in the stdout.

    Parameters

    • tag: string

      Tag of the message.

    • message: string

      Message.

    • Rest...args: any[]

      Another arguments to log.

    Returns void

  • Logs the warning in the stdout.

    Parameters

    • tag: string

      Tag of the message.

    • message: string

      Message.

    • Rest...args: any[]

      Another arguments to log.

    Returns void

  • Registers the callback executing before the route execution.

    Type Parameters

    Parameters

    • spec: string

      Route specification. If '*' is used the callback is called for every route.

    • callback: ((req: R, res: IResponse) => Promise<void>)

      Callback to execute before the route execution.

        • (req, res): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns this

  • Registers component.

    Parameters

    • componentPath: string

      Absolute path or relative path to the component from the app directory.

    • elementId: string

      Id of the element in the layout where the component should be rendered.

    Returns this

  • Registers component.

    Parameters

    • componentPath: string

      Absolute path or relative path to the component from the app directory.

    • elementId: string

      Id of the element in the layout where the component should be rendered.

    • auto: boolean

      Indicates if the component's wrapper should be automatically rendered in the layout's body.

    Returns this

  • Registers the component error handler. It catches all react errors.

    Parameters

    • path: string

      Absolute path or relative path to the error handler.

    Returns this

  • Registers the component provider. All components rendered with the application are wrapped with this provider.

    Parameters

    • path: string

      Absolute path or relative path to the component provider.

    Returns this

  • Registers the error page.

    Parameters

    • componentPath: string

      Relative path to the component from the app directory.

    Returns this

  • Registers the middleware.

    Parameters

    Returns this

  • Registers the middleware.

    Parameters

    • middleware: ((server: default) => ((req: IRequest<Session<any>>, res: IResponse, next: ((err?: Error) => void)) => void))

      Middleware to register.

    • afterRoutes: boolean

      Indicates if the middleware should be executed after the routes register.

    Returns this

  • Parameters

    • method: HttpMethod
    • route: string
    • contentComponent: string
    • title: string

    Returns this

  • Parameters

    • method: HttpMethod
    • route: string
    • contentComponent: string
    • title: string
    • requireAuth: boolean

    Returns this

  • Registers route.

    Parameters

    • method: HttpMethod
    • route: string
    • contentComponent: string
    • title: string
    • requireAuth: boolean
    • callback: Function

    Returns this

  • Registers route.

    Parameters

    • method: HttpMethod
    • route: string
    • contentComponent: string
    • title: string
    • requireAuth: boolean
    • layout: string | typeof Layout
    • callback: Function

    Returns this

  • Registers callback to route registered with rsconfig for GET method.

    Parameters

    • route: string

      Route spec.

    • callback: RouteCallback

      Callback to call when the route is called.

    Returns this

  • Registers callback to route registered with rsconfig.

    Parameters

    • method: HttpMethod

      HTTP method.

    • route: string

      Route spec.

    • callback: RouteCallback

      Callback to call when the route is called.

    Returns this

  • Registers the socket event.

    Parameters

    • event: string

      Name of the event.

    • listener: ((socket: Socket<Session<any>>, data: any, next?: ((err?: any, data?: any) => void)) => void | Promise<any>)

      Listener executed in the event.

        • (socket, data, next?): void | Promise<any>
        • Parameters

          • socket: Socket<Session<any>>
          • data: any
          • Optionalnext: ((err?: any, data?: any) => void)
              • (err?, data?): void
              • Parameters

                • Optionalerr: any
                • Optionaldata: any

                Returns void

          Returns void | Promise<any>

    Returns this

  • Starts the application. It creates bundle in the process.

    Returns Promise<void>

  • Starts the application. It creates bundle in the process.

    Parameters

    • cb: ((err?: any) => void)

      Callback called after the application is started.

        • (err?): void
        • Parameters

          • Optionalerr: any

          Returns void

    Returns Promise<void>

  • Starts the application. Bundle creation depends on the skipBundle parameter.

    Parameters

    • skipBundle: boolean

      Indicates if the bundle creation should be skipped in the start process. It means bundle is already created with bundle method.

    • cb: ((err?: any) => void)

      Callback called after the application is started.

        • (err?): void
        • Parameters

          • Optionalerr: any

          Returns void

    Returns Promise<void>

  • Stops the application.

    Returns void

  • Stops the application.

    Parameters

    • Optionalcb: ((err?: Error) => void)

      Callback called after the server stopped.

        • (err?): void
        • Parameters

          • Optionalerr: Error

          Returns void

    Returns void