@boomerang-io/webapp-spa-server

1.3.0-beta.5 • Public • Published

Webapp SPA Server

Provide a consistent way to deploy Boomerang React SPAs with client-side routing into an IBM Cloud Private environment.

Features

  • Serve static assets
  • Client-side routing support for SPAs
  • Dynamic data and script injection into HTML document at run-time
  • Logging with @boomerang-io/logger-middleware
  • Cloud native health checking with Cloud Native Health Connect
  • New Relic monitoring
  • Instana monitoring
  • Google Analytics
  • BeeHeard survey

Design

The server can be invoked via a command line or imported as a configurable function to be executed.

  • CLI - for easy stand alone use that can be invoked via a script e.g. in npm scripts
  • Function - create server and run it within a node.js file

CLI

The server can be run via the CLI interface with configuration pass as options.

Enter the following to see the manual

boomerang-webapp-server --help

Command

boomerang-webapp-server serve

Options

Option Alias Description
--cors -c CORS configuration using cors package. Accepts JSON string
--disableInjectHTMLHeadData -d Toggle whether the app needs to inject data into the header. Defaults to false
--dotenvFilePath -p Path to local .env file to read in. Useful for local testing

Use as a function

const server = require("@boomerang-io/webapp-spa-server");
server({
  cors: {},
  disableInjectHTMLHeadData: true,
});

Environment Variables

The following env variables are assumed to exist either from a local .env file or passed in to the container at runtime. If nothing is passed it, it will default to the following:

Variable Purpose Type
APP_ROOT Root context of the application string
BUILD_DIR directory relative to the exeuction where app files are located string
PORT Port for server to run on number
HTML_HEAD_INJECTED_DATA_KEYS Environment variables to inject into the HTML document comma delimited list
HTML_HEAD_INJECTED_SCRIPTS Scripts to inject into HTML document. Files need to be in the BUILD_DIR comma delimited list
NEW_RELIC_APP_NAME App name for New Relic monitoring string
NEW_RELIC_LICENSE_KEY License key for New Relic monitoring string
INSTANA_REPORTING_URL Reporting URL for Instana monitoring string
INSTANA_KEY License key for Instana monitoring string
GA_SITE_ID Site ID for Goolge Analytics string
ENABLE_BEEHEARD_SURVEY Enable BeeHeard survey boolean

Defaults

Some of the values, both config and environment variables have defaults in the server for deploying to the IBM Consulting Essentials platform.

APP_ROOT

  • "/"

BUILD_DIR

  • "build"

CORS

{
  "origin": "*",
  "allowedHeaders": "Content-Type, Authorization, Content-Length, X-Requested-With",
  "methods": "DELETE,GET,OPTIONS,PATCH,POST,PUT"
}

HTML_HEAD_INJECTED_DATA_KEYS

  • APP_ROOT
  • BASE_APPS_ENV_URL
  • BASE_LAUNCH_ENV_URL
  • BASE_SERVICE_ENV_URL
  • BASE_WWW_ENV_URL
  • CORE_APPS_ENV_URL
  • CORE_ENV_URL
  • CORE_SERVICE_ENV_URL
  • PRODUCT_APPS_ENV_URL
  • PRODUCT_ENV_URL
  • PRODUCT_SERVICE_ENV_URL

PORT

  • 3000

Readme

Keywords

Package Sidebar

Install

npm i @boomerang-io/webapp-spa-server

Weekly Downloads

48

Version

1.3.0-beta.5

License

Apache-2.0

Unpacked Size

17.1 kB

Total Files

7

Last publish

Collaborators

  • timrbula
  • tysonlawrie
  • benjamin-ruby
  • isa-kawa
  • lucasgrimauth