Server configuration.

interface IAppConfig {
    appDir?: string;
    auth?: ((session: Session<any>, next: ((err?: any) => void)) => void);
    autoprefixer?: any;
    babelTranspileModules?: string[];
    bundleAfterServerStart?: boolean;
    bundlePathRelative?: boolean;
    connectSocketAutomatically?: boolean;
    cookies?: {
        domain?: string;
        httpOnly?: boolean;
        sameSite?: string;
        secret?: string;
        secure?: boolean;
    };
    cookieSecret?: string;
    createMissingComponents?: boolean;
    cssDir?: string;
    dev?: boolean;
    entryFile?: string;
    envVars?: Record<string, any>;
    error?: {
        handler?: (<S>(err: any, req: IRequest<S>, res: IResponse, next: ((err?: any) => void)) => void);
        layout?: typeof Layout;
        page?: any;
    };
    errorHandler?: (<S>(err: any, req: IRequest<S>, res: IResponse, next: ((err?: any) => void)) => void);
    filename?: string;
    generatedComponentsExtension?:
        | "js"
        | "jsx"
        | "ts"
        | "tsx";
    getInitialData?: ((req: IRequest<Session<any>>) => {
        [key: string]: any;
    } | Promise<{
        [key: string]: any;
    }>);
    getTitle?: ((req: IRequest<Session<any>>) => string | Promise<string>);
    jsDir?: string;
    layoutComponent?: typeof Layout;
    locale?: {
        accepted?: string[];
        default?: string;
    };
    logging?: boolean;
    mergeStyles?: string[];
    onWebpackProgress?: ((percents: number, message: string) => void);
    port?: number;
    rsConfig?: string;
    scripts?: string[];
    session?: typeof Session;
    socketIO?: ServerOptions;
    socketMessageMaxSize?: number;
    sourceStylesDir?: string;
    staticDir?: string;
    styles?: string[];
    tsCompilerOptions?: CompilerOptions;
    webpack?: any;
}

Properties

appDir?: string

Relative path to the app directory.

'./app'
auth?: ((session: Session<any>, next: ((err?: any) => void)) => void)

Auth function called before the route execution.

Type declaration

    • (session, next): void
    • Parameters

      • session: Session<any>

        Session instance.

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

            • Optionalerr: any

            Returns void

      Returns void

(session, next) => next()
autoprefixer?: any

Custom autoprefixer config.

{}
babelTranspileModules?: string[]

List of modules to add to the babel-loader.

[]
bundleAfterServerStart?: boolean

Indicates if the server should be started before the webpack bundle. In that case bundling info page is rendered. @default: false

bundlePathRelative?: boolean

Indicates if the bundle is loaded relatively in the output html.

false
connectSocketAutomatically?: boolean

Indicates if the socket should be connected automatically after the bundle load.

true
cookies?: {
    domain?: string;
    httpOnly?: boolean;
    sameSite?: string;
    secret?: string;
    secure?: boolean;
}

Configuration for cookies.

Type declaration

  • Optionaldomain?: string

    The domain flag for the cookies.

    null
    
  • OptionalhttpOnly?: boolean

    HttpOnly flag for the cookies.

    The flag should be always true.

    null
    
  • OptionalsameSite?: string

    SameSite flag for the cookies.

    null
    
  • Optionalsecret?: string

    Secret which is used to sign cookies.

    '[random generated string]'
    
  • Optionalsecure?: boolean

    Secure flag for the cookies.

    null
    
cookieSecret?: string

Secret which is used to sign cookies.

null
createMissingComponents?: boolean

Indicates if registered components should be created if missing.

false
cssDir?: string

Name of the directory where the css is located in the staticDir.

'css'
dev?: boolean

Flag of the dev status of the app.

false
entryFile?: string

Relative path to the entry file.

null
envVars?: Record<string, any>

Client env variables.

error?: {
    handler?: (<S>(err: any, req: IRequest<S>, res: IResponse, next: ((err?: any) => void)) => void);
    layout?: typeof Layout;
    page?: any;
}

Definition of error handling

Type declaration

  • Optionalhandler?: (<S>(err: any, req: IRequest<S>, res: IResponse, next: ((err?: any) => void)) => void)

    Function to handle errors in the route execution.

    (err, req, res, next) => next()
    
      • <S>(err, req, res, next): void
      • Type Parameters

        Parameters

        • err: any
        • req: IRequest<S>
        • res: IResponse
        • next: ((err?: any) => void)
            • (err?): void
            • Parameters

              • Optionalerr: any

              Returns void

        Returns void

  • Optionallayout?: typeof Layout

    Error layout.

  • Optionalpage?: any

    Error page.

errorHandler?: (<S>(err: any, req: IRequest<S>, res: IResponse, next: ((err?: any) => void)) => void)

Function to handle errors in the route execution.

(err, req, res, next) => next()
filename?: string

Name of the bundle file.

'bundle.js'
generatedComponentsExtension?:
    | "js"
    | "jsx"
    | "ts"
    | "tsx"

Extension of the generated components.

'tsx'
getInitialData?: ((req: IRequest<Session<any>>) => {
    [key: string]: any;
} | Promise<{
    [key: string]: any;
}>)

Gets the request initial data.

getTitle?: ((req: IRequest<Session<any>>) => string | Promise<string>)

Gets the request title.

jsDir?: string

Name of the directory where the javascript is located in the staticDir.

'js'
layoutComponent?: typeof Layout

React component width default html code.

typeof Layout
locale?: {
    accepted?: string[];
    default?: string;
}

Locale settings.

Type declaration

  • Optionalaccepted?: string[]

    List of accepted locales.

    []
    
  • Optionaldefault?: string

    Default locale of the website. This locale will be used in default.json.

    'en-US'
    
logging?: boolean

Indicates if the server logs to the console.

true
mergeStyles?: string[]

List of styles to merge to rs-app.css.

[]
onWebpackProgress?: ((percents: number, message: string) => void)

Function to handle webpack progress.

null
port?: number

Port on which the app listens.

8080
rsConfig?: string

Custom path to rsconfig.json file.

null
scripts?: string[]

List of scripts loaded in the base html.

[]
session?: typeof Session

Class of the session.

typeof Session
socketIO?: ServerOptions

Custom socketIO config.

{}
socketMessageMaxSize?: number

Maximal size of one socket message.

104857600
sourceStylesDir?: string

Path to the directory containing source styles that are merged to app styles.

'./[staticDir]/[cssDir]'
staticDir?: string

Relative path to the static directory for the express app.

'./public'
styles?: string[]

List of styles loaded in the base html.

[]
tsCompilerOptions?: CompilerOptions

Additional TS compiler options.

webpack?: any

Custom webpack config.

{}