0.0.12 • Published 6 years ago

ssm-params-convict-adapter v0.0.12

Weekly downloads
3
License
WTFPL
Repository
github
Last release
6 years ago

TypeScript Maintainability bithound styled with prettier Built with generator-ts-np

ssm-params-convict-adapter

Allows loading ssm parameters via convict

npm npm node version Dependency Security Status Peer Dependencies Security Status Travis PRs Welcome License

npm.io

Install

npm i --save ssm-params-convict-adapter

Peer Dependencies

Before installing this package you need the following peer dependencies installed in your project (If they are not already installed):

npm i -D aws-sdk convict

How it works?

The schema is expressed as a conventional convict schema with an extra property ssmParameter that eaccepts an object with two values the path and whether it should be strict when requesting the value (error in absence of a value).

Example schema:

const schema = {
  auth: {
    default: true,
    doc: 'Whether authentication is required',
    env: 'TESTDB_AUTH',
    format: Boolean,
  },
  password: {
    default: '',
    doc: 'The example testdb password',
    env: 'TESTDB_PASS',
    format: String,
    ssmParameter: {
      path: '/testdb/db/password',
      strict: false,
    },
  },
  username: {
    default: '',
    doc: 'The example testdb username',
    env: 'TESTDB_USER',
    format: String,
    ssmParameter: {
      path: '/testdb/db/username',
      strict: true,
    },
  },
};
export default schema;

Usage

Example usage:

import * as logger from 'winston';
import SSMParamsConvictAdapter from 'ssm-params-convict-adapter';
import schema from './schema';

(async () => {
  try {
    const config = await SSMParamsConvictAdapter.convict(schema);
    logger.info(JSON.stringify(config.getProperties()));
  } catch (e) {
    logger.log('error', e);
  }
})();

Change log

v0.0.3

used version of ts-np generator

Licence

WTFPL © Andreas Galazis

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.4

6 years ago

0.0.1

6 years ago