Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
/ pus-decorator Public archive

Decorates a static web application for use on nav.no

License

Notifications You must be signed in to change notification settings

navikt/pus-decorator

Repository files navigation

pus-decorator

Decorates a static web application for use on nav.no

supported functionality

pus-decorator comes with much functionality out of the box, but may be deactivated using the following environment variables:

  • DISABLE_DECORATOR
  • DISABLE_PROXY
  • DISABLE_UNLEASH
  • DISABLE_FRONTEND_LOGGER
  • DISABLE_SENSU_METRICS

BETA: Use the environment variabel GZIP_ENABLED in the Dockerfile to turn on gzipping for files: ENV GZIP_ENABLED=true.

usage

use this image as baseimage and set the required configuration parameters. The new image will serve a static web application from index.html found in directory /app with the enabled functionality.

convert your application like this:

https://github.com/navikt/jobbsokerkompetanse/commit/a24450465ee4b49e7772f7739c8249ae95a59a97

configuration

pus-decorator checks for a configuration file at /decorator.yaml unless a different path is explicitly set through the CONFIGURATION_LOCATION environment variable . If either of these files are absent or if some required attributes are undefined, pus-decorator will apply sane and safe default. Using a minimalistic configuration file, only overriding or extending default behaviour is therefore fine.

Please see the example configuration file

typically, you add the following line to the Dockerfile to add decorator.yaml to the docker-container:

ADD decorator.yaml /decorator.yaml

environment variables

in addition to the configuration file the following environment variables are supported:

proxy configuration

Please see the example configuration file

Multiple single page applications

Please see the example configuration file

Enforced login

If your application requires the user to be logged in, the pus-decorator can enforce this. Check out the example configuration file.
And don't forget to set the webproxy-flag to true in your application's nais.yaml.

/environment.js

endpoint that exposes system properties/environment variables matching this regex: ^PUBLIC_.+. Example:

GET /myapp/environment.js

myapp = window.myapp || {};
myapp['prop2']='content2';
myapp['prop1']='content1';
myapp['MY_ENV_VARIABLE']='tester environment';
myapp['prop']='content';

Feature-evaluation

Two different endpoints that evaluates a list of feature toggles using Unleash.

Example that evaluates toggle-a, toggle-b and toggle-c

GET /myapp/api/feature?feature=toggle-a&feature=toggle-b&feature=toggle-c

Returns application/json

{
    "toggle-b":false,
    "toggle-a":true,
    "toggle-c":false    
}