App
General application parameters.
config
_app.config() : Values
Description
Obtains the application configuration data present in the file in the config folder.
How To Use
// Returns the name of the app configured in config/_[environment].json
const appName = _app.config().getString("name");
_out.println(`App Name: ${appName}`);
Return
( Values )
Returns a structure with the configuration parameters.
configReloaded
_app.configReloaded() : boolean
Description
Checks whether the application configuration has been changed.
How To Use
// Validates whether the configuration has been changed.
if (_app.configReloaded()) {
_out.println(`App config is up to date.`);
}
Return
( boolean )
Returns whether the configuration was changed and reloaded.
file
_app.file(path: string) : File
Description
Processes files within the application.
How To Use
// Load the full path of the Logo:
const logo = _app.file("public/images/logo.png");
_out.println(`<p>Full logo path: ${logo.fullPath()}</p>`);
// Creates the JSON file within the app at public/data.json:
_app.file("public/data.json").output().writeAndClose(
_val.map()
.set("result", true)
.toJSON(2)
)
// Load the JSON file into the app at public/data.json:
const jsonFile = _app.file("public/data.json")
if (jsonFile.exists()) {
const data = _val.fromJSON(
jsonFile.input().readAllAndClose()
)
_out.println(`<p>JSON Result: ${data.getString("result")}</p>`)
}
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
path | string | Relative file path within the application. |
Return
( File )
Returns the file object obtained through the path.
folder
_app.folder(path: string) : File
Description
Tracks all the files present in the folder of the inserted path.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
path | string | Path of the file. |
Return
( File )
Returns all files present in the folder of the inserted path.
getConfig
_app.getConfig() : Values
Description
Obtains the application configuration data present in the file in the config folder.
How To Use
// Returns the name of the app configured in config/_[environment].json
const appName = _app.config().getString("name");
_out.println(`App Name: ${appName}`);
Return
( Values )
Returns a structure with the configuration parameters.
getFile
_app.getFile(path: string) : File
Description
Processes files within the application.
How To Use
// Load the full path of the Logo:
const logo = _app.file("public/images/logo.png");
_out.println(`<p>Full logo path: ${logo.fullPath()}</p>`);
// Creates the JSON file within the app at public/data.json:
_app.file("public/data.json").output().writeAndClose(
_val.map()
.set("result", true)
.toJSON(2)
)
// Load the JSON file into the app at public/data.json:
const jsonFile = _app.file("public/data.json")
if (jsonFile.exists()) {
const data = _val.fromJSON(
jsonFile.input().readAllAndClose()
)
_out.println(`<p>JSON Result: ${data.getString("result")}</p>`)
}
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
path | string | Relative file path within the application. |
Return
( File )
Returns the file object obtained through the path.
getFolder
_app.getFolder(path: string) : File
Description
Tracks all the files present in the folder of the inserted path.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
path | string | Path of the file. |
Return
( File )
Returns all files present in the folder of the inserted path.
getName
_app.getName() : string
Description
Gets the name of the application.
How To Use
const appName = _app.name();
Return
( string )
Returns the name of the application.
getPathBase
_app.getPathBase() : string
Return
( string )
getPathConfig
_app.getPathConfig() : string
Return
( string )
getPathHome
_app.getPathHome() : string
Return
( string )
getPathPublic
_app.getPathPublic() : string
Return
( string )
getPathServer
_app.getPathServer() : string
Return
( string )
getPathStorage
_app.getPathStorage() : string
Return
( string )
getSettings
_app.getSettings() : Values
Description
Obtains the application settings data present in the file of the config.
How To Use
// Returns the custom settings that are in config/_[environment].json
// in ... "settings": { "maxTickets": 8 }
const maxTickets = _app.settings().getString("maxTickets");
_out.println(`The maximum limit for tickets is: ${maxTickets}`);
Return
( Values )
Returns the custom settings.
getUrl
_app.getUrl() : string
Description
Gets the application url.
How To Use
const urlDaApp = _app.url();
Return
( string )
Returns the URL of the application.