Home Reference Source Test Repository
import Trek from 'trek/src/Trek.js'
public class | source

Trek

Extends:

KoaEngine → Trek

Construct a Trek (app) instance

Static Member Summary

Static Public Members
public static get

env: Boolean: *

Returns the current Trek environment
public static get
Returns true if current environment is `development`
public static get
Returns true if current environment is `production`
public static get
Returns true if current environment is `test`
public static get

logger: winston.Logger: *

Gets Trek's logger
public static set

logger(logger: Object): void: *

Sets Trek's logger
public static get
Returns Trek package information
public static get
Returns Trek current version

Inherited Summary

From class Engine
public get

logger: winston.Logger: *

The app `logger`
public get

path: String: *

Get the app prefix path
public get

paths: Paths: *

The `config.paths` delegation
public get
The app working `rootPath` directory
public set

rootPath(root: String): *

Set a working `rootPath` directory for app
public get

routeMapper: RouteMapper: *

Get route mapper.
public get
Get all servides
public

body: *

public

cache: *

public

config: *

public

context: *

public

engines: *

public

env: *

public
public
public
public

router: *

public

server: *

public

state: *

public

all(path: String, handler: GeneratorFunction[]): Engine

Special-cased "all" method, applying the given route `path`, middleware, and handler to _every_ HTTP method.
public

* bootstrap(): void

Boot the app
public
Register the given template engine callback `fn` * as `ext`.
public
Serves the default favicon - GET /favicon.ico
public

getService(key: String): *

Get a service by key
public

index(file: String, options: Object): Engine

Index serves index file
public

* loadServices(): void

Load services
public

match(methods: String[], path: String, handler: GeneratorFunction[]): Engine

Match adds a route > handler to the router for multiple HTTP methods provided
public

* render(view: String, options: Object): String

Render `view` with the given `options`
public

run(args: *): Promise

Run the app
public

serveDir(path: String, dir: String, options: Object): Engine

Serves files from a directory
public

serveFile(path: String, file: String, options: Object): Engine

Serves a file
public

set(key: *, value: *): Engine

Stores the `value` with `key` into `app.config`
public

setService(key: String, service: *): void

Stores a service
public

static(path: String, dir: String, options: Object): Engine

Serves static files from a directory.

Static Public Members

public static get env: Boolean: * source

Returns the current Trek environment

Override:

Engine#env

Return:

Boolean

Example:

 Trek.env
 // => development | production | test

public static get isDevelopment: Boolean: * source

Returns true if current environment is development

Return:

Boolean

public static get isProduction: Boolean: * source

Returns true if current environment is production

Return:

Boolean

public static get isTest: Boolean: * source

Returns true if current environment is test

Return:

Boolean

public static get logger: winston.Logger: * source

Gets Trek's logger

Override:

Engine#logger

Return:

winston.Logger

public static set logger(logger: Object): void: * source

Sets Trek's logger

Override:

Engine#logger

Return:

void

public static get package: Object: * source

Returns Trek package information

Return:

Object

public static get version: String: * source

Returns Trek current version

Return:

String