Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Application

Map a Webda Application

It allows to:

  • Analyse imported modules
  • Scan code for Modda and generate the webda.config.json
  • Compile and Watch
  • Migrate from old configuration
  • List deployments

Hierarchy

  • Application

Constructors

  • new Application(file: string, logger?: WorkerOutput): Application

Properties

_loaded: string[] = []

Contains already loaded modules

appPath: string

Get Application root path

baseConfiguration: Configuration

Base configuration loaded from webda.config.json

compiled: boolean = false

Flag if application has been compiled already

currentDeployment: string

Current deployment

deployers: object

Deployers type registry

Type declaration

  • [key: string]: any
initTime: number

When the application got initiated

logger: WorkerOutput

Class Logger

namespace: string

Webda namespace

packageDescription: any

Contains package.json of application

packageWebda: any

Contains webda section of package.json and workspaces if exist

workspacesPath: string = ""

Detect if running as workspace

Methods

  • addDeployer(name: string, model: any): void
  • addModel(name: string, model: any): void
  • compile(): void
  • completeNamespace(name?: string): string
  • Return the full name including namespace

    In Webda the ServiceType include namespace Webda/Store or Webda/Test This method will make sure the namespace is present, adding it if no '/' is found in the name

    Parameters

    • Default value name: string = ""

    Returns string

  • extends(obj: any, className: any): boolean
  • generateModule(): void
  • getAppPath(subpath?: string): string
  • Return the application Configuration for a deployment

    Given this inputs:

    webda.config.json

    {
     "parameters": {
       "param3": "test"
     },
     "services": {
       "MyService": {
         "param1": {
           "sub": "test"
         },
         "param2": "value"
       }
     }
    }

    deployment.json

    {
     "parameters": {
       "param4": "deployment"
     }
     "services": {
       "MyService": {
         "param1": {
           "sub2": "deploymentSub"
         },
         "param2": "${package.version}"
       }
     }
    }

    The result would be:

    {
     "parameters": {
       "param3": "test",
       "param4": "deployment"
     },
     "services": {
       "MyService": {
         "param1": {
           "sub": "test",
           "sub2": "deploymentSub"
         },
         "param2": "1.1.0"
       }
     }
    }

    This map can also use parameters replaceVariables

    Parameters

    • Default value deploymentName: string = undefined

      to use for the Configuration

    Returns Configuration

  • getCurrentDeployment(): string
  • getDeployers(): object
  • getDeployment(deploymentName?: string): Deployment
  • getModel(name: string): any
  • getModels(): object
  • getPackageDescription(): any
  • getPackageWebda(): any
  • getPackagesLocations(): string[]
  • getServices(): object
  • getWebdaVersion(): string
  • getWorkerOutput(): WorkerOutput
  • hasDeployment(deploymentName: string): boolean
  • isTypescript(): boolean
  • loadJavascriptFile(absolutePath: string): void
  • loadLocalModule(): void
  • loadModules(): void
  • Load all imported modules and current module It will compile module Generate the current module file Load any imported webda.module.json

    Returns void

  • loadPackageInfos(): void
  • preventCompilation(compile: boolean): void
  • replaceVariables(object: any, replacements?: any): any
  • Allow variable inside object strings

    Example

    replaceVariables({
     myobj: "${test.replace}"
    }, {
     test: {
       replace: 'plop'
     }
    })

    will return

    {
     myobj: 'plop'
    }

    By default the replacements map contains

    {
     git: GitInformation,
     package: 'package.json content',
     deployment: string,
     now: number,
     ...replacements
    }

    See: GitInformation

    Parameters

    • object: any

      a duplicated object with replacement done

    • Default value replacements: any = {}

      additional replacements to run

    Returns any

  • resolveRequire(info: string): any
  • setCurrentDeployment(deployment: string): void
  • Set the current deployment for the application Call to getCurrentConfiguration will resolve to the computed configuration for the deployment If needed, you can call the method with undefined to reset to default configuration

    Parameters

    • deployment: string

      to set

    Returns void

  • stringParameter(templateString: string, replacements?: any): any
  • Allow variable inside of string

    Parameters

    • templateString: string

      to copy

    • Default value replacements: any = {}

      additional replacements to run

    Returns any

Object literals

appModule: object

Contains definitions of current application

deployers: object

Type declaration

models: object

Type declaration

services: object

Type declaration

cachedModules: object

Contains all definitions from imported modules and current code

deployers: object

Type declaration

models: object

Type declaration

services: object

Type declaration

sources: undefined[] = []
models: object

Models type registry

webda/coremodel: CoreModel = CoreModel
webda/ident: Ident = Ident
webda/user: User = User
webdacore/context: Context = Context
webdacore/securecookie: SecureCookie = SecureCookie
webdacore/sessioncookie: SessionCookie = SessionCookie
services: object

Services type registry

webda/asyncevents: EventService = EventService
webda/authentication: Authentication = Authentication
webda/configurationservice: ConfigurationService = ConfigurationService
webda/consolelogger: ConsoleLoggerService = ConsoleLoggerService
webda/debugmailer: DebugMailer = DebugMailer
webda/filebinary: FileBinary = FileBinary
webda/fileconfigurationservice: FileConfigurationService = FileConfigurationService
webda/filestore: FileStore = FileStore
webda/kubernetesconfigurationservice: KubernetesConfigurationService = KubernetesConfigurationService
webda/mailer: Mailer = Mailer
webda/memorylogger: MemoryLoggerService = MemoryLoggerService
webda/memoryqueue: MemoryQueue = MemoryQueue
webda/memorystore: MemoryStore = MemoryStore
webda/resourceservice: ResourceService = ResourceService

Generated using TypeDoc