Kamboja Option

Kamboja Option is configuration you can provide when instantiating KambojaJs application.

export interface KambojaOption {
    skipAnalysis?: boolean
    controllerPaths?: string[]
    modelPath?: string
    rootPath: string
    showLog?: "Info" | "Warning" | "Error" | "None"
    dependencyResolver?: DependencyResolver
    validators?: (ValidatorCommand | string)[]
    interceptors?: (RequestInterceptor | string | InterceptorFunction)[]
    autoValidation?: boolean

KambojaOption.rootPath (required)

Specify root path that will be used as relative position of controller, model, view etc. It also related to the Qualified Class Name.

For example the file structure is like below:

File structure


import { Kamboja } from "kamboja"
import { ExpressEngine } from "kamboja"

let kamboja = new Kamboja(new ExpressEngine(), { rootPath = <PATH> })
export {kamboja}

<PATH> on above code can be change using value below:

__dirname will make all path relative to src/index.ts, so the controller path will be controller, model path will be model. The Qualified Class Name for model is ModelName, model/model-file.

process.cwd() will make all path relative to the current executing nodejs. For example if executed in the root folder, the controller path will be src/controller Qualified Class Name for model is ModelName, src/model/model-file.

KambojaOption.skipAnalysis (optional)

Default value: false

This step will skip static analysis in the startup process. Not recommended on development process.

KambojaOption.showLog (optional)

Default value: Info

Hide or show the console log, including the static analysis console log. Not recommended to turn off on development process.

KambojaOption.controllerPaths (optional)

Default value: ["controller"]

Specify path of controllers, can be specify more than one. This configuration respect the KambojaOption.rootPath.

In some case you need to separate your controller and api controller you can provide an array [controller, api] then provide 2 folders controller and api

KambojaOption.modelPath (optional)

Default value: "model"

Specify path of model files, This configuration respect the KambojaOption.rootPath.

KambojaOption.dependencyResolver (optional)

Default value: Resolver.DefaultDependencyResolver

Specify dependency resolver used by KambojaJS. Dependency resolver is a way the system create/resolve the object its create (Controller, Model, Services etc).

Note You can specify custom dependency resolver by using dependency injection framework like Inversify. Refer to Dependency Injection for more information

KambojaOption.validators (optional)

Default value: undefined

Specify custom validator to validate the action parameters and the models.

KambojaOption.interceptors (optional)

Default value: undefined

Specify global request interceptors. Global interceptors will executed for every request even the request does not handled by a Controller. Technically for non handled url all global request interceptors will be called before the 404 error handler executed.

KambojaOption.autoValidation (optional)

Default value: true

Specify automatic validation response when request parameter/body doesn’t fit the validation rule defined in model. See also the effect of auto validation used in ApiController