Subscribe to our list to receive the latest updates on Node on Fire

Class: Firestarter

Firestarter

new Firestarter()

The isomorphic fire service. This service is available in both the front- and the back-end.

The service contains two methods to check at runtime whether your code is running on the client- or the server-side, respectively, Firestarter#isClient and Firestarter#isServer.

The below example illustrates the usage of the service:

app.run(function(fire) {
    if(fire.isServer()) {
        // The server.
    }
    else {
        // The client.
    }
});

On the back-end, the service is also responsible for orchastrating the modules and apps. You do not need to construct an instance of fire yourself.

Methods

app(id, name, settings)

Creates a new or returns an existing App.

If a options is specified, a new app will be created. If an app with the same id already exists, an exception is thrown.

If options is not specified, an existing app will be retrieved. If no app with id exists, an exception is thrown.

For example, to create a new app:

var app = require('fire')('nodeonfire.org', {type: 'angular'});

//

It's possible to create multiple apps which share models and other modules, but serve a different purpose. For example, you can create an admin section and the user-facing app all in the same codebase.

// Create the user-facing app
var app = require('fire')('nodeonfire.org', 'web', {type: 'angular'});

// Create an admin app
var adminApp = require('fire')('nodeonfire.org', 'admin', {type: 'angular'});

In the build and run phase you set the NODE_APP environment variable to specify which app to return.

If you retrieve an app without a name and the NODE_APP is set, that app is returned. If NODE_APP is not set, an app named default is returned.

Parameters:
Name Type Description
id String

The identifier of the app passed to the App constructor. This is usually the app's domain e.g. nodeonfire.org.

name String

The name of the app, defaults to 'default'.

settings Dictionary

Passed directly to the app constructor. See App for more information.

Returns:

The newly created or existing app.

Type
App

isClient()

Returns true if the code is running on the client-side.

isServer()

Returns true if the code is running on the server-side.

Do you have any questions or comments on this page? Start a discussion below.

comments powered by Disqus
Subscribe to our list to receive the latest updates on Node on Fire