npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hmcts/properties-volume

v1.1.0

Published

Azure key-vault flex volume to express properties integration

Downloads

28,356

Readme

properties-volume-nodejs

MIT license

This module is to incorporate the integration of the Azure key-vault flex volume to node properties.

Usage

This module adds the properties volume entries into the configuration object from 'config' We use the default mount point of /mnt/ volume, which happens exposes the key vault in chart-nodejs.

We use the last folder of the mount point, secrets, to map the properties into the configuration.

Below is an example:

{
 "secrets": {
   "VAULT": {
     "secretOne": "VALUE",
     "some-secret-two": "VALUE"
   },
   "VAULT2": {
     "secretOne": "VALUE",
     "some-secret-two": "VALUE"
   }
 }
}

NOTE

  • The property names are not sanitised and are an exact copy from the file names on volume. This means when using the hmcts/nodejs helm chart the property naming is exactly the same as those in the key vault.

  • Application property defaults can be added to your application configuration for the config package using the same object structure.

    e.g To add a default for the property secrets.cmc.staff-email we would add the following to the configuration.

    in JSON:

    {
      "secrets": {
        "cmc": {
          "staff-email": "DEFAULT_EMAIL"
        }
      }
    }

    or in yaml

    secrets:
       cmc:
         staff-email: DEFAULT_EMAIL
    
  • If you have the need to add a test or add multiple property volumes in one application you can override the volume mount point. To do this we can supply a value for the defaulted volume folder in the api i.e addTo( config, {mountPoint:'some/other/folder/secrets'}).

  • The last folder name is used as the prefix for the properties in the configuration e.g. /mnt/secrets the properties start with secrets, /mnt/certs the properties start with certs.

  • If you mount volumes with the same last folder name e.g /mnt/super/secrets and /mnt/silly/secrets the properties will be fully merged together into the configuration object under secrets and the last property volume that is merged in will override any properties with the same name.

Quick start

$ yarn add @hmcts/properties-volume

Typescript

import * as config from 'config'
import * as propertiesVolume from '@hmcts/properties-volume'
propertiesVolume.addTo(config)

Javascript

config = require('@hmcts/properties-volume').addTo(require('config'))

Options

The properties volume can be supplied with a couple of options via a js like options object. e.g.

const config = require('@hmcts/properties-volume').addTo(require('config'),{mountPoint:'some/properties/mount/point'})

| Option | Description | Default | | ------ | ----------- | ------- | | mountPoint | the folder where the properties volume exists. | /mnt/secrets/| | failOnError | Should this module throw an exception if mount does not exist or there is an error reading the properties | false |

Local access to vaults

You can configure the application to connect directly to the Azure Vaults specified in your application's Helm chart. This is intended to be used locally, and not in production.

This method uses your local Azure AD authentication so you will need to run az login before running your application.

import * as config from 'config'
import { addTo, addFromAzureVault } from '@hmcts/properties-volume'

async function setupConfig() {
  if (process.env.NODE_ENV !== 'production') {
    await addFromAzureVault(config, { pathToHelmChart: 'charts/my-app/values.yaml' });
  } else {
    addTo(config);
  }
}

Note that this method is asynchronous and either needs to be awaited inside an async function or in a project with top level await enabled.

| Option | Description | Default | | ------ | ----------- | ------- | | pathToHelmChart | path to the values.yaml file for the Helm chart. | N/A| | env | Used to calculate the vault name | aat |