EggCore

EggCore

new EggCore(options)

Parameters:
Name Type Description
options Object

options

Properties
Name Type Description
[ baseDir = process.cwd() ] String

the directory of application

[ type = application|agent ] String

whether it's running in app worker or agent worker

[ plugins ] Object

custom plugins

Since:
  • 1.0.0
Source:

Members

BaseContextClass :BaseContextClass

Since:
  • 1.0.0
Source:

baseDir :String

The current directory of application

Since:
  • 1.0.0
Source:
See:

config :Config

The configuration of application

Since:
  • 1.0.0
Source:

Controller :Controller

Retrieve base controller

Since:
  • 1.0.0
Source:

deprecate :function

Since:
  • 1.0.0
Source:

loader :EggLoader

The loader instance, the default class is EggLoader. If you want define

Since:
  • 1.0.0
Source:

name :String

The name of application

Since:
  • 1.0.0
Source:
See:

plugins :Object

Retrieve enabled plugins

Since:
  • 1.0.0
Source:

router :Router

get router

Since:
  • 1.0.0
Source:

Service :Service

Retrieve base service

Since:
  • 1.0.0
Source:

type :String

Whether application or agent

Since:
  • 1.0.0
Source:

Methods

beforeClose(fn)

Register a function that will be called when app close

Parameters:
Name Type Description
fn function

the function that can be generator function or async function

Source:

beforeStart(scope)

Execute scope after loaded and before app start

Parameters:
Name Type Description
scope function | GeneratorFunction | AsyncFunction

function will execute before app start

Source:

close() → {Promise}

Close all, it wil close

  • callbacks registered by beforeClose
  • emit close event
  • remove add listeners

If error is thrown when it's closing, the promise will reject. It will also reject after following call.

Since:
  • 1.0.0
Source:

url(name, params) → {String}

Alias to Router#url

Parameters:
Name Type Description
name String

Router name

params Object

more parameters

Source:

use(fn) → {Application}

override koa's app.use, support async function

Parameters:
Name Type Description
fn function

middleware

Since:
  • 1.0.0
Source: