HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Node.JS code package format

Optimizely DXP supports Node.JS code package formats as a deployment container format. Because many developers will want to adapt the basic container format to suit the needs of their specific use case, developers can configure changes to the deployment container built from the code package in the dxpPlatformSettings.json file within that package. This article explains the format for configuring a Node.JS code package and provides an example file that can be extended for application development with Optimizely DXP code package deployments.

The dxpPlatformSettings.json file lets specific settings and installed packages be configured for a code package. For example, a package developer may want a code package that uses a specific entry point for the application or uses NPM packages that are not already present in the container.

The format of dxpPlatformSettings.json is a JSON object consisting of two required attributes:

  • entrypoint – A string attribute with the file name containing the executable code to be run when the container is initialized. Normally, this is a main.js file or its equivalent.
  • platformPackages – An array of objects consisting of two string attributes, name and version, which identifies the package name and version to install into the container.

The following plaformschema.json file shows the schema for these package configuration files.

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "The schema file that should be used for validation",
      "enum": [
        "https://schema.episerver.net/paasportal/2022-03-24/platformschema.json"
      ]
    },
    "entrypoint": {
      "type": "string",
      "description": "Manually specified entrypoint to use in the docker configuration"
    },
    "platformPackages": {
      "type": "array",
      "items": [
        {
          "type": "object",
          "description": "Additional packages that should be installed",
          "properties": {
            "name": {
              "type": "string",
              "description": "Name of the package",
              "enum": [
                "NodeJs"
              ]
            },
            "version": {
              "type": "integer",
              "description": "Version of the package that should be installed"
            }
          },
          "required": [
            "name",
            "version"
          ]
        }
      ]
    }
  },
  "required": [
    "$schema"
  ]
}

The following example illustrates the format of a dxpPlatformSettings.json file. This configuration file will initialize a code package in the following way:

  • The package is built into a container with additional layers installed to support two common JavaScript libraries: lodash version 14.17.21 and express version 4.18.0.
  • The container executes a custom entry point named startHere.js.
{
  "entrypoint": "startHere.js",
  "platformPackages": [
      {
      "name": "lodash",
      "version": "14.17.21"
      },
      {
      "name": "express",
      "version": "4.18.0"
      }
  ]
}