Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Commit

Permalink
Merge 23e3872 into 2eb8a76
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzmor committed Apr 18, 2017
2 parents 2eb8a76 + 23e3872 commit 1ca8e94
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/guide/application-lifecycle.md
Expand Up @@ -8,18 +8,18 @@ layout: guide.hbs
---

This guide outlines the lifecycle of the backend side of a Zeroth application, as the frontend lifecycle is just standard
Angular 2.
Angular 2.

## Startup
Like the frontend, bootstrapping the application happens both in the `main.ts` section of the project, and in the core
module. The core handles the loading, registration and bootstrapping of both core components and the components that
module. The core handles the loading, registration and bootstrapping of both core components and the components that
are defined in the application.

To kick off the server, the entry javascript file will require the exported `bootstrap()` function. In production, this
file would be the `./lib/server/server/bootstrap.js` file. In development, this bootstrapping is handle by the cli,
as it extends the capabilities of the before start to allow the webpack dev sever to run and the file watchers to start
detecting changes.

### 1. Configuration
When first loaded, the `dotenv` library looks for a `.env` file in the current working directory, and exports all variables
to `process.env`. For more info, see the [Configuration Section](/guide/configuration) of the guide
Expand All @@ -29,6 +29,7 @@ Next, all of the entities of the application are loaded. In your `main.ts` file,
```typescript
import * as models from '../common/models';
import * as controllers from './controllers';
import * as seeders from './seeders';
import * as migrations from './migrations';

let loadClasses = [
Expand Down Expand Up @@ -59,12 +60,12 @@ array. A general rule of thumb is that if a class uses an entity decorator like
needs to be imported into the `loadClasses` array. All of the entity decorators are bootstrapped and registered with the
injector separately, so they do not need to be in the providers array. You would only want to explicitly provide a decorated
entity if you are substituting an implementation, or have some funky factory requirements.

### 4. Bootstrap
The bootstrapping is in itself a multi-phase process. The core exports a `bootstrap` function, which is invoked with the
entities and providers defined above.
1. The bootstrapping is deferred until all provider promises have resolved. If *any* are rejected, bootstrapping is aborted.
1. Specialist bootstrappers for each Entity type (models, migrations, seeders, controllers) retrieve the injectable instances
1. Specialist bootstrappers for each Entity type (models, migrations, seeders, controllers) retrieve the injectable instances
from the core registry and when appropriate, resolve them with the `ReflectiveInjector`
1. A new `injector` instance is created using the passed providers and newly resolved entities
1. Any logs that have been buffered up to this point are output with the newly resolved concrete `Logger` implementation
Expand Down

0 comments on commit 1ca8e94

Please sign in to comment.