Would you like to contribute to the Titanium docs? To get started, sign up for an account on the Appcelerator Wiki and sign our CLA.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed the custom error messages information per RDPP-1734

...

Code Block
titleapp.js
var Arrow = require('arrow');
var server = new Arrow();

server.on('starting', function () {
    server.logger.debug('server is starting!');
 
    // server.app reference the Express app instance
    server.app.use(function (req, res, next) {
        if (!req.secure) {
            return res.redirect('https://' + req.get('Host') + req.originalUrl);
        } else {
            next();
        }
    });
});
// start the server
server.start();

Custom 404 page

You can render your own custom not found page by adding the following code to your app.js:

Code Block
linenumberstrue
languagejs
var Arrow = require('arrow'),
    server = new Arrow();

server.on('started', function( ) {
    server.logger.debug('server started!');

    // add a 404 error handler
    server.app.use(function(req, resp, next) {
        if (!resp.bodyFlushed) {
            resp.status(404).render('404', {
                menuName: 'Not Found'
            });
        }
        next(false);
    });

});

// start the server
server.start();

This example renders a 404 page from web/views/404.md:

Code Block
languagexml
<strong>404!</strong>

<p>Oh no, nothing was found! I am so sorry. :(</p>

Custom 500 page

You can render your own custom error handling page by adding the following code to your app.js:

Code Block
linenumberstrue
languagejs
var Arrow = require('arrow'),
    server = new Arrow();

server.on('started', function( ) {
    server.logger.debug('server started!');

    // add a 500 error handler
    app.use(function(err, req, resp, next) {
        if (!resp.bodyFlushed) {
            server.logger.error(req.originalUrl + ' Failed With ' + err.stack);

            app.render('500', function(err, html) {
                resp.status(500).send(html);
                next(false);
            });
        }
    });

});

// start the server
server.start();

This example renders a 500 page from web/views/500.md:

Code Block
languagexml
<strong>500 Error!</strong>

<p>Oh no, something went wrong! I am so sorry. :(</p>

Deploy the application

To deploy an application to API Runtime Services, run the appc publish command from the API Runtime Services project directory.  Your project source code will be uploaded to the API Runtime Services where npm install will be executed against the project, which downloads and installs any NPM module dependencies. When installation completes, the application is executed using node.

...

  • To specify a bigger container for the application, set the cloud.container field in the appc.json file or use the appc cloud server command.
  • To use more than one container for your application, see Scale the Application.

You can specify one of the following container sizes depending on your Appcelerator Platform subscription:

Excerpt
NamePoint CostMemoryCPU SharesArchive Behavior
Dev1512MB1000After an hour of inactivity
Small2256MB1000After a week of inactivity
Medium4512MB2000After a week of inactivity
Large81024MB4000After a week of inactivity
XLarge162048MB8000After a week of inactivity
Note

It is important to choose small containers (256MB) wisely. We recommend the use of a medium (512MB) or larger container for MBS (formerly known as ArrowDB) apps.

 

...