App

API ReferenceApp

Source


app.config

Static property of
app
Type
Object
Default
{}

Config object from the package.json file.

Can be overriden in the init.js file.

type

The app type (the default one) uses renderer on the client side.

The game type uses special renderer (if exists) focused on more performance goals.

The text type always return HTML document with no renderer on the client side. It's used for the crawlers (e.g. GoogleBot) or browsers with no javascript support.

// package.json
{
    "name": "neft.io app",
    "version": "0.1.0",
    "config": {
        "title": "My first application!",
        "protocol": "http",
        "port": 3000,
        "host": "localhost",
        "language": "en",
        "type": "app"
    }
}
// init.js
module.exports = function(NeftApp) {
    var app = NeftApp({ title: "Overridden title" });
    console.log(app.config);
    // {title: "My first application!", protocol: "http", port: ....}
};

Source


app.networking

Static property of
app
Type
Networking

Standard Networking instance used to communicate with the server and to create local requests.

All routes created by the App.Route uses this networking.

HTTP protocol is used by default with the data specified in the package.json.

Source


app.models

Static property of
app
Type
Object
Default
{}

Files from the models folder with objects returned by their exported functions.

// models/user/permission.js
module.exports = function(app) {
    return {
        getPermission: function(id){}
    };
};
// controllers/user.js
module.exports = function(app) {
    return {
        get: function(req, res, callback) {
            var data = app.models['user/permission'].getPermission(req.params.userId);
            callback(null, data);
        }
    }
};

Source


app.routes

Static property of
app
Type
Object
Default
{}

Files from the routes folder with objects returned by their exported functions.

Source


app.styles

Static property of
app
Type
Object
Default
{}

Files from the styles folder as Functions ready to create new Items.

Source


app.components

Static property of
app
Type
Object
Default
{}

Files from the components folder as the Document instances.

Source


app.resources

Static property of
app
Type
Resources

Source


app.onReady()

Static property of
app
Type
Signal

Called when all modules, components, styled etc. have been loaded.

Source


app.cookies

Static property of
app
Type
Dict

On the client side, this object refers to the last received cookies from the networking request.

On the server side, this cookies object are added into the each networking response.

By default, client has clientId and sessionId hashes.

app.cookies.onChange(function(key){
    console.log('cookie changed', key, this[key]);
});
<h1>Your clientId</h1>
<em>${context.app.cookies.clientId}</em>

Source

results matching ""

    No results matching ""