Custom Packages

How to create a Packer and Deployer for your application

Should you pack or deploy data with a module package, you can implement a "Packer" interface and provide data that will be included in that application's package.

  1. When you publish a module that has Scheduler Tasks, the tasks are packed with your module. A Packer is responsible for doing that;
    You don't need to implement a packer in your module to pack the tasks.

  2. When you publish a module that has Templates, the templates are packed with your module. A packer is responsible for doing that.
    You don't need to implement a packer in your module to pack the templates.

All packers are notified when the platform is creating a package from a module. So the packer can return the data specifically for that module.

Hardcode Data

In the case you wish to pack hardcode data, you may not event need to generate data. Just create your packer with the deploy function and run your code.

Whenever an application is installed, your deploy code will be invoked.

Packer Code Sample

 * SamplePacker
 * inpaas.util.packer.samplepacker
/*global require*/
(function(scope) {
    'use strict';
    var logger = require("inpaas.core.log");
     * Should return a list of data to include in the package
    function pack(module) {"SamplePacker::packing ...");
        return require("your-business-service").find();    
     * Must deploy listed itens
    function deploy(module, data) {
        if (data == null) return;"SamplePacker::deploying ...");
        var serviceBd = require("your-business-service");
        for(var k in data) {
            var o = data[k];
  "SamplePacker::deploy - {}", o);       
            var c = serviceBd.get(o.key);
            if (c == null) {           
            } else {
    /* exports */
    scope["pack"] = pack;
    scope["deploy"] = deploy;
    scope["getFileName"] = function() { return ""; };
    return scope;      



  • Since your packer/deployer will always be invoked when a module is installed/packed in the instance. It is necessary to prevent unwanted execution by validating the module data;
  • The packer/deployer will never prevent an application of being installed/packed;
  • It is recommended that you provide ways of exporting/importing the package manually, thus, you can pack/deploy that package manually if you wish.