App

Appolo app contains all the application context. it can be injected to any class and exists on every request

The app can be injected to any class.

@define()
export class FooManager{
@inject() app:App
}

or accessed from req controller or middleware

@define()
export class FooManager{
@controller()
export class LoginController extends Controller{
@post("/login/")
public async loginUser(req:IRequest,res:IResponse){
//req.app.options
}
}
}

Usage#

options#

app.options:IOptions#

getter returns the launch options.

app.options.port // 8080

set#

app.set(name: keyof IOptions, value: any)#

set any app option. app.set("port",8080) // 8080

env#

app.env: IEnv#

getter return the current env

app.env.name // production

tree#

app.tree#

return methods to traverse app child modules.

module#

app.module#

return methods to handle loading of modules.

discovery#

app.discovery#

return methods to handles exported modules files and custom decorators.

dispatcher#

app.Dispatcher#

return global event dispatcher.

injector#

app.injector :Injector#

return app injector instance

app.injector.get("someObject")

launch#

app.launch():Promise<App>#

launch the app and return the app instance when finished

var {createApp} from '@appolo/core';
(function async (){
let app = await createApp().launch();
})()

reset#

app.reset():Promise<void>#

reset the app clean all assets and closes the server

server#

server(): http.Server | https.Server#

return the http server instance