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

Class: Bridge

Bridge

new Bridge(app)

The Bridge module compiles Mustache templates to client-side JavaScript libraries in the build phase. All JavaScript is concatenated in a single fire.js file.

Modules can extend Bridge's functionality by including a generator method which returns a Generator instance. For example:

function MyModule(app) {
    this.app = app;
}

MyModule.prototype.generator = function() {
    return new this.app.bridge.Generator(path.join(__dirname, 'templates', this.app.settings('type'), 'my-module.js'), {
        // Module data here.
    });
};
Parameters:
Name Type Description
app App

The app which loads this module.

Members

Generator

Exposes the Generator constructor. This is useful for modules implementing the generator method.

<inner> generateFireControllers

Generates all controller services and all local routes for the angular-route module.

<inner> generateFireInit

Generates the initial angular.Module and all the methods like angular.directive(...).

<inner> generateLocalControllers

Generates the client-side angular controllers from the controllers' constructor's.

function TestController($scope) {
    $scope.test = function() {
        console.log('test');
    };
}
app.controller(TestController);

Roughly generates:

app.controller('TestController', ['$scope', function($scope) {
    $scope.test = function() {
        console.log('test');
    };
}]);

<inner> generateModels

Generates a client-side library to manage your models with a 1-to-1 API as the models api on the server-context.

For more information on the API itself, see the Models module.

Methods

generate(writeStream)

Generates the client-side fire.js by executing all generators local in ./generators.

In addition, every module may provide a generator if it implements a generator method. Bridge loops over every module and executes it's generator method (if it exists). The generator method should return an instance of Generator.

Please note: this method will close the write stream by calling fs.WriteStream#end once it succeeds.

Parameters:
Name Type Description
writeStream fs.WriteStream

An opened stream to write to.

Returns:

Resolves when succeeded. Rejects when fails.

Type
Promise

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