Search Results

Developing Node.js Code From Stub Code

After generating and downloading the server stub code generated from your API Specification, you can unzip the code archive and write your code in the editor of your choice.

Code ZIP Archive Contents

The generated code ZIP archive contains the following:

  • A manifest.json file, which is a standard TIBCO Cloud Integration manifest file for user apps. It defines endpoints, app name, description, and so on for this user app, as well as the API specification in Swagger format.

  • A folder containing the server stub code, including directories for config, data, handlers, tests, and utilities.

    The stub code is generated from the Swagger spec by using the generator-swaggerize framework ( For each path definition of the swagger spec, a handler file is generated Inside the handlers sub-folder, and a data file is generated inside the data sub-folder. Developers should replace the default “mock” data inside the data file with actual data feeds, based on the desired functionality.

  • A unit test file is generated corresponding to each path definition of the swagger spec; by default mock requests are generated based on the parameters definitions of the swagger spec, however developers can replace it with their own request data feeds.

  • Express Web Application

    Express is a flexible and well-accepted Node.js web application framework that provides a robust set of features for web and mobile applications. By leveraging Express, developers don’t have to worry about basic coding such as parsing the request, handling the request routing, taking care of the cookies and sessions, and so on. Developers can also use other features supported by Express, such as error handling, database integration, pr process management for their web applications.

As in all other Node.js apps, developers can use the package.json file under the root folder to manage the extra Node.js packages required in the app.

About Logging

In the util directory is a logger.js file, which provides a log function to be used by other code for generating the right format of logging. This logging format is essential for the log messages to be picked up and displayed correctly on the TIBCO® Cloud Integration front-end UI.

For an example of how to use the log object defined in this file, see the server.js file located in the root directory of the ZIP archive.

Basically you need to add these in your code in order to generate log messages:

var Logger = require('./util/logger');   
/* use the right relative path in your code */


Logger.log(Logger.LOG_INFO, 'Your log messages here');
/* Four level of logging levels are available: LOG_ERROR, LOG_WARN, LOG_INFO, and LOG_DEBUG */

About Node.js Modules

You can also add and use any Node.js modules available on when writing your implementation.

Note that we reserve the right to blacklist Node.js modules in the future if they are found to be an issue.

Other Notes

  • The default port 8000 for the app’s API service that we set in the generated stub code must not be changed

  • Developers should not modify any part of the manifest.json file, which could cause deployment or the running of the app to fail.

  • It is possible to access the file system of the app container, but we do not guarantee how long any files will persist. You are responsible for any housekeeping of files you generate.

Packaging Your Code

After you have made your changes to the stub code, zip the folder that contains the stub code (the folder at the same level as the manifest.json file), to generate a new ZIP archive file. Do not include the manifest.json in the new ZIP archive.

You can push your new app archive as described in Pushing and Deploying Node.js Apps. Before you push your app, make sure you have tested the app in your local development environment.